From 047709628bc1f1175240f5cb4e53028e16886475 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 14 Dec 2022 21:15:04 +0100 Subject: [PATCH 1/7] [MNG-7629] Add an IT --- .../it/MavenITmng7629SubtreeBuildTest.java | 66 + .../apache/maven/it/TestSuiteOrdering.java | 1 + .../src/test/resources-filtered/bootstrap.txt | 1 + .../resources/mng-7629/.mvn/placeholder.txt | 0 .../test/resources/mng-7629/child-1/pom.xml | 63 + .../org/apache/maven/its/mng7629/Test.java | 23 + .../child-1/src/main/mdo/settings.mdo | 1083 +++++++++++++++++ .../test/resources/mng-7629/child-2/pom.xml | 71 ++ .../src/test/resources/mng-7629/pom.xml | 34 + 9 files changed, 1342 insertions(+) create mode 100644 core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7629SubtreeBuildTest.java create mode 100644 core-it-suite/src/test/resources/mng-7629/.mvn/placeholder.txt create mode 100644 core-it-suite/src/test/resources/mng-7629/child-1/pom.xml create mode 100644 core-it-suite/src/test/resources/mng-7629/child-1/src/main/java/org/apache/maven/its/mng7629/Test.java create mode 100644 core-it-suite/src/test/resources/mng-7629/child-1/src/main/mdo/settings.mdo create mode 100644 core-it-suite/src/test/resources/mng-7629/child-2/pom.xml create mode 100644 core-it-suite/src/test/resources/mng-7629/pom.xml diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7629SubtreeBuildTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7629SubtreeBuildTest.java new file mode 100644 index 000000000..48b0c69aa --- /dev/null +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7629SubtreeBuildTest.java @@ -0,0 +1,66 @@ +package org.apache.maven.it; + +/* + * 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. + */ + +import org.apache.maven.shared.verifier.Verifier; +import org.apache.maven.shared.verifier.util.ResourceExtractor; +import org.junit.jupiter.api.Test; + +import java.io.File; + +/** + * This is a test set for MNG-7629. + * It checks that building a subtree that consumes an attached artifact works + * + */ +class MavenITmng7629SubtreeBuildTest + extends AbstractMavenIntegrationTestCase +{ + + public MavenITmng7629SubtreeBuildTest() + { + super( "[4.0.0-alpha-4,)" ); + } + + /** + * Verify that dependencies which are managed through imported dependency management work + * + * @throws Exception in case of failure + */ + @Test + void testBuildSubtree() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-7629" ); + + Verifier verifier = newVerifier( testDir.getAbsolutePath() ); + verifier.setAutoclean( true ); + verifier.addCliArgument( "verify" ); + verifier.execute(); + verifier.verifyErrorFreeLog(); + + verifier = newVerifier( testDir.getAbsolutePath() ); + verifier.setAutoclean( true ); + verifier.addCliArguments( "-f", "child-2", "verify" ); + verifier.execute(); + verifier.verifyErrorFreeLog(); + } + +} diff --git a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java index e5e8e1a53..1e5ab87e3 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java @@ -105,6 +105,7 @@ public TestSuiteOrdering() * the tests are to finishing. Newer tests are also more likely to fail, so this is * a fail fast technique as well. */ + suite.addTestSuite( MavenITmng7629SubtreeBuildTest.class ); suite.addTestSuite( MavenITmng7606DependencyImportScopeTest.class ); suite.addTestSuite( MavenITmng6609ProfileActivationForPackagingTest.class ); suite.addTestSuite( MavenITmng7566JavaPrerequisiteTest.class ); diff --git a/core-it-suite/src/test/resources-filtered/bootstrap.txt b/core-it-suite/src/test/resources-filtered/bootstrap.txt index d9ccd06b7..148c05a81 100644 --- a/core-it-suite/src/test/resources-filtered/bootstrap.txt +++ b/core-it-suite/src/test/resources-filtered/bootstrap.txt @@ -132,6 +132,7 @@ org.apache.maven:maven-script-ant:2.1.0 org.apache.maven:maven-settings-builder:3.1.1 org.apache.maven:maven-settings:3.1.1 org.codehaus.gmavenplus:gmavenplus-plugin:1.11.0 +org.codehaus.mojo:build-helper-maven-plugin:3.2.0 org.codehaus.mojo:flatten-maven-plugin:1.0.0 org.codehaus.plexus:plexus-classworlds:2.5.1 org.codehaus.plexus:plexus-component-annotations:1.5.5 diff --git a/core-it-suite/src/test/resources/mng-7629/.mvn/placeholder.txt b/core-it-suite/src/test/resources/mng-7629/.mvn/placeholder.txt new file mode 100644 index 000000000..e69de29bb diff --git a/core-it-suite/src/test/resources/mng-7629/child-1/pom.xml b/core-it-suite/src/test/resources/mng-7629/child-1/pom.xml new file mode 100644 index 000000000..8e1845845 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-7629/child-1/pom.xml @@ -0,0 +1,63 @@ + + + + 4.0.0 + + + org.apache.maven.its.mng7629 + test + 1.0-SNAPSHOT + + + child-1 + + + 8 + 8 + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.2.0 + + + attach-mdo + + attach-artifact + + + + + src/main/mdo/settings.mdo + mdo + + + + + + + + + + diff --git a/core-it-suite/src/test/resources/mng-7629/child-1/src/main/java/org/apache/maven/its/mng7629/Test.java b/core-it-suite/src/test/resources/mng-7629/child-1/src/main/java/org/apache/maven/its/mng7629/Test.java new file mode 100644 index 000000000..9217ba515 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-7629/child-1/src/main/java/org/apache/maven/its/mng7629/Test.java @@ -0,0 +1,23 @@ +/* + * 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.its.mng7629; + +class Test { + +} diff --git a/core-it-suite/src/test/resources/mng-7629/child-1/src/main/mdo/settings.mdo b/core-it-suite/src/test/resources/mng-7629/child-1/src/main/mdo/settings.mdo new file mode 100644 index 000000000..93fa6034a --- /dev/null +++ b/core-it-suite/src/test/resources/mng-7629/child-1/src/main/mdo/settings.mdo @@ -0,0 +1,1083 @@ + + + + + + settings + Settings + + This is a reference for the user-specific configuration for Maven.

+

Includes things that should not be distributed with the pom.xml file, such as developer identity, along with + local settings, like proxy information.

+

The default location for the settings file is ~/.m2/settings.xml

+ ]]> +
+ + + package + org.apache.maven.settings + + + + + TrackableBase + 1.0.0+ + + common base class that contains code to track the source for + this instance (USER|GLOBAL) + + + + 1.0.0+ + + + + + + + + IdentifiableBase + TrackableBase + 1.0.0+ + + Mirror, Profile, Proxy and Server. + ]]> + + + id + 1.0.0+ + String + default + true + + + + + Settings + 1.0.0+ + TrackableBase + + Root element of the user configuration file. + + + + localRepository + 1.0.0+ + true + + Default value is: ${user.home}/.m2/repository + ]]> + + String + + + interactiveMode + 1.0.0+ + + + + boolean + true + + + usePluginRegistry + 1.0.0+ + + + + boolean + false + + + + + offline + 1.0.0+ + false + + + + boolean + false + + + + + proxies + 1.0.0+ + + + + + Proxy + * + + + + servers + 1.0.0+ + + + + + Server + * + + + + mirrors + 1.0.0+ + + Configuration of download mirrors for repositories. + + + Mirror + * + + + + profiles + 1.0.0+ + + + + + Profile + * + + + + activeProfiles + 1.0.0+ + + + + + String + * + + + + pluginGroups + 1.0.0+ + + List of groupIds to search for a plugin when that plugin + groupId is not explicitly provided. + + + String + * + + + + + + 1.0.0+ + + activeProxy field to null + */ + public void flushActiveProxy() + { + this.activeProxy = null; + } + + /** + * @return the first active proxy + */ + public synchronized Proxy getActiveProxy() + { + if ( activeProxy == null ) + { + java.util.List proxies = getProxies(); + if ( proxies != null && !proxies.isEmpty() ) + { + for ( Proxy proxy : proxies ) + { + if ( proxy.isActive() ) + { + activeProxy = proxy; + break; + } + } + } + } + + return activeProxy; + } + + public Server getServer( String serverId ) + { + Server match = null; + + java.util.List servers = getServers(); + if ( servers != null && serverId != null ) + { + for ( Server server : servers ) + { + if ( serverId.equals( server.getId() ) ) + { + match = server; + break; + } + } + } + + return match; + } + + @Deprecated + public Mirror getMirrorOf( String repositoryId ) + { + Mirror match = null; + + java.util.List mirrors = getMirrors(); + if ( mirrors != null && repositoryId != null ) + { + for ( Mirror mirror : mirrors ) + { + if ( repositoryId.equals( mirror.getMirrorOf() ) ) + { + match = mirror; + break; + } + } + } + + return match; + } + + private java.util.Map profileMap; + + /** + * Reset the profileMap field to null + */ + public void flushProfileMap() + { + this.profileMap = null; + } + + /** + * @return a Map of profiles field with Profile#getId() as key + * @see Profile#getId() + */ + public java.util.Map getProfilesAsMap() + { + if ( profileMap == null ) + { + profileMap = new java.util.LinkedHashMap(); + + if ( getProfiles() != null ) + { + for ( Profile profile : getProfiles() ) + { + profileMap.put( profile.getId(), profile ); + } + } + } + + return profileMap; + } + ]]> + + + + + + + + + Proxy + 1.0.0+ + IdentifiableBase + + <proxy> element contains informations required to a proxy settings. + ]]> + + + active + 1.0.0+ + false + true + + + + boolean + + + protocol + 1.0.0+ + + + + String + http + + + username + 1.0.0+ + + + + String + + + password + 1.0.0+ + + + + String + + + port + 1.0.0+ + + + + int + 8080 + + + host + 1.0.0+ + + + + String + true + + + nonProxyHosts + 1.0.0+ + + + + String + + + + + Server + 1.0.0+ + IdentifiableBase + + <server> element contains informations required to a server settings. + ]]> + + + username + 1.0.0+ + + + + String + + + password + 1.0.0+ + + + + String + + + privateKey + 1.0.0+ + + + + String + + + passphrase + 1.0.0+ + + + + String + + + filePermissions + 1.0.0+ + + + + String + + + directoryPermissions + 1.0.0+ + + + + String + + + configuration + DOM + + + + + + + + Mirror + 1.0.0+ + IdentifiableBase + + A download mirror for a given repository. + + + + mirrorOf + true + 1.0.0+ + String + + The server ID of the repository being mirrored, e.g., + "central". This MUST NOT match the mirror id. + + + + name + false + 1.0.0+ + String + + The optional name that describes the mirror. + + + + url + true + 1.0.0+ + String + The URL of the mirror repository. + + + layout + 1.1.0+ + String + default + The layout of the mirror repository. Since Maven 3. + + + mirrorOfLayouts + 1.1.0+ + String + default,legacy + + The layouts of repositories being mirrored. This value can be used to restrict the usage + of the mirror to repositories with a matching layout (apart from a matching id). Since Maven 3. + + + + blocked + 1.2.0+ + boolean + false + + Whether this mirror should be blocked from any download request but fail the download process, explaining why. + + + + + + 1.0.0+ + + + + + + + + + Profile + 1.0.0+ + IdentifiableBase + + + + + + activation + 1.0.0+ + + + + + Activation + + + + properties + + <property.name>property.value</property.name> + ]]> + + Properties + + String + * + + + + repositories + 1.0.0+ + + + + + Repository + * + + + + pluginRepositories + 1.0.0+ + + + + + Repository + * + + + + + + + + + Activation + 1.0.0+ + + + + + + activeByDefault + 1.0.0+ + boolean + + Flag specifying whether this profile is active as a default. + + + + jdk + 1.0.0+ + String + + + + + + os + 1.0.0+ + + + + + ActivationOS + + + + property + 1.0.0+ + + + + + ActivationProperty + + + + file + 1.0.0+ + + + + + ActivationFile + + + + + + + + RepositoryBase + 1.0.0+ + + + + + + id + 1.0.0+ + + + + String + + + name + 1.0.0+ + + + + String + + + url + 1.0.0+ + + + + String + + + layout + 1.0.0+ + + The type of layout this repository uses for locating and + storing artifacts - can be "legacy" or "default". + + String + default + + + + + 1.0.0+ + + + + + + + + + Repository + RepositoryBase + 1.0.0+ + + Repository contains the information needed for establishing + connections with remote repository + + + + releases + 1.0.0+ + + How to handle downloading of releases from this repository + + + RepositoryPolicy + + + + snapshots + 1.0.0+ + + How to handle downloading of snapshots from this repository + + + RepositoryPolicy + + + + + + + 1.0.0+ + + + + + + + + + RepositoryPolicy + 1.0.0+ + Download policy + + + enabled + 1.0.0+ + + Whether to use this repository for downloading this type of + artifact. + + boolean + true + + + updatePolicy + 1.0.0+ + + The frequency for downloading updates - can be "always", + "daily" (default), "interval:XXX" (in minutes) or "never" + (only if it doesn't exist locally). + + String + + + checksumPolicy + 1.0.0+ + + What to do when verification of an artifact checksum fails. Valid values are "fail" (default for Maven 4 and + above), "warn" (default for Maven 2 and 3) or "ignore". + + String + + + + + + ActivationProperty + 1.0.0+ + + + + + + name + 1.0.0+ + String + true + + The name of the property to be used to activate a profile. + + + + value + 1.0.0+ + String + + The value of the property to be used to activate a profile. + + + + + + ActivationOS + 1.0.0+ + + + + + + name + 1.0.0+ + String + + The name of the OS to be used to activate a profile. + + + + family + 1.0.0+ + String + + The general family of the OS to be used to activate a + profile (e.g. 'windows') + + + + arch + 1.0.0+ + String + + The architecture of the OS to be used to activate a profile. + + + + version + 1.0.0+ + String + + The version of the OS to be used to activate a profile. + + + + + + ActivationFile + 1.0.0+ + + + + + + missing + 1.0.0+ + String + + The name of the file that should be missing to activate a + profile. + + + + exists + 1.0.0+ + String + + The name of the file that should exist to activate a profile. + + + + + + +
diff --git a/core-it-suite/src/test/resources/mng-7629/child-2/pom.xml b/core-it-suite/src/test/resources/mng-7629/child-2/pom.xml new file mode 100644 index 000000000..b559a57ac --- /dev/null +++ b/core-it-suite/src/test/resources/mng-7629/child-2/pom.xml @@ -0,0 +1,71 @@ + + + + 4.0.0 + + + org.apache.maven.its.mng7629 + test + 1.0-SNAPSHOT + + + child-2 + + + + org.apache.maven.its.mng7629 + child-1 + 1.0-SNAPSHOT + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.3.0 + + + copy-model + + copy + + generate-sources + + + + org.apache.maven.its.mng7629 + child-1 + 1.0-SNAPSHOT + mdo + target/mdo/ + settings.mdo + + + + + + + + + + diff --git a/core-it-suite/src/test/resources/mng-7629/pom.xml b/core-it-suite/src/test/resources/mng-7629/pom.xml new file mode 100644 index 000000000..dae9ae7ce --- /dev/null +++ b/core-it-suite/src/test/resources/mng-7629/pom.xml @@ -0,0 +1,34 @@ + + + + 4.0.0 + + org.apache.maven.its.mng7629 + test + 1.0-SNAPSHOT + pom + + + child-1 + child-2 + + + From 4c17406b50a6bd039c1f7e6c68a851d4969fd8cc Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 13 Jan 2023 08:28:14 +0100 Subject: [PATCH 2/7] Fix ITs --- ...Tmng2720SiblingClasspathArtifactsTest.java | 5 ++- ...nITmng2921ActiveAttachedArtifactsTest.java | 8 ++-- ...ng3043BestEffortReactorResolutionTest.java | 39 ++++++++++--------- ...fierBasedDepResolutionFromReactorTest.java | 4 +- ...olutionForManuallyCreatedArtifactTest.java | 3 +- ...lutionOfDependenciesDuringReactorTest.java | 1 + ...137ReactorResolutionInForkedBuildTest.java | 2 +- 7 files changed, 35 insertions(+), 27 deletions(-) diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2720SiblingClasspathArtifactsTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2720SiblingClasspathArtifactsTest.java index 3dca206f2..f46d373de 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2720SiblingClasspathArtifactsTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2720SiblingClasspathArtifactsTest.java @@ -57,6 +57,7 @@ public void testIT() Verifier verifier = newVerifier( testDir.getAbsolutePath() ); verifier.setAutoclean( false ); + verifier.deleteDirectory( "target" ); verifier.deleteDirectory( "child2/target" ); verifier.deleteDirectory( "child3/target" ); verifier.addCliArgument( "initialize" ); @@ -90,14 +91,16 @@ private void assertMainJar( List classPath ) assertFalse( classPath.toString(), classPath.contains( "main" ) ); assertFalse( classPath.toString(), classPath.contains( "test.jar" ) ); assertFalse( classPath.toString(), classPath.contains( "test" ) ); + assertFalse( classPath.toString(), classPath.contains( "child1-1-tests.jar" ) ); } private void assertTestJar( List classPath ) { assertFalse( classPath.toString(), classPath.contains( "main.jar" ) ); assertFalse( classPath.toString(), classPath.contains( "main" ) ); - assertTrue( classPath.toString(), classPath.contains( "test.jar" ) ); + assertFalse( classPath.toString(), classPath.contains( "test.jar" ) ); assertFalse( classPath.toString(), classPath.contains( "test" ) ); + assertTrue( classPath.toString(), classPath.contains( "child1-1-tests.jar" ) ); } } diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2921ActiveAttachedArtifactsTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2921ActiveAttachedArtifactsTest.java index b02044a43..339c3a6c2 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2921ActiveAttachedArtifactsTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2921ActiveAttachedArtifactsTest.java @@ -87,10 +87,10 @@ public void testitMNG2921() testArtifacts.contains( "org.apache.maven.its.mng2921:producer:test-jar:tests:1.0-SNAPSHOT" ) ); Collection testClassPath = verifier.loadLines( "consumer/target/test-classpath.txt", "UTF-8" ); - assertTrue( testClassPath.toString(), testClassPath.contains( "ejbs/attached.jar" ) ); - assertTrue( testClassPath.toString(), testClassPath.contains( "tests/attached.jar" ) ); - assertTrue( testClassPath.toString(), testClassPath.contains( "producer/client.jar" ) ); - assertTrue( testClassPath.toString(), testClassPath.contains( "producer/tests.jar" ) ); + assertTrue( testClassPath.toString(), testClassPath.contains( "ejbs/ejbs-1.0-SNAPSHOT-client.jar" ) ); + assertTrue( testClassPath.toString(), testClassPath.contains( "tests/tests-1.0-SNAPSHOT-tests.jar" ) ); + assertTrue( testClassPath.toString(), testClassPath.contains( "producer/producer-1.0-SNAPSHOT-client.jar" ) ); + assertTrue( testClassPath.toString(), testClassPath.contains( "producer/producer-1.0-SNAPSHOT-tests.jar" ) ); } } diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3043BestEffortReactorResolutionTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3043BestEffortReactorResolutionTest.java index 27b2a3641..32107c69f 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3043BestEffortReactorResolutionTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3043BestEffortReactorResolutionTest.java @@ -25,6 +25,7 @@ import java.io.File; import java.util.List; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; /** @@ -56,6 +57,7 @@ public void testitTestPhase() Verifier verifier = newVerifier( testDir.getAbsolutePath() ); verifier.setAutoclean( false ); + verifier.deleteDirectory( "target" ); verifier.deleteDirectory( "consumer-a/target" ); verifier.deleteDirectory( "consumer-b/target" ); verifier.deleteDirectory( "consumer-c/target" ); @@ -113,6 +115,7 @@ public void testitPackagePhase() Verifier verifier = newVerifier( testDir.getAbsolutePath() ); verifier.setAutoclean( false ); + verifier.deleteDirectory( "target" ); verifier.deleteDirectory( "consumer-a/target" ); verifier.deleteDirectory( "consumer-b/target" ); verifier.deleteDirectory( "consumer-c/target" ); @@ -125,34 +128,34 @@ public void testitPackagePhase() List classpath; classpath = verifier.loadLines( "consumer-a/target/compile.txt", "UTF-8" ); - assertContains( classpath, new String[] { "tests.jar" } ); - assertNotContains( classpath, new String[] { "client.jar" } ); + assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); + assertNotContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); classpath = verifier.loadLines( "consumer-a/target/runtime.txt", "UTF-8" ); - assertContains( classpath, new String[] { "tests.jar" } ); - assertNotContains( classpath, new String[] { "client.jar" } ); + assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); + assertNotContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); classpath = verifier.loadLines( "consumer-a/target/test.txt", "UTF-8" ); - assertContains( classpath, new String[] { "tests.jar" } ); - assertNotContains( classpath, new String[] { "client.jar" } ); + assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); + assertNotContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); classpath = verifier.loadLines( "consumer-b/target/compile.txt", "UTF-8" ); - assertContains( classpath, new String[] { "client.jar" } ); - assertNotContains( classpath, new String[] { "tests.jar" } ); + assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); + assertNotContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); classpath = verifier.loadLines( "consumer-b/target/runtime.txt", "UTF-8" ); - assertContains( classpath, new String[] { "client.jar" } ); - assertNotContains( classpath, new String[] { "tests.jar" } ); + assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); + assertNotContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); classpath = verifier.loadLines( "consumer-b/target/test.txt", "UTF-8" ); - assertContains( classpath, new String[] { "client.jar" } ); - assertNotContains( classpath, new String[] { "tests.jar" } ); + assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); + assertNotContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); classpath = verifier.loadLines( "consumer-c/target/compile.txt", "UTF-8" ); - assertContains( classpath, new String[] { "client.jar" } ); - assertContains( classpath, new String[] { "tests.jar" } ); + assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); + assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); classpath = verifier.loadLines( "consumer-c/target/runtime.txt", "UTF-8" ); - assertContains( classpath, new String[] { "client.jar" } ); - assertContains( classpath, new String[] { "tests.jar" } ); + assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); + assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); classpath = verifier.loadLines( "consumer-c/target/test.txt", "UTF-8" ); - assertContains( classpath, new String[] { "client.jar" } ); - assertContains( classpath, new String[] { "tests.jar" } ); + assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); + assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); } private void assertContains( List collection, String[] items ) diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4056ClassifierBasedDepResolutionFromReactorTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4056ClassifierBasedDepResolutionFromReactorTest.java index e23fa250a..e9c970930 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4056ClassifierBasedDepResolutionFromReactorTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4056ClassifierBasedDepResolutionFromReactorTest.java @@ -90,8 +90,8 @@ public void testit() } List classpath = verifier.loadLines( "consumer/target/compile.txt", "UTF-8" ); - assertTrue( classpath.toString(), classpath.contains( "producer/test.jar" ) ); - assertTrue( classpath.toString(), classpath.contains( "producer/client.jar" ) ); + assertTrue( classpath.toString(), classpath.contains( "producer/producer-0.1-tests.jar" ) ); + assertTrue( classpath.toString(), classpath.contains( "producer/producer-0.1-client.jar" ) ); } } diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4233ReactorResolutionForManuallyCreatedArtifactTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4233ReactorResolutionForManuallyCreatedArtifactTest.java index 2a587b07c..670e5b56a 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4233ReactorResolutionForManuallyCreatedArtifactTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4233ReactorResolutionForManuallyCreatedArtifactTest.java @@ -63,7 +63,8 @@ public void testit() verifier.verifyErrorFreeLog(); Properties props = verifier.loadProperties( "consumer/target/artifact.properties" ); - assertEquals( new File( testDir.getCanonicalFile(), "producer/pom.xml" ), new File( + assertEquals( + new File( testDir.getCanonicalFile(), "target/project-local-repo/org.apache.maven.its.mng4233/producer/producer-1.0-SNAPSHOT.jar" ), new File( props.getProperty( "org.apache.maven.its.mng4233:producer:jar:1.0-SNAPSHOT" ) ).getCanonicalFile() ); } diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4814ReResolutionOfDependenciesDuringReactorTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4814ReResolutionOfDependenciesDuringReactorTest.java index c8d8e0707..8a92a4ec4 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4814ReResolutionOfDependenciesDuringReactorTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4814ReResolutionOfDependenciesDuringReactorTest.java @@ -57,6 +57,7 @@ public void testit() Verifier verifier = newVerifier( testDir.getAbsolutePath() ); verifier.setAutoclean( false ); + verifier.deleteDirectory( "target" ); verifier.deleteDirectory( "consumer/target" ); verifier.deleteArtifacts( "org.apache.maven.its.mng4814" ); verifier.addCliArgument( "-s" ); diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5137ReactorResolutionInForkedBuildTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5137ReactorResolutionInForkedBuildTest.java index e976cfa64..458dd0d6a 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5137ReactorResolutionInForkedBuildTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5137ReactorResolutionInForkedBuildTest.java @@ -67,7 +67,7 @@ public void testit() List compile = verifier.loadLines( "consumer/target/compile.txt", "UTF-8" ); - assertTrue( compile.toString(), compile.contains( "producer/pom.xml" ) ); + assertTrue( compile.toString(), compile.contains( "producer/producer-0.1.jar" ) ); } } From ea7575c6dfdfb34448fa815fdf5c6f4261334cba Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 13 Jan 2023 21:07:06 +0100 Subject: [PATCH 3/7] Fix --- .../maven/it/MavenITmng4660OutdatedPackagedArtifact.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4660OutdatedPackagedArtifact.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4660OutdatedPackagedArtifact.java index cfc476738..8f7847d20 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4660OutdatedPackagedArtifact.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4660OutdatedPackagedArtifact.java @@ -119,10 +119,7 @@ public void testShouldWarnWhenPackagedArtifactIsOutdated() throws Exception { verifier3.verifyTextInLog( "File '" + Paths.get( "module-a", "target", "classes", "example.properties" ) - + "' is more recent than the packaged artifact for 'module-a'; " - + "using '" - + Paths.get( "module-a", "target","classes" ) - + "' instead" + + "' is more recent than the packaged artifact for 'module-a', please run a full `mvn verify` build" ); } catch ( VerificationException e ) From 9bcb5e12fb393eb39ca5e71cff4578b1c6005dd1 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 17 Jan 2023 13:00:24 +0100 Subject: [PATCH 4/7] Update ITs --- .../it/MavenITmng2720SiblingClasspathArtifactsTest.java | 4 +--- .../it/MavenITmng2921ActiveAttachedArtifactsTest.java | 8 ++++---- ...ng4056ClassifierBasedDepResolutionFromReactorTest.java | 4 ++-- ...33ReactorResolutionForManuallyCreatedArtifactTest.java | 2 +- .../MavenITmng5137ReactorResolutionInForkedBuildTest.java | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2720SiblingClasspathArtifactsTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2720SiblingClasspathArtifactsTest.java index f46d373de..76c3d604d 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2720SiblingClasspathArtifactsTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2720SiblingClasspathArtifactsTest.java @@ -91,16 +91,14 @@ private void assertMainJar( List classPath ) assertFalse( classPath.toString(), classPath.contains( "main" ) ); assertFalse( classPath.toString(), classPath.contains( "test.jar" ) ); assertFalse( classPath.toString(), classPath.contains( "test" ) ); - assertFalse( classPath.toString(), classPath.contains( "child1-1-tests.jar" ) ); } private void assertTestJar( List classPath ) { assertFalse( classPath.toString(), classPath.contains( "main.jar" ) ); assertFalse( classPath.toString(), classPath.contains( "main" ) ); - assertFalse( classPath.toString(), classPath.contains( "test.jar" ) ); + assertTrue( classPath.toString(), classPath.contains( "test.jar" ) ); assertFalse( classPath.toString(), classPath.contains( "test" ) ); - assertTrue( classPath.toString(), classPath.contains( "child1-1-tests.jar" ) ); } } diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2921ActiveAttachedArtifactsTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2921ActiveAttachedArtifactsTest.java index 339c3a6c2..b02044a43 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2921ActiveAttachedArtifactsTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2921ActiveAttachedArtifactsTest.java @@ -87,10 +87,10 @@ public void testitMNG2921() testArtifacts.contains( "org.apache.maven.its.mng2921:producer:test-jar:tests:1.0-SNAPSHOT" ) ); Collection testClassPath = verifier.loadLines( "consumer/target/test-classpath.txt", "UTF-8" ); - assertTrue( testClassPath.toString(), testClassPath.contains( "ejbs/ejbs-1.0-SNAPSHOT-client.jar" ) ); - assertTrue( testClassPath.toString(), testClassPath.contains( "tests/tests-1.0-SNAPSHOT-tests.jar" ) ); - assertTrue( testClassPath.toString(), testClassPath.contains( "producer/producer-1.0-SNAPSHOT-client.jar" ) ); - assertTrue( testClassPath.toString(), testClassPath.contains( "producer/producer-1.0-SNAPSHOT-tests.jar" ) ); + assertTrue( testClassPath.toString(), testClassPath.contains( "ejbs/attached.jar" ) ); + assertTrue( testClassPath.toString(), testClassPath.contains( "tests/attached.jar" ) ); + assertTrue( testClassPath.toString(), testClassPath.contains( "producer/client.jar" ) ); + assertTrue( testClassPath.toString(), testClassPath.contains( "producer/tests.jar" ) ); } } diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4056ClassifierBasedDepResolutionFromReactorTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4056ClassifierBasedDepResolutionFromReactorTest.java index e9c970930..e23fa250a 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4056ClassifierBasedDepResolutionFromReactorTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4056ClassifierBasedDepResolutionFromReactorTest.java @@ -90,8 +90,8 @@ public void testit() } List classpath = verifier.loadLines( "consumer/target/compile.txt", "UTF-8" ); - assertTrue( classpath.toString(), classpath.contains( "producer/producer-0.1-tests.jar" ) ); - assertTrue( classpath.toString(), classpath.contains( "producer/producer-0.1-client.jar" ) ); + assertTrue( classpath.toString(), classpath.contains( "producer/test.jar" ) ); + assertTrue( classpath.toString(), classpath.contains( "producer/client.jar" ) ); } } diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4233ReactorResolutionForManuallyCreatedArtifactTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4233ReactorResolutionForManuallyCreatedArtifactTest.java index 670e5b56a..e1eb884aa 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4233ReactorResolutionForManuallyCreatedArtifactTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4233ReactorResolutionForManuallyCreatedArtifactTest.java @@ -64,7 +64,7 @@ public void testit() Properties props = verifier.loadProperties( "consumer/target/artifact.properties" ); assertEquals( - new File( testDir.getCanonicalFile(), "target/project-local-repo/org.apache.maven.its.mng4233/producer/producer-1.0-SNAPSHOT.jar" ), new File( + new File( testDir.getCanonicalFile(), "producer/pom.xml" ), new File( props.getProperty( "org.apache.maven.its.mng4233:producer:jar:1.0-SNAPSHOT" ) ).getCanonicalFile() ); } diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5137ReactorResolutionInForkedBuildTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5137ReactorResolutionInForkedBuildTest.java index 458dd0d6a..e976cfa64 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5137ReactorResolutionInForkedBuildTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5137ReactorResolutionInForkedBuildTest.java @@ -67,7 +67,7 @@ public void testit() List compile = verifier.loadLines( "consumer/target/compile.txt", "UTF-8" ); - assertTrue( compile.toString(), compile.contains( "producer/producer-0.1.jar" ) ); + assertTrue( compile.toString(), compile.contains( "producer/pom.xml" ) ); } } From d8ddc104e8108967fa4e62827d043a3207efb09a Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 17 Jan 2023 13:24:30 +0100 Subject: [PATCH 5/7] Use the correct lifecycle --- .../apache/maven/it/MavenITmng4660OutdatedPackagedArtifact.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4660OutdatedPackagedArtifact.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4660OutdatedPackagedArtifact.java index 8f7847d20..aa9f5637e 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4660OutdatedPackagedArtifact.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4660OutdatedPackagedArtifact.java @@ -119,7 +119,7 @@ public void testShouldWarnWhenPackagedArtifactIsOutdated() throws Exception { verifier3.verifyTextInLog( "File '" + Paths.get( "module-a", "target", "classes", "example.properties" ) - + "' is more recent than the packaged artifact for 'module-a', please run a full `mvn verify` build" + + "' is more recent than the packaged artifact for 'module-a', please run a full `mvn package` build" ); } catch ( VerificationException e ) From 0cbb3e483202326d8bae6e7e84d713b9be22c4ae Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 17 Jan 2023 23:03:59 +0100 Subject: [PATCH 6/7] Remove unused import --- .../maven/it/MavenITmng3043BestEffortReactorResolutionTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3043BestEffortReactorResolutionTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3043BestEffortReactorResolutionTest.java index 32107c69f..43053a06a 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3043BestEffortReactorResolutionTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3043BestEffortReactorResolutionTest.java @@ -25,7 +25,6 @@ import java.io.File; import java.util.List; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; /** From 0807fe95235bbca729abd087df3a77ff174eaa0b Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 19 Jan 2023 11:25:47 +0100 Subject: [PATCH 7/7] Fix tests so that they work on pre and post 4.0.0-m4 --- ...ng3043BestEffortReactorResolutionTest.java | 38 ++++++++++--------- ...olutionForManuallyCreatedArtifactTest.java | 3 +- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3043BestEffortReactorResolutionTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3043BestEffortReactorResolutionTest.java index 43053a06a..1985b8605 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3043BestEffortReactorResolutionTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3043BestEffortReactorResolutionTest.java @@ -124,37 +124,39 @@ public void testitPackagePhase() verifier.execute(); verifier.verifyErrorFreeLog(); + String prefix = matchesVersionRange("[4.0.0-alpha-4,)") ? "dependency-0.1-SNAPSHOT-" : ""; + List classpath; classpath = verifier.loadLines( "consumer-a/target/compile.txt", "UTF-8" ); - assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); - assertNotContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); + assertContains( classpath, new String[] { prefix + "tests.jar" } ); + assertNotContains( classpath, new String[] { prefix + "client.jar" } ); classpath = verifier.loadLines( "consumer-a/target/runtime.txt", "UTF-8" ); - assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); - assertNotContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); + assertContains( classpath, new String[] { prefix + "tests.jar" } ); + assertNotContains( classpath, new String[] { prefix + "client.jar" } ); classpath = verifier.loadLines( "consumer-a/target/test.txt", "UTF-8" ); - assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); - assertNotContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); + assertContains( classpath, new String[] { prefix + "tests.jar" } ); + assertNotContains( classpath, new String[] { prefix + "client.jar" } ); classpath = verifier.loadLines( "consumer-b/target/compile.txt", "UTF-8" ); - assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); - assertNotContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); + assertContains( classpath, new String[] { prefix + "client.jar" } ); + assertNotContains( classpath, new String[] { prefix + "tests.jar" } ); classpath = verifier.loadLines( "consumer-b/target/runtime.txt", "UTF-8" ); - assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); - assertNotContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); + assertContains( classpath, new String[] { prefix + "client.jar" } ); + assertNotContains( classpath, new String[] { prefix + "tests.jar" } ); classpath = verifier.loadLines( "consumer-b/target/test.txt", "UTF-8" ); - assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); - assertNotContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); + assertContains( classpath, new String[] { prefix + "client.jar" } ); + assertNotContains( classpath, new String[] { prefix + "tests.jar" } ); classpath = verifier.loadLines( "consumer-c/target/compile.txt", "UTF-8" ); - assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); - assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); + assertContains( classpath, new String[] { prefix + "client.jar" } ); + assertContains( classpath, new String[] { prefix + "tests.jar" } ); classpath = verifier.loadLines( "consumer-c/target/runtime.txt", "UTF-8" ); - assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); - assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); + assertContains( classpath, new String[] { prefix + "client.jar" } ); + assertContains( classpath, new String[] { prefix + "tests.jar" } ); classpath = verifier.loadLines( "consumer-c/target/test.txt", "UTF-8" ); - assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-client.jar" } ); - assertContains( classpath, new String[] { "dependency-0.1-SNAPSHOT-tests.jar" } ); + assertContains( classpath, new String[] { prefix + "client.jar" } ); + assertContains( classpath, new String[] { prefix + "tests.jar" } ); } private void assertContains( List collection, String[] items ) diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4233ReactorResolutionForManuallyCreatedArtifactTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4233ReactorResolutionForManuallyCreatedArtifactTest.java index e1eb884aa..2a587b07c 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4233ReactorResolutionForManuallyCreatedArtifactTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4233ReactorResolutionForManuallyCreatedArtifactTest.java @@ -63,8 +63,7 @@ public void testit() verifier.verifyErrorFreeLog(); Properties props = verifier.loadProperties( "consumer/target/artifact.properties" ); - assertEquals( - new File( testDir.getCanonicalFile(), "producer/pom.xml" ), new File( + assertEquals( new File( testDir.getCanonicalFile(), "producer/pom.xml" ), new File( props.getProperty( "org.apache.maven.its.mng4233:producer:jar:1.0-SNAPSHOT" ) ).getCanonicalFile() ); }