gnodet-bot commented on code in PR #13179: URL: https://github.com/apache/maven/pull/13179#discussion_r4046498520
########## its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh13059MvnupJarPluginUpgradeTest.java: ########## @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.it; + +import java.io.File; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Integration test for GH-13059: mvnup jar-plugin upgrade target. + * <p> + * Verifies that {@code mvn --up apply} upgrades {@code maven-jar-plugin} to + * <strong>3.4.1</strong> — the last release before the two regressions introduced + * in 3.4.2 via maven-archiver 3.6.3: + * <ul> + * <li>{@code SOURCE_DATE_EPOCH=0} / {@code 1970-01-01T00:00:00Z} timestamps are + * rejected with {@code IllegalArgumentException} + * (apache/maven-jar-plugin#595)</li> + * <li>Derived {@code Automatic-Module-Name} values containing hyphens fail + * the build with {@code Invalid automatic module name: '...'} + * (apache/maven-jar-plugin#596)</li> + * </ul> + * After the upgrade, the project is built with {@code mvn package} to confirm + * that maven-jar-plugin 3.4.1 works correctly under Maven 4. + * + * @see <a href="https://github.com/apache/maven/pull/13059">GH-13059</a> + * @since 4.0.0-rc-7 + */ +public class MavenITgh13059MvnupJarPluginUpgradeTest extends AbstractMavenIntegrationTestCase { + + public MavenITgh13059MvnupJarPluginUpgradeTest() { + super(ALL_MAVEN_VERSIONS); Review Comment: **Compile error: `ALL_MAVEN_VERSIONS` does not exist on `maven-4.0.x`.** `AbstractMavenIntegrationTestCase` on this branch has only a no-arg constructor — there is no `String`-arg constructor and no `ALL_MAVEN_VERSIONS` constant. Both were introduced on `master` (4.1.x). This will fail compilation. Drop the constructor entirely; the inherited no-arg is sufficient (all other `MavenITgh*` tests on this branch omit the constructor): ```suggestion ``` ########## its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh13059MvnupJarPluginUpgradeTest.java: ########## @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.it; + +import java.io.File; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Integration test for GH-13059: mvnup jar-plugin upgrade target. + * <p> + * Verifies that {@code mvn --up apply} upgrades {@code maven-jar-plugin} to + * <strong>3.4.1</strong> — the last release before the two regressions introduced + * in 3.4.2 via maven-archiver 3.6.3: + * <ul> + * <li>{@code SOURCE_DATE_EPOCH=0} / {@code 1970-01-01T00:00:00Z} timestamps are + * rejected with {@code IllegalArgumentException} + * (apache/maven-jar-plugin#595)</li> + * <li>Derived {@code Automatic-Module-Name} values containing hyphens fail + * the build with {@code Invalid automatic module name: '...'} + * (apache/maven-jar-plugin#596)</li> + * </ul> + * After the upgrade, the project is built with {@code mvn package} to confirm + * that maven-jar-plugin 3.4.1 works correctly under Maven 4. + * + * @see <a href="https://github.com/apache/maven/pull/13059">GH-13059</a> + * @since 4.0.0-rc-7 + */ +public class MavenITgh13059MvnupJarPluginUpgradeTest extends AbstractMavenIntegrationTestCase { + + public MavenITgh13059MvnupJarPluginUpgradeTest() { + super(ALL_MAVEN_VERSIONS); + } + + /** + * Verify that mvnup upgrades maven-jar-plugin 3.3.0 to 3.4.1 (not 3.4.2+ + * which carries regressions), then that the upgraded project builds cleanly + * with Maven 4. + */ + @Test + void testMvnupUpgradesJarPluginTo341AndBuilds() throws Exception { + File testDir = extractResources("gh-13059-mvnup-jar-plugin"); Review Comment: **Compile error: `extractResources()` returns `Path`, not `File`.** `AbstractMavenIntegrationTestCase.extractResources()` is declared as `protected Path extractResources(String)`. Assigning its result to `File testDir` fails to compile. All subsequent `testDir.getAbsolutePath()` and `testDir.toPath()` calls also rely on the wrong type. Use `Path` throughout and pass it directly to `newVerifier(Path)` (which has a `Path`-accepting overload on this branch): ```suggestion Path testDir = extractResources("gh-13059-mvnup-jar-plugin"); ``` Then replace `newVerifier(testDir.getAbsolutePath())` → `newVerifier(testDir)`, `testDir.toPath().resolve(...)` → `testDir.resolve(...)`, and `testDir.getAbsolutePath()` in CLI args → `testDir.toString()`. Also remove the now-unused `import java.io.File;`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
