From e2891667dda38857ce0b269c0fb097408cca2eea Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Tue, 16 Mar 2021 17:59:50 +0100 Subject: [PATCH 001/183] Bump version to 3.8.0-SNAPSHOT --- apache-maven/pom.xml | 2 +- maven-artifact/pom.xml | 2 +- maven-builder-support/pom.xml | 2 +- maven-compat/pom.xml | 2 +- maven-core/pom.xml | 2 +- maven-embedder/pom.xml | 2 +- maven-model-builder/pom.xml | 2 +- maven-model/pom.xml | 2 +- maven-plugin-api/pom.xml | 2 +- maven-repository-metadata/pom.xml | 2 +- maven-resolver-provider/pom.xml | 2 +- maven-settings-builder/pom.xml | 2 +- maven-settings/pom.xml | 2 +- maven-slf4j-provider/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index 7d85e7525202..6cf6a2c06a56 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.6.3 + 3.8.0-SNAPSHOT apache-maven diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml index ef112321174a..7984bf7337e8 100644 --- a/maven-artifact/pom.xml +++ b/maven-artifact/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.6.3 + 3.8.0-SNAPSHOT maven-artifact diff --git a/maven-builder-support/pom.xml b/maven-builder-support/pom.xml index ca20b8c5868d..dbc54fb2ee4f 100644 --- a/maven-builder-support/pom.xml +++ b/maven-builder-support/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.6.3 + 3.8.0-SNAPSHOT maven-builder-support diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml index 0fb684acd172..8492627a88b5 100644 --- a/maven-compat/pom.xml +++ b/maven-compat/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.6.3 + 3.8.0-SNAPSHOT maven-compat diff --git a/maven-core/pom.xml b/maven-core/pom.xml index 1f52e1b63bad..74543e2e4071 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.6.3 + 3.8.0-SNAPSHOT maven-core diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index 7af181714fa0..085373bcd4da 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.6.3 + 3.8.0-SNAPSHOT maven-embedder diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml index f03c59c3b6ae..b0eb11a91c4e 100644 --- a/maven-model-builder/pom.xml +++ b/maven-model-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.6.3 + 3.8.0-SNAPSHOT maven-model-builder diff --git a/maven-model/pom.xml b/maven-model/pom.xml index f9f015349e2c..5a48eacf7b69 100644 --- a/maven-model/pom.xml +++ b/maven-model/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.6.3 + 3.8.0-SNAPSHOT maven-model diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml index 8abe7430d673..d88c4f0f3ff3 100644 --- a/maven-plugin-api/pom.xml +++ b/maven-plugin-api/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.6.3 + 3.8.0-SNAPSHOT maven-plugin-api diff --git a/maven-repository-metadata/pom.xml b/maven-repository-metadata/pom.xml index 07a0a177c5a8..dd1146fa25a5 100644 --- a/maven-repository-metadata/pom.xml +++ b/maven-repository-metadata/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.6.3 + 3.8.0-SNAPSHOT maven-repository-metadata diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml index aad87452c748..33a605b9357e 100644 --- a/maven-resolver-provider/pom.xml +++ b/maven-resolver-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.6.3 + 3.8.0-SNAPSHOT maven-resolver-provider diff --git a/maven-settings-builder/pom.xml b/maven-settings-builder/pom.xml index 868d3447d4a9..e6018234ff30 100644 --- a/maven-settings-builder/pom.xml +++ b/maven-settings-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.6.3 + 3.8.0-SNAPSHOT maven-settings-builder diff --git a/maven-settings/pom.xml b/maven-settings/pom.xml index 4a33dbe3eea4..3730e6c2baba 100644 --- a/maven-settings/pom.xml +++ b/maven-settings/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.6.3 + 3.8.0-SNAPSHOT maven-settings diff --git a/maven-slf4j-provider/pom.xml b/maven-slf4j-provider/pom.xml index 604f8bbf7866..00ba5c9e4548 100644 --- a/maven-slf4j-provider/pom.xml +++ b/maven-slf4j-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.6.3 + 3.8.0-SNAPSHOT maven-slf4j-provider diff --git a/pom.xml b/pom.xml index c770f0d33c5c..c890214b1bb3 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven - 3.6.3 + 3.8.0-SNAPSHOT pom Apache Maven From 02bc2a69fc8d1a14ff35645d9478b686a07cf29f Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 28 Feb 2021 22:18:23 +0100 Subject: [PATCH 002/183] Add versionlessMavenDist profile --- apache-maven/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index 6cf6a2c06a56..485923df8314 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -319,6 +319,12 @@ under the License. + + + versionlessMavenDist + + ${project.artifactId} + From a96fd11b1fb9724d563cfde60288d17ddd22bf7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sat, 13 Mar 2021 21:46:48 +0100 Subject: [PATCH 003/183] [MNG-3220] fix doc: dependencyManagement import require scope import --- maven-model-builder/src/site/apt/index.apt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-model-builder/src/site/apt/index.apt b/maven-model-builder/src/site/apt/index.apt index e18ad9deb331..f7dd1d2e038c 100644 --- a/maven-model-builder/src/site/apt/index.apt +++ b/maven-model-builder/src/site/apt/index.apt @@ -81,7 +81,7 @@ Maven Model Builder with its <<>> implementation in maven-core ({{{./maven-core/xref/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.html}source}}) - ** dependency management import (for dependencies of type <<>> in the <<<\>>> section) + ** dependency management import (for dependencies of type <<>> and scope <<>> in the <<<\>>> section) ** dependency management injection: <<>> ({{{./apidocs/org/apache/maven/model/management/DependencyManagementInjector.html}javadoc}}), with its <<>> implementation From 09f77da9b0c39848fe763bdd4a392151eec0d8c3 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Tue, 16 Mar 2021 18:22:04 +0100 Subject: [PATCH 004/183] [MNG-7119] Upgrade Maven Wagon to 3.4.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c890214b1bb3..f94b73ab29ba 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ under the License. 3.2.1 4.2.1 0.3.4 - 3.3.4 + 3.4.3 1.12.1 1.4 1.7 From e5f6634e17362387282b3867c9b23d4b54fea871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 14 Mar 2021 20:52:42 +0100 Subject: [PATCH 005/183] use Maven Resolver 1.6.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f94b73ab29ba..4168c58bafbf 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ under the License. 1.7 1.11 1.3 - 1.4.1 + 1.6.2 1.7.29 2.2.1 1.7.4 From fa79cb22e456cc65522b5bab8c4240fe08c5775f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sat, 13 Mar 2021 18:40:48 +0100 Subject: [PATCH 006/183] [MNG-7116] add support for mirrorOf external:http:* --- .../repository/DefaultMirrorSelector.java | 51 ++++++++++++++++--- .../maven/bridge/MavenRepositorySystem.java | 48 +++++++++++++++-- 2 files changed, 89 insertions(+), 10 deletions(-) diff --git a/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java b/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java index 6fa2c554a7a6..adb562a6d091 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java @@ -41,6 +41,8 @@ public class DefaultMirrorSelector private static final String EXTERNAL_WILDCARD = "external:*"; + private static final String EXTERNAL_HTTP_WILDCARD = "external:http:*"; + public Mirror getMirror( ArtifactRepository repository, List mirrors ) { String repoId = repository.getId(); @@ -68,9 +70,14 @@ public Mirror getMirror( ArtifactRepository repository, List mirrors ) } /** - * This method checks if the pattern matches the originalRepository. Valid patterns: * = - * everything external:* = everything not on the localhost and not file based. repo,repo1 = repo - * or repo1 *,!repo1 = everything except repo1 + * This method checks if the pattern matches the originalRepository. Valid patterns: + *
    + *
  • {@code *} = everything,
  • + *
  • {@code external:*} = everything not on the localhost and not file based,
  • + *
  • {@code external:http:*} = any repository not on the localhost using HTTP,
  • + *
  • {@code repo,repo1} = {@code repo} or {@code repo1},
  • + *
  • {@code *,!repo1} = everything except {@code repo1}.
  • + *
* * @param originalRepository to compare for a match. * @param pattern used for match. Currently only '*' is supported. @@ -115,6 +122,12 @@ else if ( EXTERNAL_WILDCARD.equals( repo ) && isExternalRepo( originalRepository result = true; // don't stop processing in case a future segment explicitly excludes this repo } + // check for external:http:* + else if ( EXTERNAL_HTTP_WILDCARD.equals( repo ) && isExternalHttpRepo( originalRepository ) ) + { + result = true; + // don't stop processing in case a future segment explicitly excludes this repo + } else if ( WILDCARD.equals( repo ) ) { result = true; @@ -136,8 +149,34 @@ static boolean isExternalRepo( ArtifactRepository originalRepository ) try { URL url = new URL( originalRepository.getUrl() ); - return !( url.getHost().equals( "localhost" ) || url.getHost().equals( "127.0.0.1" ) - || url.getProtocol().equals( "file" ) ); + return !( isLocal( url.getHost() ) || url.getProtocol().equals( "file" ) ); + } + catch ( MalformedURLException e ) + { + // bad url just skip it here. It should have been validated already, but the wagon lookup will deal with it + return false; + } + } + + private static boolean isLocal( String host ) + { + return "localhost".equals( host ) || "127.0.0.1".equals( host ); + } + + /** + * Checks the URL to see if this repository refers to a non-localhost repository using HTTP. + * + * @param originalRepository + * @return true if external. + */ + static boolean isExternalHttpRepo( ArtifactRepository originalRepository ) + { + try + { + URL url = new URL( originalRepository.getUrl() ); + return ( "http".equalsIgnoreCase( url.getProtocol() ) || "dav".equalsIgnoreCase( url.getProtocol() ) + || "dav:http".equalsIgnoreCase( url.getProtocol() ) + || "dav+http".equalsIgnoreCase( url.getProtocol() ) ) && !isLocal( url.getHost() ); } catch ( MalformedURLException e ) { @@ -146,7 +185,7 @@ static boolean isExternalRepo( ArtifactRepository originalRepository ) } } - static boolean matchesLayout( ArtifactRepository repository, Mirror mirror ) + static boolean matchesLayout( ArtifactRepository repository, Mirror mirror ) { return matchesLayout( RepositoryUtils.getLayout( repository ), mirror.getMirrorOfLayouts() ); } diff --git a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java index 730b428221d0..90bfdcdce288 100644 --- a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java +++ b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java @@ -710,6 +710,8 @@ public ArtifactRepository createLocalRepository( MavenExecutionRequest request, private static final String EXTERNAL_WILDCARD = "external:*"; + private static final String EXTERNAL_HTTP_WILDCARD = "external:http:*"; + public static Mirror getMirror( ArtifactRepository repository, List mirrors ) { String repoId = repository.getId(); @@ -737,8 +739,14 @@ public static Mirror getMirror( ArtifactRepository repository, List mirr } /** - * This method checks if the pattern matches the originalRepository. Valid patterns: * = everything external:* = - * everything not on the localhost and not file based. repo,repo1 = repo or repo1 *,!repo1 = everything except repo1 + * This method checks if the pattern matches the originalRepository. Valid patterns: + *
    + *
  • {@code *} = everything,
  • + *
  • {@code external:*} = everything not on the localhost and not file based,
  • + *
  • {@code external:http:*} = any repository not on the localhost using HTTP,
  • + *
  • {@code repo,repo1} = {@code repo} or {@code repo1},
  • + *
  • {@code *,!repo1} = everything except {@code repo1}.
  • + *
* * @param originalRepository to compare for a match. * @param pattern used for match. Currently only '*' is supported. @@ -782,6 +790,12 @@ else if ( EXTERNAL_WILDCARD.equals( repo ) && isExternalRepo( originalRepository result = true; // don't stop processing in case a future segment explicitly excludes this repo } + // check for external:http:* + else if ( EXTERNAL_HTTP_WILDCARD.equals( repo ) && isExternalHttpRepo( originalRepository ) ) + { + result = true; + // don't stop processing in case a future segment explicitly excludes this repo + } else if ( WILDCARD.equals( repo ) ) { result = true; @@ -803,8 +817,34 @@ static boolean isExternalRepo( ArtifactRepository originalRepository ) try { URL url = new URL( originalRepository.getUrl() ); - return !( url.getHost().equals( "localhost" ) || url.getHost().equals( "127.0.0.1" ) - || url.getProtocol().equals( "file" ) ); + return !( isLocal( url.getHost() ) || url.getProtocol().equals( "file" ) ); + } + catch ( MalformedURLException e ) + { + // bad url just skip it here. It should have been validated already, but the wagon lookup will deal with it + return false; + } + } + + private static boolean isLocal( String host ) + { + return "localhost".equals( host ) || "127.0.0.1".equals( host ); + } + + /** + * Checks the URL to see if this repository refers to a non-localhost repository using HTTP. + * + * @param originalRepository + * @return true if external. + */ + static boolean isExternalHttpRepo( ArtifactRepository originalRepository ) + { + try + { + URL url = new URL( originalRepository.getUrl() ); + return ( "http".equalsIgnoreCase( url.getProtocol() ) || "dav".equalsIgnoreCase( url.getProtocol() ) + || "dav:http".equalsIgnoreCase( url.getProtocol() ) + || "dav+http".equalsIgnoreCase( url.getProtocol() ) ) && !isLocal( url.getHost() ); } catch ( MalformedURLException e ) { From 899465aeec03753ea91e15a79579eab76369c016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sat, 13 Mar 2021 18:00:59 +0100 Subject: [PATCH 007/183] [MNG-7117] add support for blocked mirror --- .../DefaultRepositorySystemSessionFactory.java | 4 ++-- maven-settings/pom.xml | 2 +- maven-settings/src/main/mdo/settings.mdo | 13 +++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java index 248a3b6dd120..bda467c45e06 100644 --- a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java +++ b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java @@ -177,8 +177,8 @@ else if ( request.isUpdateSnapshots() ) DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector(); for ( Mirror mirror : request.getMirrors() ) { - mirrorSelector.add( mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(), - mirror.getMirrorOfLayouts() ); + mirrorSelector.add( mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.isBlocked(), + mirror.getMirrorOf(), mirror.getMirrorOfLayouts() ); } session.setMirrorSelector( mirrorSelector ); diff --git a/maven-settings/pom.xml b/maven-settings/pom.xml index 3730e6c2baba..70866e54ca79 100644 --- a/maven-settings/pom.xml +++ b/maven-settings/pom.xml @@ -46,7 +46,7 @@ under the License. org.codehaus.modello modello-maven-plugin - 1.1.0 + 1.2.0 src/main/mdo/settings.mdo diff --git a/maven-settings/src/main/mdo/settings.mdo b/maven-settings/src/main/mdo/settings.mdo index 333d8bd7ac86..b0498df43a42 100644 --- a/maven-settings/src/main/mdo/settings.mdo +++ b/maven-settings/src/main/mdo/settings.mdo @@ -633,6 +633,15 @@ 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. + + @@ -648,6 +657,10 @@ sb.append( ",mirrorOf=" ).append( mirrorOf ); sb.append( ",url=" ).append( this.url ); sb.append( ",name=" ).append( this.name ); + if ( isBlocked() ) + { + sb.append( ",blocked" ); + } sb.append( "]" ); return sb.toString(); } From 907d53ad3264718f66ff15e1363d76b07dd0c05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sat, 13 Mar 2021 19:03:43 +0100 Subject: [PATCH 008/183] [MNG-7118] block HTTP repositories by default --- apache-maven/src/conf/settings.xml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apache-maven/src/conf/settings.xml b/apache-maven/src/conf/settings.xml index e27c579cf6db..99d8b1a4b01d 100644 --- a/apache-maven/src/conf/settings.xml +++ b/apache-maven/src/conf/settings.xml @@ -43,9 +43,9 @@ under the License. | values (values used when the setting is not specified) are provided. | |--> - + xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd"> + + maven-default-http-blocker + external:http:* + Pseudo repository to mirror external repositories initially using HTTP. + http://0.0.0.0/ + true + - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.codehaus.mojo - buildnumber-maven-plugin - [1.2,) - - create-timestamp - - - - - - - - - - @@ -234,16 +209,6 @@ under the License. org.codehaus.mojo buildnumber-maven-plugin - - create-noncanonicalrev - - create-timestamp - - - 'NON-CANONICAL_'yyyy-MM-dd'T'HH:mm:ssXXX_'${user.name}' - nonCanonicalRevision - - create-buildnumber @@ -252,7 +217,7 @@ under the License. false false - ${nonCanonicalRevision} + NON_CANONICAL From 8f58b85eaf724a98d1332cfbb3e0a3de58c9587b Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Mon, 4 Jan 2021 20:07:46 +0100 Subject: [PATCH 045/183] [MNG-7064] Use HTTPS for schema location in global settings.xml --- apache-maven/src/conf/settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apache-maven/src/conf/settings.xml b/apache-maven/src/conf/settings.xml index 99d8b1a4b01d..9a80350ff042 100644 --- a/apache-maven/src/conf/settings.xml +++ b/apache-maven/src/conf/settings.xml @@ -45,7 +45,7 @@ under the License. |--> + xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd"> - - org.apache.maven.plugins - maven-source-plugin - 3.2.1 - - - org.apache.maven.plugins - maven-jar-plugin - 3.2.0 - - - org.apache.maven.plugins - maven-assembly-plugin - 3.2.0 - org.codehaus.plexus plexus-component-metadata From 2a2392f15e3cbdc7a7c8a453a4cbed314947a036 Mon Sep 17 00:00:00 2001 From: huangkaifeng Date: Mon, 2 Mar 2020 22:10:50 +0800 Subject: [PATCH 049/183] [MNG-6873] Align JUnit version to 4.13 Closes #331 --- .../test/java/org/apache/maven/project/PomConstructionTest.java | 2 +- .../lifecycle-executor/project-with-inheritance/pom.xml | 2 +- .../projects/plugin-manager/project-with-inheritance/pom.xml | 2 +- .../resources-project-builder/dependency-inheritance/pom.xml | 2 +- .../dependency-inheritance/sub/pom.xml | 2 +- .../src/test/resources-project-builder/micromailer/pom.xml | 2 +- .../src/test/resources/org/apache/maven/lifecycle/pom.xml | 2 +- maven-embedder/src/examples/simple-project/pom.xml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java index 9e16ebc59487..e44e60f023b7 100644 --- a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java @@ -975,7 +975,7 @@ public void testDependencyInheritance() { PomTestWrapper pom = buildPom( "dependency-inheritance/sub" ); assertEquals( 1, ( (List) pom.getValue( "dependencies" ) ).size() ); - assertEquals( "4.4", pom.getValue( "dependencies[1]/version" ) ); + assertEquals( "4.13", pom.getValue( "dependencies[1]/version" ) ); } /** MNG-4034 */ diff --git a/maven-core/src/test/projects/lifecycle-executor/project-with-inheritance/pom.xml b/maven-core/src/test/projects/lifecycle-executor/project-with-inheritance/pom.xml index c19061ad9661..c9a894d9059b 100644 --- a/maven-core/src/test/projects/lifecycle-executor/project-with-inheritance/pom.xml +++ b/maven-core/src/test/projects/lifecycle-executor/project-with-inheritance/pom.xml @@ -53,7 +53,7 @@ under the License. --> 1.0-alpha-9 1.2_Java1.3 - 3.8.1 + 4.13 1.0-beta-3.0.7 1.0-alpha-6 1.1 diff --git a/maven-core/src/test/projects/plugin-manager/project-with-inheritance/pom.xml b/maven-core/src/test/projects/plugin-manager/project-with-inheritance/pom.xml index c19061ad9661..c9a894d9059b 100644 --- a/maven-core/src/test/projects/plugin-manager/project-with-inheritance/pom.xml +++ b/maven-core/src/test/projects/plugin-manager/project-with-inheritance/pom.xml @@ -53,7 +53,7 @@ under the License. --> 1.0-alpha-9 1.2_Java1.3 - 3.8.1 + 4.13 1.0-beta-3.0.7 1.0-alpha-6 1.1 diff --git a/maven-core/src/test/resources-project-builder/dependency-inheritance/pom.xml b/maven-core/src/test/resources-project-builder/dependency-inheritance/pom.xml index 736b793c8e87..8f9c028e3823 100644 --- a/maven-core/src/test/resources-project-builder/dependency-inheritance/pom.xml +++ b/maven-core/src/test/resources-project-builder/dependency-inheritance/pom.xml @@ -33,7 +33,7 @@ under the License. pom - 3.8.1 + 4.13 diff --git a/maven-core/src/test/resources-project-builder/dependency-inheritance/sub/pom.xml b/maven-core/src/test/resources-project-builder/dependency-inheritance/sub/pom.xml index aaf8e8e5ab58..832f49e321ff 100644 --- a/maven-core/src/test/resources-project-builder/dependency-inheritance/sub/pom.xml +++ b/maven-core/src/test/resources-project-builder/dependency-inheritance/sub/pom.xml @@ -25,7 +25,7 @@ junit junit - 4.4 + 4.13 test diff --git a/maven-core/src/test/resources-project-builder/micromailer/pom.xml b/maven-core/src/test/resources-project-builder/micromailer/pom.xml index 44f1cd9f22d0..0e875a7a1d4c 100644 --- a/maven-core/src/test/resources-project-builder/micromailer/pom.xml +++ b/maven-core/src/test/resources-project-builder/micromailer/pom.xml @@ -97,7 +97,7 @@ junit junit - 3.8.2 + 4.13 jar test diff --git a/maven-core/src/test/resources/org/apache/maven/lifecycle/pom.xml b/maven-core/src/test/resources/org/apache/maven/lifecycle/pom.xml index cd0a3d81712e..531e5510c5a7 100644 --- a/maven-core/src/test/resources/org/apache/maven/lifecycle/pom.xml +++ b/maven-core/src/test/resources/org/apache/maven/lifecycle/pom.xml @@ -53,7 +53,7 @@ under the License. --> 1.0-alpha-9 1.2_Java1.3 - 3.8.1 + 4.13 1.0-beta-3.0.7-SNAPSHOT 1.0-alpha-6 1.1 diff --git a/maven-embedder/src/examples/simple-project/pom.xml b/maven-embedder/src/examples/simple-project/pom.xml index 62de37aac1be..843b38e32b52 100644 --- a/maven-embedder/src/examples/simple-project/pom.xml +++ b/maven-embedder/src/examples/simple-project/pom.xml @@ -29,7 +29,7 @@ under the License. junit junit - 3.8.1 + 4.13 test From 9ae1d95a581bbf07bab72aff7aa26b096a267615 Mon Sep 17 00:00:00 2001 From: Artem Krosheninnikov Date: Thu, 9 Jan 2020 11:12:22 +0300 Subject: [PATCH 050/183] [MNG-6844] Use StandardCharsets and remove outdated @SuppressWarnings This closes #312 --- .../org/apache/maven/settings/GlobalSettingsTest.java | 3 ++- .../java/org/apache/maven/building/StringSource.java | 3 ++- .../inheritance/DefaultModelInheritanceAssembler.java | 3 --- .../artifact/AbstractArtifactComponentTestCase.java | 3 ++- .../apache/maven/repository/legacy/StringWagon.java | 10 ++-------- .../maven/artifact/handler/ArtifactHandlerTest.java | 1 - .../internal/stub/DefaultLifecyclesStub.java | 1 - .../maven/project/ExtensionDescriptorBuilderTest.java | 11 ++--------- .../main/java/org/apache/maven/cli/CLIManager.java | 2 +- .../interpolation/ProblemDetectingValueSource.java | 1 - 10 files changed, 11 insertions(+), 27 deletions(-) diff --git a/apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java b/apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java index 0d0543e2899d..257350c90510 100644 --- a/apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java +++ b/apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java @@ -26,6 +26,7 @@ import java.io.FileInputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.nio.charset.StandardCharsets; /** * Tests that the global settings.xml shipped with the distribution is in good state. @@ -44,7 +45,7 @@ public void testValidGlobalSettings() File globalSettingsFile = new File( basedir, "src/conf/settings.xml" ); assertTrue( globalSettingsFile.getAbsolutePath(), globalSettingsFile.isFile() ); - try ( Reader reader = new InputStreamReader( new FileInputStream( globalSettingsFile ), "UTF-8" ) ) + try ( Reader reader = new InputStreamReader( new FileInputStream( globalSettingsFile ), StandardCharsets.UTF_8) ) { new SettingsXpp3Reader().read( reader ); } diff --git a/maven-builder-support/src/main/java/org/apache/maven/building/StringSource.java b/maven-builder-support/src/main/java/org/apache/maven/building/StringSource.java index f9d87c0ba649..7705804aa4b2 100644 --- a/maven-builder-support/src/main/java/org/apache/maven/building/StringSource.java +++ b/maven-builder-support/src/main/java/org/apache/maven/building/StringSource.java @@ -22,6 +22,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; /** * Wraps an ordinary {@link CharSequence} as a source. @@ -62,7 +63,7 @@ public StringSource( CharSequence content, String location ) public InputStream getInputStream() throws IOException { - return new ByteArrayInputStream( content.getBytes( "UTF-8" ) ); + return new ByteArrayInputStream( content.getBytes( StandardCharsets.UTF_8 ) ); } @Override diff --git a/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java b/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java index 7c3ca79ae309..2071cecc740e 100644 --- a/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java +++ b/maven-compat/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java @@ -55,7 +55,6 @@ public class DefaultModelInheritanceAssembler implements ModelInheritanceAssembler { // TODO Remove this! - @SuppressWarnings( "unchecked" ) public void assembleBuildInheritance( Build childBuild, Build parentBuild, boolean handleAsInheritance ) { // The build has been set but we want to step in here and fill in @@ -307,7 +306,6 @@ private void assembleModelInheritance( Model child, Model parent, String childPa } // TODO Remove this! - @SuppressWarnings( "unchecked" ) private void assembleDependencyManagementInheritance( Model child, Model parent ) { DependencyManagement parentDepMgmt = parent.getDependencyManagement(); @@ -527,7 +525,6 @@ else if ( handleAsInheritance && ( parentInherited == null ) ) } // TODO Remove this! - @SuppressWarnings( "unchecked" ) private void assembleDependencyInheritance( Model child, Model parent ) { Map depsMap = new LinkedHashMap<>(); diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java b/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java index 2ce37940791a..dbd6e8ffd758 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java @@ -59,6 +59,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -293,7 +294,7 @@ protected void createArtifact( Artifact artifact, ArtifactRepository repository { artifactFile.getParentFile().mkdirs(); } - try ( Writer writer = new OutputStreamWriter( new FileOutputStream( artifactFile ), "ISO-8859-1" ) ) + try ( Writer writer = new OutputStreamWriter( new FileOutputStream( artifactFile ), StandardCharsets.ISO_8859_1) ) { writer.write( artifact.getId() ); } diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java index 944cce62d71f..3a72b98e9a0c 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java @@ -22,6 +22,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -72,14 +73,7 @@ public void fillInputData( InputData inputData ) resource.setContentLength( content.length() ); resource.setLastModified( System.currentTimeMillis() ); - try - { - inputData.setInputStream( new ByteArrayInputStream( content.getBytes( "UTF-8" ) ) ); - } - catch ( UnsupportedEncodingException e ) - { - throw new Error( "broken JVM", e ); - } + inputData.setInputStream( new ByteArrayInputStream( content.getBytes( StandardCharsets.UTF_8 ) ) ); } else { diff --git a/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java b/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java index 69f59fdb364e..2803d8d80a29 100644 --- a/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java +++ b/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java @@ -33,7 +33,6 @@ public void testAptConsistency() { File apt = getTestFile( "src/site/apt/artifact-handlers.apt" ); - @SuppressWarnings( "unchecked" ) List lines = FileUtils.loadFile( apt ); for ( String line : lines ) diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/DefaultLifecyclesStub.java b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/DefaultLifecyclesStub.java index 1dc2b6b0a633..a1a95322941b 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/DefaultLifecyclesStub.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/DefaultLifecyclesStub.java @@ -47,7 +47,6 @@ public static DefaultLifecycles createDefaultLifecycles() List stubSiteCycle = Arrays.asList( PRE_SITE.getPhase(), SITE.getPhase(), POST_SITE.getPhase(), SITE_DEPLOY.getPhase() ); - @SuppressWarnings( "unchecked" ) Iterator> lcs = Arrays.asList( stubDefaultCycle, stubCleanCycle, stubSiteCycle ).iterator(); Map lifeCycles = new HashMap<>(); diff --git a/maven-core/src/test/java/org/apache/maven/project/ExtensionDescriptorBuilderTest.java b/maven-core/src/test/java/org/apache/maven/project/ExtensionDescriptorBuilderTest.java index 7a5e55d1eb1b..5ac8f611cf92 100644 --- a/maven-core/src/test/java/org/apache/maven/project/ExtensionDescriptorBuilderTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/ExtensionDescriptorBuilderTest.java @@ -25,7 +25,7 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import junit.framework.TestCase; @@ -61,14 +61,7 @@ protected void tearDown() private InputStream toStream( String xml ) { - try - { - return new ByteArrayInputStream( xml.getBytes( "UTF-8" ) ); - } - catch ( UnsupportedEncodingException e ) - { - throw new IllegalStateException( e ); - } + return new ByteArrayInputStream( xml.getBytes( StandardCharsets.UTF_8 ) ); } public void testEmptyDescriptor() diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java index a0d54d3bf944..edd60c91c0bb 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java @@ -107,7 +107,7 @@ public class CLIManager protected Options options; - @SuppressWarnings( { "static-access", "checkstyle:linelength" } ) + @SuppressWarnings( "checkstyle:linelength" ) public CLIManager() { options = new Options(); diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ProblemDetectingValueSource.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ProblemDetectingValueSource.java index 4ed98d035dd3..0b29f20e71cc 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ProblemDetectingValueSource.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ProblemDetectingValueSource.java @@ -72,7 +72,6 @@ public Object getValue( String expression ) } @Override - @SuppressWarnings( "unchecked" ) public List getFeedback() { return valueSource.getFeedback(); From 8b693cc992ff4a5947babecd222fbebf7516e677 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 2 Jul 2021 17:50:44 +0200 Subject: [PATCH 051/183] Document hacks as such --- .../org/apache/maven/project/artifact/MavenMetadataSource.java | 1 + .../repository/internal/DefaultArtifactDescriptorReader.java | 1 + 2 files changed, 2 insertions(+) diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java index 1c40af8b9869..ac55fb93eb4d 100644 --- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java +++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java @@ -180,6 +180,7 @@ public ResolutionGroup retrieve( MetadataResolutionRequest request ) Artifact relocatedArtifact = null; + // TODO hack: don't rebuild model if it was already loaded during reactor resolution final WorkspaceReader workspace = legacySupport.getRepositorySession().getWorkspaceReader(); Model model = null; if ( workspace instanceof MavenWorkspaceReader ) diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java index 586c83e271e9..c2ba0a3d729a 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java @@ -257,6 +257,7 @@ private Model loadPom( RepositorySystemSession session, ArtifactDescriptorReques Model model; + // TODO hack: don't rebuild model if it was already loaded during reactor resolution final WorkspaceReader workspace = session.getWorkspaceReader(); if ( workspace instanceof MavenWorkspaceReader ) { From 7358b084b120e28f42b5ae37b1c298ba123e2a5e Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 3 Jul 2021 11:12:47 +0200 Subject: [PATCH 052/183] Add new ignores --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f79c9285cd4c..f85dc5684299 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ out/ /bootstrap /dependencies.xml .java-version +.factorypath +.checkstyle From 7b355f72235c0bd26b872601b38a493ed1cc518b Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 3 Jul 2021 18:28:31 +0200 Subject: [PATCH 053/183] [MNG-7180] Make --color option behave more like BSD/GNU grep's --color option --- .../src/main/java/org/apache/maven/cli/CLIManager.java | 2 +- .../src/main/java/org/apache/maven/cli/MavenCli.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java index edd60c91c0bb..2ad542457b31 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java @@ -152,7 +152,7 @@ public CLIManager() options.addOption( Option.builder( "up" ).longOpt( "update-plugins" ).desc( "Ineffective, only kept for backward compatibility" ).build() ); options.addOption( Option.builder( "npu" ).longOpt( "no-plugin-updates" ).desc( "Ineffective, only kept for backward compatibility" ).build() ); - options.addOption( Option.builder().longOpt( COLOR ).hasArg().desc( "Defines the color mode of the output. Available options are auto/always/never" ).build() ); + options.addOption( Option.builder().longOpt( COLOR ).hasArg().optionalArg( true ).desc( "Defines the color mode of the output. Supported are 'auto', 'always', 'never'." ).build() ); } public CommandLine parse( String[] args ) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index e8e2f7401b7c..feed90561d35 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -506,18 +506,18 @@ else if ( cliRequest.quiet ) // LOG COLOR String styleColor = cliRequest.getUserProperties().getProperty( STYLE_COLOR_PROPERTY, "auto" ); styleColor = cliRequest.commandLine.getOptionValue( COLOR, styleColor ); - if ( "always".equals( styleColor ) ) + if ( "always".equals( styleColor ) || "yes".equals( styleColor ) || "force".equals( styleColor ) ) { MessageUtils.setColorEnabled( true ); } - else if ( "never".equals( styleColor ) ) + else if ( "never".equals( styleColor ) || "no".equals( styleColor ) || "none".equals( styleColor ) ) { MessageUtils.setColorEnabled( false ); } - else if ( !"auto".equals( styleColor ) ) + else if ( !"auto".equals( styleColor ) && !"tty".equals( styleColor ) && !"if-tty".equals( styleColor ) ) { - throw new IllegalArgumentException( "Invalid color configuration option [" + styleColor - + "]. Supported values are (auto|always|never)." ); + throw new IllegalArgumentException( "Invalid color configuration value '" + styleColor + + "'. Supported are 'auto', 'always', 'never'." ); } else if ( cliRequest.commandLine.hasOption( CLIManager.BATCH_MODE ) || cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) ) From 7a8acdd8e66de81b4f7f918905976191837bf147 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 3 Jul 2021 19:17:19 +0200 Subject: [PATCH 054/183] [MNG-7181] Make --version support -q --- .../java/org/apache/maven/cli/CLIReportingUtils.java | 7 +++++++ .../src/main/java/org/apache/maven/cli/MavenCli.java | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java index 97a2db65bde1..57be1963295f 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java @@ -75,6 +75,13 @@ public static String showVersion() return version.toString(); } + public static String showVersionMinimal() + { + Properties properties = getBuildProperties(); + String version = reduce( properties.getProperty( BUILD_VERSION_PROPERTY ) ); + return ( version != null ? version : "" ); + } + /** * Create a human readable string containing the Maven version, buildnumber, and time of build * diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index feed90561d35..fbcb05f91371 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -433,7 +433,14 @@ private void informativeCommands( CliRequest cliRequest ) throws ExitException if ( cliRequest.commandLine.hasOption( CLIManager.VERSION ) ) { - System.out.println( CLIReportingUtils.showVersion() ); + if ( cliRequest.commandLine.hasOption( CLIManager.QUIET ) ) + { + System.out.println( CLIReportingUtils.showVersionMinimal() ); + } + else + { + System.out.println( CLIReportingUtils.showVersion() ); + } throw new ExitException( 0 ); } } From 0635e92665cbd247a4144c328321b0e9f058398e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 11 Jul 2021 19:00:24 +0200 Subject: [PATCH 055/183] [MNG-7184] document .mavenrc/mavenrc_pre.bat|cmd and MAVEN_SKIP_RC --- apache-maven/src/site/apt/index.apt.vm | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 apache-maven/src/site/apt/index.apt.vm diff --git a/apache-maven/src/site/apt/index.apt.vm b/apache-maven/src/site/apt/index.apt.vm new file mode 100644 index 000000000000..994aeab1d9eb --- /dev/null +++ b/apache-maven/src/site/apt/index.apt.vm @@ -0,0 +1,40 @@ +~~ 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. + + ----- + ${project.name} + ----- + Hervé Boutemy + ----- + 2021-07-11 + ----- + +${project.name} + + ${project.description} + +* References + + * <<>> invocation can be customised through: + + * <<>> and <<<~/.mavenrc>>> scripts on Unix, + + * <<<~\mavenrc_pre.bat>>> and <<<~\mavenrc_pre.cmd>>> scripts on Windows, + + [] + + and these scripts calls can be disabled by setting <<>> environment variable. From 842e7c88da3b310031d58325874c4b6b9a182c04 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Mon, 12 Jul 2021 19:36:38 +0200 Subject: [PATCH 056/183] [MNG-7186] Upgrade Guice to 4.2.2 --- maven-embedder/pom.xml | 4 ++++ pom.xml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index cf065031a7c2..8e08be47322a 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -104,6 +104,10 @@ under the License. org.codehaus.mojo animal-sniffer-annotations + + org.checkerframework + checker-qual + diff --git a/pom.xml b/pom.xml index 84abe1ad615a..dbe5eb2de604 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ under the License. 2.1.0 1.25 3.2.1 - 4.2.1 + 4.2.2 0.3.4 3.4.3 1.12.1 From a27b4ee595ee48833fa659ee30ff463f26c4a50d Mon Sep 17 00:00:00 2001 From: Marc Bruggmann Date: Thu, 10 Sep 2020 15:21:55 +0200 Subject: [PATCH 057/183] [MNG-6987] Reorder groupId before artifactId when writing an exclusion using maven-model In most other places, we order the groupId before the artifactId. Exclusion was the odd one out, so I changed it to be in line with the others. This closes #375 --- maven-model/src/main/mdo/maven.mdo | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/maven-model/src/main/mdo/maven.mdo b/maven-model/src/main/mdo/maven.mdo index 7f439faa9f7d..61d9ceb6d5fe 100644 --- a/maven-model/src/main/mdo/maven.mdo +++ b/maven-model/src/main/mdo/maven.mdo @@ -1191,16 +1191,16 @@ - artifactId + groupId 4.0.0+ - The artifact ID of the project to exclude. + The group ID of the project to exclude. String true - groupId + artifactId 4.0.0+ - The group ID of the project to exclude. + The artifact ID of the project to exclude. String true From 5d6bb35b048d9d430c38cdf16f53b850a9ca9e4e Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sat, 7 Dec 2019 10:28:19 +0100 Subject: [PATCH 058/183] [MNG-6810] - Remove profiles in maven-model --- maven-model/pom.xml | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/maven-model/pom.xml b/maven-model/pom.xml index 122e0b9b8b95..cd9a63940231 100644 --- a/maven-model/pom.xml +++ b/maven-model/pom.xml @@ -82,46 +82,4 @@ under the License. - - - all-models - - - - org.codehaus.modello - modello-maven-plugin - - - v3 - - java - xpp3-writer - xpp3-reader - xsd - - - 3.0.0 - true - - - - - - maven-jar-plugin - - - package - - jar - - - all - - - - - - - - From 5060349e676f2133219950f0d670997dacfbad69 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sat, 7 Dec 2019 15:18:46 +0100 Subject: [PATCH 059/183] [MNG-6811] - Remove unnecessary filtering configuration --- maven-embedder/pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index 8e08be47322a..2edf4171d63b 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -174,12 +174,6 @@ under the License. - - - src/main/resources - true - - From f32c3dba9495e3b7d4a73de6d303ae2eedb769f5 Mon Sep 17 00:00:00 2001 From: Romain Manni-Bucau Date: Thu, 6 Sep 2018 11:08:14 +0200 Subject: [PATCH 060/183] [MNG-6471] Parallel builder should use the module name as thread name This closes #177 --- .../multithreaded/MultiThreadedBuilder.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java index 94d10af4b44c..2688a6b4357c 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java @@ -186,12 +186,23 @@ private Callable createBuildCallable( final MavenSession rootSes { public ProjectSegment call() { - // muxer.associateThreadWithProjectSegment( projectBuild ); - lifecycleModuleBuilder.buildProject( projectBuild.getSession(), rootSession, reactorContext, - projectBuild.getProject(), taskSegment ); - // muxer.setThisModuleComplete( projectBuild ); + final Thread currentThread = Thread.currentThread(); + final String originalThreadName = currentThread.getName(); + currentThread.setName( "mvn-builder-" + projectBuild.getProject().getId() ); - return projectBuild; + try + { + // muxer.associateThreadWithProjectSegment( projectBuild ); + lifecycleModuleBuilder.buildProject( projectBuild.getSession(), rootSession, reactorContext, + projectBuild.getProject(), taskSegment ); + // muxer.setThisModuleComplete( projectBuild ); + + return projectBuild; + } + finally + { + currentThread.setName( originalThreadName ); + } } }; } From a3907fcb2b541d80852611b68494965f10b828f2 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 11 Oct 2020 20:27:49 +0200 Subject: [PATCH 061/183] [MNG-6754] Set the same timestamp in multi module builds Reuse MavenExecutionRequest#getStartTime() throughout for snapshot versions, last updated fields in metadata consistently for local and remote repositories for the entire reactor and its modules. This closes #381 --- .../installer/DefaultArtifactInstaller.java | 1 + .../transform/ReleaseArtifactTransformation.java | 1 + .../transform/SnapshotTransformation.java | 1 + .../metadata/AbstractRepositoryMetadata.java | 1 - .../DefaultRepositorySystemSessionFactory.java | 1 + .../internal/LocalSnapshotMetadata.java | 15 ++++++++------- .../internal/LocalSnapshotMetadataGenerator.java | 7 ++++++- .../maven/repository/internal/MavenMetadata.java | 8 ++++++-- .../internal/MavenSnapshotMetadata.java | 5 +++-- .../internal/RemoteSnapshotMetadata.java | 14 +++++++------- .../internal/RemoteSnapshotMetadataGenerator.java | 9 +++++++-- .../repository/internal/VersionsMetadata.java | 13 +++++++------ .../internal/VersionsMetadataGenerator.java | 7 ++++++- .../internal/RemoteSnapshotMetadataTest.java | 2 +- 14 files changed, 55 insertions(+), 30 deletions(-) diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java b/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java index a2529757c1cc..5deee382f948 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java @@ -123,6 +123,7 @@ else if ( metadata instanceof SnapshotArtifactRepositoryMetadata } Versioning versioning = new Versioning(); + // TODO Should this be changed for MNG-6754 too? versioning.updateTimestamp(); versioning.addVersion( artifact.getBaseVersion() ); if ( artifact.isRelease() ) diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java index 3714924c6670..b1d2c7107a5f 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java @@ -82,6 +82,7 @@ public void transformForDeployment( Artifact artifact, ArtifactRepository remote private ArtifactMetadata createMetadata( Artifact artifact ) { Versioning versioning = new Versioning(); + // TODO Should this be changed for MNG-6754 too? versioning.updateTimestamp(); versioning.addVersion( artifact.getVersion() ); diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/SnapshotTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/SnapshotTransformation.java index 895b952669e6..1a79049b17e4 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/SnapshotTransformation.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/SnapshotTransformation.java @@ -91,6 +91,7 @@ public void transformForDeployment( Artifact artifact, ArtifactRepository remote { Snapshot snapshot = new Snapshot(); + // TODO Should this be changed for MNG-6754 too? snapshot.setTimestamp( getDeploymentTimestamp() ); // we update the build number anyway so that it doesn't get lost. It requires the timestamp to take effect diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java index 46c41b94e75d..4ebe33f2c1f7 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java @@ -165,7 +165,6 @@ protected static Versioning createVersioning( Snapshot snapshot ) { Versioning versioning = new Versioning(); versioning.setSnapshot( snapshot ); - versioning.updateTimestamp(); return versioning; } diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java index bda467c45e06..9c4cede1c2c3 100644 --- a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java +++ b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java @@ -102,6 +102,7 @@ public DefaultRepositorySystemSession newRepositorySession( MavenExecutionReques Map configProps = new LinkedHashMap<>(); configProps.put( ConfigurationProperties.USER_AGENT, getUserAgent() ); configProps.put( ConfigurationProperties.INTERACTIVE, request.isInteractiveMode() ); + configProps.put( "maven.startTime", request.getStartTime() ); configProps.putAll( request.getSystemProperties() ); configProps.putAll( request.getUserProperties() ); diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java index ce09efdf4f31..453e4d2bec9d 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java @@ -22,6 +22,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Collection; +import java.util.Date; import java.util.LinkedHashMap; import java.util.Map; @@ -42,15 +43,15 @@ final class LocalSnapshotMetadata private final boolean legacyFormat; - LocalSnapshotMetadata( Artifact artifact, boolean legacyFormat ) + LocalSnapshotMetadata( Artifact artifact, boolean legacyFormat, Date timestamp ) { - super( createMetadata( artifact, legacyFormat ), null ); + super( createMetadata( artifact, legacyFormat ), null, timestamp ); this.legacyFormat = legacyFormat; } - LocalSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat ) + LocalSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat, Date timestamp ) { - super( metadata, file ); + super( metadata, file, timestamp ); this.legacyFormat = legacyFormat; } @@ -82,7 +83,7 @@ public void bind( Artifact artifact ) public MavenMetadata setFile( File file ) { - return new LocalSnapshotMetadata( metadata, file, legacyFormat ); + return new LocalSnapshotMetadata( metadata, file, legacyFormat, timestamp ); } public Object getKey() @@ -98,7 +99,7 @@ public static Object getKey( Artifact artifact ) @Override protected void merge( Metadata recessive ) { - metadata.getVersioning().updateTimestamp(); + metadata.getVersioning().setLastUpdatedTimestamp( timestamp ); if ( !legacyFormat ) { @@ -160,4 +161,4 @@ public Nature getNature() return Nature.SNAPSHOT; } -} \ No newline at end of file +} diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java index 584e1666064e..75b4e6b93900 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadataGenerator.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.Collections; +import java.util.Date; import java.util.LinkedHashMap; import java.util.Map; @@ -42,10 +43,14 @@ class LocalSnapshotMetadataGenerator private final boolean legacyFormat; + private final Date timestamp; + LocalSnapshotMetadataGenerator( RepositorySystemSession session, InstallRequest request ) { legacyFormat = ConfigUtils.getBoolean( session.getConfigProperties(), false, "maven.metadata.legacy" ); + timestamp = (Date) ConfigUtils.getObject( session, new Date(), "maven.startTime" ); + snapshots = new LinkedHashMap<>(); } @@ -59,7 +64,7 @@ public Collection prepare( Collection ar LocalSnapshotMetadata snapshotMetadata = snapshots.get( key ); if ( snapshotMetadata == null ) { - snapshotMetadata = new LocalSnapshotMetadata( artifact, legacyFormat ); + snapshotMetadata = new LocalSnapshotMetadata( artifact, legacyFormat, timestamp ); snapshots.put( key, snapshotMetadata ); } snapshotMetadata.bind( artifact ); diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java index aef44f6bbb5e..bdddc709f6ae 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java @@ -34,6 +34,7 @@ import java.io.Reader; import java.io.Writer; import java.util.Collections; +import java.util.Date; import java.util.Map; /** @@ -46,16 +47,19 @@ abstract class MavenMetadata static final String MAVEN_METADATA_XML = "maven-metadata.xml"; + protected Metadata metadata; + private final File file; - protected Metadata metadata; + protected final Date timestamp; private boolean merged; - protected MavenMetadata( Metadata metadata, File file ) + protected MavenMetadata( Metadata metadata, File file, Date timestamp ) { this.metadata = metadata; this.file = file; + this.timestamp = timestamp; } public String getType() diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java index e4c9a7e9e0d7..35d4d42808a1 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java @@ -22,6 +22,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Collection; +import java.util.Date; import org.apache.maven.artifact.repository.metadata.Metadata; import org.eclipse.aether.artifact.Artifact; @@ -38,9 +39,9 @@ abstract class MavenSnapshotMetadata protected final boolean legacyFormat; - protected MavenSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat ) + protected MavenSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat, Date timestamp ) { - super( metadata, file ); + super( metadata, file, timestamp ); this.legacyFormat = legacyFormat; } diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java index efcfb4d5e8ca..d9b56166af79 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java @@ -47,19 +47,19 @@ final class RemoteSnapshotMetadata private final Map versions = new LinkedHashMap<>(); - RemoteSnapshotMetadata( Artifact artifact, boolean legacyFormat ) + RemoteSnapshotMetadata( Artifact artifact, boolean legacyFormat, Date timestamp ) { - super( createRepositoryMetadata( artifact, legacyFormat ), null, legacyFormat ); + super( createRepositoryMetadata( artifact, legacyFormat ), null, legacyFormat, timestamp ); } - private RemoteSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat ) + private RemoteSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat, Date timestamp ) { - super( metadata, file, legacyFormat ); + super( metadata, file, legacyFormat, timestamp ); } public MavenMetadata setFile( File file ) { - return new RemoteSnapshotMetadata( metadata, file, legacyFormat ); + return new RemoteSnapshotMetadata( metadata, file, legacyFormat, timestamp ); } public String getExpandedVersion( Artifact artifact ) @@ -82,11 +82,11 @@ protected void merge( Metadata recessive ) snapshot = new Snapshot(); snapshot.setBuildNumber( getBuildNumber( recessive ) + 1 ); - snapshot.setTimestamp( utcDateFormatter.format( new Date() ) ); + snapshot.setTimestamp( utcDateFormatter.format( timestamp ) ); Versioning versioning = new Versioning(); versioning.setSnapshot( snapshot ); - versioning.setLastUpdated( snapshot.getTimestamp().replace( ".", "" ) ); + versioning.setLastUpdatedTimestamp( timestamp ); lastUpdated = versioning.getLastUpdated(); metadata.setVersioning( versioning ); diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java index 32188636b34a..2e42bee7d5c7 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataGenerator.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.Collections; +import java.util.Date; import java.util.LinkedHashMap; import java.util.Map; @@ -42,9 +43,13 @@ class RemoteSnapshotMetadataGenerator private final boolean legacyFormat; + private final Date timestamp; + RemoteSnapshotMetadataGenerator( RepositorySystemSession session, DeployRequest request ) { - legacyFormat = ConfigUtils.getBoolean( session.getConfigProperties(), false, "maven.metadata.legacy" ); + legacyFormat = ConfigUtils.getBoolean( session, false, "maven.metadata.legacy" ); + + timestamp = (Date) ConfigUtils.getObject( session, new Date(), "maven.startTime" ); snapshots = new LinkedHashMap<>(); @@ -74,7 +79,7 @@ public Collection prepare( Collection ar RemoteSnapshotMetadata snapshotMetadata = snapshots.get( key ); if ( snapshotMetadata == null ) { - snapshotMetadata = new RemoteSnapshotMetadata( artifact, legacyFormat ); + snapshotMetadata = new RemoteSnapshotMetadata( artifact, legacyFormat, timestamp ); snapshots.put( key, snapshotMetadata ); } snapshotMetadata.bind( artifact ); diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java index f7df64ef7fa9..5103e5caea82 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java @@ -22,6 +22,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Collection; +import java.util.Date; import java.util.LinkedHashSet; import org.apache.maven.artifact.repository.metadata.Metadata; @@ -38,15 +39,15 @@ final class VersionsMetadata private final Artifact artifact; - VersionsMetadata( Artifact artifact ) + VersionsMetadata( Artifact artifact, Date timestamp ) { - super( createRepositoryMetadata( artifact ), null ); + super( createRepositoryMetadata( artifact ), null, timestamp ); this.artifact = artifact; } - VersionsMetadata( Artifact artifact, File file ) + VersionsMetadata( Artifact artifact, File file, Date timestamp ) { - super( createRepositoryMetadata( artifact ), file ); + super( createRepositoryMetadata( artifact ), file, timestamp ); this.artifact = artifact; } @@ -76,7 +77,7 @@ private static Metadata createRepositoryMetadata( Artifact artifact ) protected void merge( Metadata recessive ) { Versioning versioning = metadata.getVersioning(); - versioning.updateTimestamp(); + versioning.setLastUpdatedTimestamp( timestamp ); if ( recessive.getVersioning() != null ) { @@ -107,7 +108,7 @@ public static Object getKey( Artifact artifact ) public MavenMetadata setFile( File file ) { - return new VersionsMetadata( artifact, file ); + return new VersionsMetadata( artifact, file, timestamp ); } public String getGroupId() diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java index d6b5c8a41c91..409eec4221d1 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadataGenerator.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.Collections; +import java.util.Date; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; @@ -31,6 +32,7 @@ import org.eclipse.aether.impl.MetadataGenerator; import org.eclipse.aether.installation.InstallRequest; import org.eclipse.aether.metadata.Metadata; +import org.eclipse.aether.util.ConfigUtils; /** * @author Benjamin Bentmann @@ -43,6 +45,8 @@ class VersionsMetadataGenerator private Map processedVersions; + private final Date timestamp; + VersionsMetadataGenerator( RepositorySystemSession session, InstallRequest request ) { this( session, request.getMetadata() ); @@ -57,6 +61,7 @@ private VersionsMetadataGenerator( RepositorySystemSession session, Collection(); processedVersions = new LinkedHashMap<>(); + timestamp = (Date) ConfigUtils.getObject( session, new Date(), "maven.startTime" ); /* * NOTE: This should be considered a quirk to support interop with Maven's legacy ArtifactDeployer which @@ -96,7 +101,7 @@ public Collection finish( Collection art VersionsMetadata versionsMetadata = versions.get( key ); if ( versionsMetadata == null ) { - versionsMetadata = new VersionsMetadata( artifact ); + versionsMetadata = new VersionsMetadata( artifact, timestamp ); versions.put( key, versionsMetadata ); } } diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java index 278231f9f60e..c319348c8082 100644 --- a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java +++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/RemoteSnapshotMetadataTest.java @@ -66,7 +66,7 @@ public void gregorianCalendarIsUsed() String dateBefore = gregorianDate(); RemoteSnapshotMetadata metadata = new RemoteSnapshotMetadata( - new DefaultArtifact( "a:b:1-SNAPSHOT" ), false); + new DefaultArtifact( "a:b:1-SNAPSHOT" ), false, new Date() ); metadata.merge( new Metadata() ); String dateAfter = gregorianDate(); From 176b272f30c4fbd62013b4702ab28518c21628ac Mon Sep 17 00:00:00 2001 From: Nils Breunese Date: Tue, 13 Jul 2021 20:36:38 +0200 Subject: [PATCH 062/183] [MNG-7185] Describe explicit and recommended version for VersionRange.createFromVersionSpec() This closes #487 --- .../org/apache/maven/artifact/versioning/VersionRange.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java index bbc6523607b7..3689b2e7abcb 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java @@ -91,7 +91,8 @@ public VersionRange cloneOf() *

* Some spec examples are: *
    - *
  • 1.0 Version 1.0
  • + *
  • 1.0 Version 1.0 as a recommended version
  • + *
  • [1.0] Version 1.0 explicitly only
  • *
  • [1.0,2.0) Versions 1.0 (included) to 2.0 (not included)
  • *
  • [1.0,2.0] Versions 1.0 to 2.0 (both included)
  • *
  • [1.5,) Versions 1.5 and higher
  • From 268f9565746175f5900670e372092e0c071d85bd Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Mon, 19 Jul 2021 23:45:50 +0200 Subject: [PATCH 063/183] Use proper term: directory --- apache-maven/src/bin/mvn.cmd | 2 +- .../projects/project-builder/it0063/jdk/jre/placeholder.txt | 2 +- .../it0063/jdk/jre/placeholder.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apache-maven/src/bin/mvn.cmd b/apache-maven/src/bin/mvn.cmd index b8367f61e3e3..d8f26265f8c8 100644 --- a/apache-maven/src/bin/mvn.cmd +++ b/apache-maven/src/bin/mvn.cmd @@ -74,7 +74,7 @@ goto error set MAVEN_CMD_LINE_ARGS=%* -@REM Find the project basedir, i.e., the directory that contains the folder ".mvn". +@REM Find the project basedir, i.e., the directory that contains the directory ".mvn". @REM Fallback to current working directory if not found. set "MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%" diff --git a/maven-core/src/test/projects/project-builder/it0063/jdk/jre/placeholder.txt b/maven-core/src/test/projects/project-builder/it0063/jdk/jre/placeholder.txt index e26e86087ce3..4a9eb145a1e3 100644 --- a/maven-core/src/test/projects/project-builder/it0063/jdk/jre/placeholder.txt +++ b/maven-core/src/test/projects/project-builder/it0063/jdk/jre/placeholder.txt @@ -1 +1 @@ -need it so that empty folder does not get deleted \ No newline at end of file +need it so that empty directory does not get deleted diff --git a/maven-core/src/test/projects/project-dependencies-resolver/it0063/jdk/jre/placeholder.txt b/maven-core/src/test/projects/project-dependencies-resolver/it0063/jdk/jre/placeholder.txt index e26e86087ce3..4a9eb145a1e3 100644 --- a/maven-core/src/test/projects/project-dependencies-resolver/it0063/jdk/jre/placeholder.txt +++ b/maven-core/src/test/projects/project-dependencies-resolver/it0063/jdk/jre/placeholder.txt @@ -1 +1 @@ -need it so that empty folder does not get deleted \ No newline at end of file +need it so that empty directory does not get deleted From 25df095829bff8a1744db7dbf1ddd14aa1f8d43f Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Mon, 19 Jul 2021 23:56:22 +0200 Subject: [PATCH 064/183] [MNG-7190] Load mavenrc from /usr/local/etc also in Bourne shell script --- apache-maven/src/bin/mvn | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apache-maven/src/bin/mvn b/apache-maven/src/bin/mvn index 1d429303a6b1..cc2cdacba096 100755 --- a/apache-maven/src/bin/mvn +++ b/apache-maven/src/bin/mvn @@ -29,6 +29,10 @@ if [ -z "$MAVEN_SKIP_RC" ] ; then + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + if [ -f /etc/mavenrc ] ; then . /etc/mavenrc fi From c395ca976dc9eaed65dcdc0037508d1edbfb57f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Tue, 20 Jul 2021 22:41:03 +0200 Subject: [PATCH 065/183] [MNG-7190] add /usr/local/etc/mavenrc to reference documentation --- apache-maven/src/site/apt/index.apt.vm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apache-maven/src/site/apt/index.apt.vm b/apache-maven/src/site/apt/index.apt.vm index 994aeab1d9eb..1d802661d98f 100644 --- a/apache-maven/src/site/apt/index.apt.vm +++ b/apache-maven/src/site/apt/index.apt.vm @@ -31,9 +31,9 @@ ${project.name} * <<>> invocation can be customised through: - * <<>> and <<<~/.mavenrc>>> scripts on Unix, + * <<>> (since 3.8.2), <<>> and <<<$HOME/.mavenrc>>> scripts on Unix, - * <<<~\mavenrc_pre.bat>>> and <<<~\mavenrc_pre.cmd>>> scripts on Windows, + * <<<%USERPROFILE%\\mavenrc_pre.bat>>> and <<<%USERPROFILE%\\mavenrc_pre.cmd>>> scripts on Windows, [] From b74199ed446c83282ad806afaf962a7f74eac0ea Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 25 Nov 2020 20:12:04 +0100 Subject: [PATCH 066/183] [MNG-7034] StackOverflowError thrown if a cycle exists in BOM imports This closes #484 --- .../model/building/DefaultModelBuilder.java | 11 +- .../building/DefaultModelBuilderTest.java | 153 ++++++++++++++++++ 2 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 maven-model-builder/src/test/java/org/apache/maven/model/building/DefaultModelBuilderTest.java diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java index a8568efb2753..a089f9d991df 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java @@ -248,6 +248,13 @@ public DefaultModelBuilder setReportingConverter( ReportingConverter reportingCo @Override public ModelBuildingResult build( ModelBuildingRequest request ) throws ModelBuildingException + { + return build( request, new LinkedHashSet() ); + } + + @SuppressWarnings( "checkstyle:methodlength" ) + protected ModelBuildingResult build( ModelBuildingRequest request, Collection importIds ) + throws ModelBuildingException { // phase 1 DefaultModelBuildingResult result = new DefaultModelBuildingResult(); @@ -427,7 +434,7 @@ else if ( !parentIds.add( parentData.getId() ) ) if ( !request.isTwoPhaseBuilding() ) { - build( request, result ); + build( request, result, importIds ); } return result; @@ -1303,7 +1310,7 @@ private void importDependencyManagement( Model model, ModelBuildingRequest reque final ModelBuildingResult importResult; try { - importResult = build( importRequest ); + importResult = build( importRequest, importIds ); } catch ( ModelBuildingException e ) { diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/building/DefaultModelBuilderTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/building/DefaultModelBuilderTest.java new file mode 100644 index 000000000000..4e7919a6c2ed --- /dev/null +++ b/maven-model-builder/src/test/java/org/apache/maven/model/building/DefaultModelBuilderTest.java @@ -0,0 +1,153 @@ +package org.apache.maven.model.building; + + /* + * 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.model.Dependency; +import org.apache.maven.model.Parent; +import org.apache.maven.model.Repository; +import org.apache.maven.model.resolution.InvalidRepositoryException; +import org.apache.maven.model.resolution.ModelResolver; +import org.apache.maven.model.resolution.UnresolvableModelException; +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +/** + * @author Guillaume Nodet + */ +public class DefaultModelBuilderTest +{ + + private static final String BASE1_ID = "thegroup:base1:pom"; + private static final String BASE1_ID2 = "thegroup:base1:1"; + + private static final String BASE1 = "\n" + + " 4.0.0\n" + + " thegroup\n" + + " base1\n" + + " 1\n" + + " pom\n" + + " \n" + + " \n" + + " \n" + + " thegroup\n" + + " base2\n" + + " 1\n" + + " pom\n" + + " import\n" + + " \n" + + " \n" + + " \n" + + "\n"; + + private static final String BASE2_ID = "thegroup:base2:pom"; + private static final String BASE2_ID2 = "thegroup:base2:1"; + + private static final String BASE2 = "\n" + + " 4.0.0\n" + + " thegroup\n" + + " base2\n" + + " 1\n" + + " pom\n" + + " \n" + + " \n" + + " \n" + + " thegroup\n" + + " base1\n" + + " 1\n" + + " pom\n" + + " import\n" + + " \n" + + " \n" + + " \n" + + "\n"; + + @Test( expected = ModelBuildingException.class ) + public void testCycleInImports() + throws Exception + { + ModelBuilder builder = new DefaultModelBuilderFactory().newInstance(); + assertNotNull( builder ); + + DefaultModelBuildingRequest request = new DefaultModelBuildingRequest(); + request.setModelSource( new StringModelSource( BASE1 ) ); + request.setModelResolver( new CycleInImportsResolver() ); + + builder.build( request ); + } + + static class CycleInImportsResolver extends BaseModelResolver + { + @Override + public ModelSource resolveModel(Dependency dependency) throws UnresolvableModelException + { + switch ( dependency.getManagementKey() ) + { + case BASE1_ID: return new StringModelSource( BASE1 ); + case BASE2_ID: return new StringModelSource( BASE2 ); + } + return null; + } + } + + static class BaseModelResolver implements ModelResolver + { + @Override + public ModelSource resolveModel( String groupId, String artifactId, String version ) + throws UnresolvableModelException + { + switch ( groupId + ":" + artifactId + ":" + version ) + { + case BASE1_ID2: return new StringModelSource( BASE1 ); + case BASE2_ID2: return new StringModelSource( BASE2 ); + } + return null; + } + + @Override + public ModelSource resolveModel( Parent parent ) throws UnresolvableModelException + { + return null; + } + + @Override + public ModelSource resolveModel( Dependency dependency ) throws UnresolvableModelException + { + return null; + } + + @Override + public void addRepository( Repository repository ) throws InvalidRepositoryException + { + } + + @Override + public void addRepository(Repository repository, boolean replace) throws InvalidRepositoryException + { + } + + @Override + public ModelResolver newCopy() + { + return this; + } + } + +} From 22a8cfa05976b23284388675dcabd7e5e8037fb0 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Thu, 22 Jul 2021 21:07:03 +0200 Subject: [PATCH 067/183] [MNG-6648] 'mavenrc_pre' script does not receive arguments like mavenrc in Bourne shell does This closes #511 --- apache-maven/src/bin/mvn.cmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apache-maven/src/bin/mvn.cmd b/apache-maven/src/bin/mvn.cmd index d8f26265f8c8..0faa39f81de8 100644 --- a/apache-maven/src/bin/mvn.cmd +++ b/apache-maven/src/bin/mvn.cmd @@ -35,8 +35,8 @@ @REM Execute a user defined script before this one if not "%MAVEN_SKIP_RC%"=="" goto skipRcPre @REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" -if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* :skipRcPre @setlocal From f32eb09892686cba083f9f175b3c8eac0ac42ae7 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 23 Jul 2021 22:45:34 +0200 Subject: [PATCH 068/183] [MNG-7010] Omit "NB: JAVA_HOME should point to a JDK not a JRE" This closes #512 --- apache-maven/src/bin/mvn | 5 ++--- apache-maven/src/bin/mvn.cmd | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/apache-maven/src/bin/mvn b/apache-maven/src/bin/mvn index cc2cdacba096..29e0eabb837c 100755 --- a/apache-maven/src/bin/mvn +++ b/apache-maven/src/bin/mvn @@ -100,9 +100,8 @@ else fi if [ ! -x "$JAVACMD" ] ; then - echo "The JAVA_HOME environment variable is not defined correctly" >&2 - echo "This environment variable is needed to run this program" >&2 - echo "NB: JAVA_HOME should point to a JDK not a JRE" >&2 + echo "The JAVA_HOME environment variable is not defined correctly," >&2 + echo "this environment variable is needed to run this program." >&2 exit 1 fi diff --git a/apache-maven/src/bin/mvn.cmd b/apache-maven/src/bin/mvn.cmd index 0faa39f81de8..fcb0f455a804 100644 --- a/apache-maven/src/bin/mvn.cmd +++ b/apache-maven/src/bin/mvn.cmd @@ -54,9 +54,8 @@ set "JAVACMD=%JAVA_HOME%\bin\java.exe" :checkJCmd if exist "%JAVACMD%" goto chkMHome -echo The JAVA_HOME environment variable is not defined correctly >&2 -echo This environment variable is needed to run this program >&2 -echo NB: JAVA_HOME should point to a JDK not a JRE >&2 +echo The JAVA_HOME environment variable is not defined correctly, >&2 +echo this environment variable is needed to run this program. >&2 goto error :chkMHome From 51f6d8b8525d8bf218f70100ec99a7ae97097923 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 25 Jul 2021 14:32:31 +0200 Subject: [PATCH 069/183] [MNG-7196] Upgrade Jansi to 2.3.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dbe5eb2de604..750e63b1eeb8 100644 --- a/pom.xml +++ b/pom.xml @@ -294,7 +294,7 @@ under the License. org.fusesource.jansi jansi - 2.3.3 + 2.3.4 org.slf4j From 7ecdb3c970d71de3e48fe4de691388868ac03630 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Tue, 27 Jul 2021 14:58:11 +0200 Subject: [PATCH 070/183] [MNG-7198] Upgrade SLF4J to 1.7.32 --- .../{MIT-slf4j-api-1.7.30.txt => MIT-slf4j-api-1.7.32.txt} | 0 pom.xml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename apache-maven/src/main/appended-resources/licenses/{MIT-slf4j-api-1.7.30.txt => MIT-slf4j-api-1.7.32.txt} (100%) diff --git a/apache-maven/src/main/appended-resources/licenses/MIT-slf4j-api-1.7.30.txt b/apache-maven/src/main/appended-resources/licenses/MIT-slf4j-api-1.7.32.txt similarity index 100% rename from apache-maven/src/main/appended-resources/licenses/MIT-slf4j-api-1.7.30.txt rename to apache-maven/src/main/appended-resources/licenses/MIT-slf4j-api-1.7.32.txt diff --git a/pom.xml b/pom.xml index 750e63b1eeb8..318141ea1899 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,7 @@ under the License. 1.11 1.3 1.6.3 - 1.7.30 + 1.7.32 2.2.1 1.7.4 true From ea98e05a04480131370aa0c110b8c54cf726c06f Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Wed, 4 Aug 2021 21:03:30 +0200 Subject: [PATCH 071/183] [maven-release-plugin] prepare release maven-3.8.2 --- apache-maven/pom.xml | 2 +- maven-artifact/pom.xml | 2 +- maven-builder-support/pom.xml | 2 +- maven-compat/pom.xml | 2 +- maven-core/pom.xml | 2 +- maven-embedder/pom.xml | 2 +- maven-model-builder/pom.xml | 2 +- maven-model/pom.xml | 2 +- maven-plugin-api/pom.xml | 2 +- maven-repository-metadata/pom.xml | 2 +- maven-resolver-provider/pom.xml | 2 +- maven-settings-builder/pom.xml | 2 +- maven-settings/pom.xml | 2 +- maven-slf4j-provider/pom.xml | 2 +- pom.xml | 6 +++--- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index 6e267ad5e25a..42491b3feb84 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2-SNAPSHOT + 3.8.2 apache-maven diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml index 6b2aabfeebe7..d085c96530d2 100644 --- a/maven-artifact/pom.xml +++ b/maven-artifact/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2-SNAPSHOT + 3.8.2 maven-artifact diff --git a/maven-builder-support/pom.xml b/maven-builder-support/pom.xml index ed0df18ec467..af3608dbb1a5 100644 --- a/maven-builder-support/pom.xml +++ b/maven-builder-support/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2-SNAPSHOT + 3.8.2 maven-builder-support diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml index 55f4f2575342..161764395933 100644 --- a/maven-compat/pom.xml +++ b/maven-compat/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2-SNAPSHOT + 3.8.2 maven-compat diff --git a/maven-core/pom.xml b/maven-core/pom.xml index dc5a422e202a..7c7b722310ce 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2-SNAPSHOT + 3.8.2 maven-core diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index 2edf4171d63b..637a408cf40b 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2-SNAPSHOT + 3.8.2 maven-embedder diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml index a383fefe3e4f..1365b6b64026 100644 --- a/maven-model-builder/pom.xml +++ b/maven-model-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2-SNAPSHOT + 3.8.2 maven-model-builder diff --git a/maven-model/pom.xml b/maven-model/pom.xml index cd9a63940231..c99d8e337fe2 100644 --- a/maven-model/pom.xml +++ b/maven-model/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2-SNAPSHOT + 3.8.2 maven-model diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml index 3d93184524ee..8ac3cfbb5037 100644 --- a/maven-plugin-api/pom.xml +++ b/maven-plugin-api/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2-SNAPSHOT + 3.8.2 maven-plugin-api diff --git a/maven-repository-metadata/pom.xml b/maven-repository-metadata/pom.xml index b1ec1e540fb1..486e26e04be5 100644 --- a/maven-repository-metadata/pom.xml +++ b/maven-repository-metadata/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2-SNAPSHOT + 3.8.2 maven-repository-metadata diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml index 355a4ebab0c4..d4a1c61363e9 100644 --- a/maven-resolver-provider/pom.xml +++ b/maven-resolver-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2-SNAPSHOT + 3.8.2 maven-resolver-provider diff --git a/maven-settings-builder/pom.xml b/maven-settings-builder/pom.xml index ee196b75d804..055eb0dbb485 100644 --- a/maven-settings-builder/pom.xml +++ b/maven-settings-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2-SNAPSHOT + 3.8.2 maven-settings-builder diff --git a/maven-settings/pom.xml b/maven-settings/pom.xml index bdc4c0f435bf..606550eea8fa 100644 --- a/maven-settings/pom.xml +++ b/maven-settings/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2-SNAPSHOT + 3.8.2 maven-settings diff --git a/maven-slf4j-provider/pom.xml b/maven-slf4j-provider/pom.xml index b896f9548acd..b4280ce7a460 100644 --- a/maven-slf4j-provider/pom.xml +++ b/maven-slf4j-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2-SNAPSHOT + 3.8.2 maven-slf4j-provider diff --git a/pom.xml b/pom.xml index 318141ea1899..1875b9f65b72 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven - 3.8.2-SNAPSHOT + 3.8.2 pom Apache Maven @@ -77,7 +77,7 @@ under the License. ref/3-LATEST None **/package-info.java - 2019-11-07T12:32:18Z + 2021-08-04T18:57:55Z @@ -101,7 +101,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven.git scm:git:https://gitbox.apache.org/repos/asf/maven.git https://github.com/apache/maven/tree/${project.scm.tag} - maven-3.8.x + maven-3.8.2 jira From 865dcaa6fffc8fbc679f190280e1f0f7b1d783b5 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Wed, 4 Aug 2021 21:03:42 +0200 Subject: [PATCH 072/183] [maven-release-plugin] prepare for next development iteration --- apache-maven/pom.xml | 2 +- maven-artifact/pom.xml | 2 +- maven-builder-support/pom.xml | 2 +- maven-compat/pom.xml | 2 +- maven-core/pom.xml | 2 +- maven-embedder/pom.xml | 2 +- maven-model-builder/pom.xml | 2 +- maven-model/pom.xml | 2 +- maven-plugin-api/pom.xml | 2 +- maven-repository-metadata/pom.xml | 2 +- maven-resolver-provider/pom.xml | 2 +- maven-settings-builder/pom.xml | 2 +- maven-settings/pom.xml | 2 +- maven-slf4j-provider/pom.xml | 2 +- pom.xml | 4 ++-- 15 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index 42491b3feb84..2cc6ca31d533 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2 + 3.8.3-SNAPSHOT apache-maven diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml index d085c96530d2..5203f1b79592 100644 --- a/maven-artifact/pom.xml +++ b/maven-artifact/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2 + 3.8.3-SNAPSHOT maven-artifact diff --git a/maven-builder-support/pom.xml b/maven-builder-support/pom.xml index af3608dbb1a5..191bfc5967d0 100644 --- a/maven-builder-support/pom.xml +++ b/maven-builder-support/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2 + 3.8.3-SNAPSHOT maven-builder-support diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml index 161764395933..06686b980a5d 100644 --- a/maven-compat/pom.xml +++ b/maven-compat/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2 + 3.8.3-SNAPSHOT maven-compat diff --git a/maven-core/pom.xml b/maven-core/pom.xml index 7c7b722310ce..60b958f1f6fb 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2 + 3.8.3-SNAPSHOT maven-core diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index 637a408cf40b..e0b647902053 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2 + 3.8.3-SNAPSHOT maven-embedder diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml index 1365b6b64026..06d42d38e31b 100644 --- a/maven-model-builder/pom.xml +++ b/maven-model-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2 + 3.8.3-SNAPSHOT maven-model-builder diff --git a/maven-model/pom.xml b/maven-model/pom.xml index c99d8e337fe2..0e002c0c2f5e 100644 --- a/maven-model/pom.xml +++ b/maven-model/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2 + 3.8.3-SNAPSHOT maven-model diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml index 8ac3cfbb5037..a0a708926b69 100644 --- a/maven-plugin-api/pom.xml +++ b/maven-plugin-api/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2 + 3.8.3-SNAPSHOT maven-plugin-api diff --git a/maven-repository-metadata/pom.xml b/maven-repository-metadata/pom.xml index 486e26e04be5..b4ac0f489b00 100644 --- a/maven-repository-metadata/pom.xml +++ b/maven-repository-metadata/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2 + 3.8.3-SNAPSHOT maven-repository-metadata diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml index d4a1c61363e9..70e0f4e5bc35 100644 --- a/maven-resolver-provider/pom.xml +++ b/maven-resolver-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2 + 3.8.3-SNAPSHOT maven-resolver-provider diff --git a/maven-settings-builder/pom.xml b/maven-settings-builder/pom.xml index 055eb0dbb485..a85c8a8c1191 100644 --- a/maven-settings-builder/pom.xml +++ b/maven-settings-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2 + 3.8.3-SNAPSHOT maven-settings-builder diff --git a/maven-settings/pom.xml b/maven-settings/pom.xml index 606550eea8fa..6fa967c38ca3 100644 --- a/maven-settings/pom.xml +++ b/maven-settings/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2 + 3.8.3-SNAPSHOT maven-settings diff --git a/maven-slf4j-provider/pom.xml b/maven-slf4j-provider/pom.xml index b4280ce7a460..802d226c9c0a 100644 --- a/maven-slf4j-provider/pom.xml +++ b/maven-slf4j-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.2 + 3.8.3-SNAPSHOT maven-slf4j-provider diff --git a/pom.xml b/pom.xml index 1875b9f65b72..05b80b2db065 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven - 3.8.2 + 3.8.3-SNAPSHOT pom Apache Maven @@ -77,7 +77,7 @@ under the License. ref/3-LATEST None **/package-info.java - 2021-08-04T18:57:55Z + 2021-08-04T19:03:41Z From 9adb3aedf21ca9a49560957e0e1b9125266bb401 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 13 Aug 2021 21:59:19 +0200 Subject: [PATCH 073/183] Document Maven 3.8.1 and 3.8.2 releases --- doap_Maven.rdf | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doap_Maven.rdf b/doap_Maven.rdf index 45b4e4bef3e4..0417fff803ea 100644 --- a/doap_Maven.rdf +++ b/doap_Maven.rdf @@ -33,6 +33,24 @@ under the License. Latest stable release + 2021-08-04 + 3.8.2 + http://archive.apache.org/dist/maven/maven-3/3.8.2/binaries/apache-maven-3.8.2-bin.zip + http://archive.apache.org/dist/maven/maven-3/3.8.2/binaries/apache-maven-3.8.2-bin.tar.gz + http://archive.apache.org/dist/maven/maven-3/3.8.2/source/apache-maven-3.8.2-src.zip + http://archive.apache.org/dist/maven/maven-3/3.8.2/source/apache-maven-3.8.2-src.tar.gz + + + Latest stable release + 2021-04-04 + 3.8.1 + http://archive.apache.org/dist/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.zip + http://archive.apache.org/dist/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz + http://archive.apache.org/dist/maven/maven-3/3.8.1/source/apache-maven-3.8.1-src.zip + http://archive.apache.org/dist/maven/maven-3/3.8.1/source/apache-maven-3.8.1-src.tar.gz + + + Apache Maven 3.6.2 2019-08-27 3.6.2 http://archive.apache.org/dist/maven/maven-3/3.6.2/binaries/apache-maven-3.6.2-bin.zip From 4dc115967a9ac1522fe01d33de1a3279d52a559a Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 14 Aug 2021 10:27:09 +0200 Subject: [PATCH 074/183] Fix DOAP --- doap_Maven.rdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doap_Maven.rdf b/doap_Maven.rdf index 0417fff803ea..531df1217a61 100644 --- a/doap_Maven.rdf +++ b/doap_Maven.rdf @@ -41,7 +41,7 @@ under the License. http://archive.apache.org/dist/maven/maven-3/3.8.2/source/apache-maven-3.8.2-src.tar.gz - Latest stable release + Apache Maven 3.8.1 2021-04-04 3.8.1 http://archive.apache.org/dist/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.zip From 547dfddb2ef02f44d9f2d0730348eaedfcd2e126 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Wed, 22 Jan 2020 09:25:24 +0100 Subject: [PATCH 075/183] Improve license handling * Stream line the output of the license listing * Exclude jsoup from final distribution since we only need its license information * Use proper SPDX ID for our license This closes #317 --- apache-maven/pom.xml | 6 +++--- .../appended-resources/META-INF/LICENSE.vm | 19 +++++++++++-------- .../licenses/{ASL-2.0.txt => Apache-2.0.txt} | 0 apache-maven/src/main/assembly/component.xml | 1 + 4 files changed, 15 insertions(+), 11 deletions(-) rename apache-maven/src/main/appended-resources/licenses/{ASL-2.0.txt => Apache-2.0.txt} (100%) diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index 2cc6ca31d533..a4cf0396c61b 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -79,10 +79,10 @@ under the License. + - org.jsoup jsoup runtime diff --git a/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm b/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm index 25ac46f3770f..43357d142ef0 100644 --- a/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm +++ b/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm @@ -18,21 +18,21 @@ ## -Apache Maven includes a number of components and libraries with separate -copyright notices and license terms. Your use of those components are -subject to the terms and conditions of the following licenses: +Apache Maven includes a number of components and libraries with separate +copyright notices and license terms. Your use of those components are +subject to the terms and conditions of the following licenses: ## #set ( $apacheMavenGroupIds = [ "org.apache.maven", "org.apache.maven.wagon", "org.apache.maven.resolver", "org.apache.maven.shared" ] ) #set ( $MITLicenseNames = [ "MIT License", "MIT license", "The MIT License" ] ) #foreach ( $project in $projects ) -#**##foreach ( $license in $project.licenses) +#**##foreach ( $license in $project.licenses ) #* *##set ( $groupId = $project.artifact.groupId ) #* *##set ( $directory = 'lib' ) #* *##if ( !$apacheMavenGroupIds.contains( $groupId ) ) #* *### advertise about each non-Maven dependency #* *### -#* *### infer SPDX license code +#* *### infer SPDX license id #* *##if ( $license.name == "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0" ) #* *##set ( $spdx = 'CDDL-1.0' ) #* *##elseif ( $MITLicenseNames.contains( $license.name ) ) @@ -40,7 +40,7 @@ subject to the terms and conditions of the following licenses: #* *##elseif ( $license.name == "Eclipse Public License, Version 1.0" ) #* *##set ( $spdx = 'EPL-1.0' ) #* *##elseif ( $license.url.contains( "www.apache.org/licenses/LICENSE-2.0" ) ) -#* *##set ( $spdx = 'ASL-2.0' ) +#* *##set ( $spdx = 'Apache-2.0' ) #* *##else #* *### unrecognized license will require analysis to know obligations #* *##set ( $spdx = 'unrecognized' ) @@ -68,13 +68,16 @@ subject to the terms and conditions of the following licenses: #* *##else #* *##set ( $downloaded = $locator.getResourceAsFile( "licenses/${spdx}.txt", "licenses/${licFile}" ) ) #* *##end + #* *### add dependency info to output - $directory/${project.artifact.artifactId}-${project.artifact.version}.jar: $project.artifact.toString().replace( ':eclipse-plugin:', ':jar:' ) - $project.name + Project: $project.name #if ( $project.url )Project URL: ${project.url}#end - License: $license.name#if ( $spdx ) ($spdx)#end $license.url ($licFile) + License: $license.name#if ( $spdx ) ($spdx)#end + + License URL: $license.url ($licFile) #* *##end #**##end diff --git a/apache-maven/src/main/appended-resources/licenses/ASL-2.0.txt b/apache-maven/src/main/appended-resources/licenses/Apache-2.0.txt similarity index 100% rename from apache-maven/src/main/appended-resources/licenses/ASL-2.0.txt rename to apache-maven/src/main/appended-resources/licenses/Apache-2.0.txt diff --git a/apache-maven/src/main/assembly/component.xml b/apache-maven/src/main/assembly/component.xml index 4f9ff1662854..657d06bf026b 100644 --- a/apache-maven/src/main/assembly/component.xml +++ b/apache-maven/src/main/assembly/component.xml @@ -31,6 +31,7 @@ under the License. lib org.codehaus.plexus:plexus-classworlds + org.jsoup:jsoup From 0c3fe074bbd3272a7b46c28683c6ed50d0daede7 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Mon, 9 Dec 2019 19:43:44 +0100 Subject: [PATCH 076/183] [MNG-6818] - Upgrade plexus-utils 3.3.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 05b80b2db065..82128161c01c 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,7 @@ under the License. 2.21.0 2.1.0 1.25 - 3.2.1 + 3.3.0 4.2.2 0.3.4 3.4.3 From ccafe8bf46ad874ca0cfba6ea5961b34f1630f82 Mon Sep 17 00:00:00 2001 From: "artem.krosheninnikov" Date: Sun, 5 Jan 2020 22:24:21 +0300 Subject: [PATCH 077/183] [MNG-6841] update plexus-interpolation to 1.26 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 82128161c01c..4a4f69ba3f0a 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ under the License. 4.12 2.21.0 2.1.0 - 1.25 + 1.26 3.3.0 4.2.2 0.3.4 From c76c9d9116b4626c20abe26c025623797249f997 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 10 Sep 2021 14:33:45 +0200 Subject: [PATCH 078/183] [MNG-7246] Upgrade Plexus Cipher and Sec Dispatcher to 2.0 Both plexus-cipher and plexus-sec-dispatcher have had a groupId change, but plexus-cipher change was implemented for 1.8 version. Latest versions of artifacts are 2.0. This PR ups plexus-cipher version and adds proper changes for plexus-sec-dispatcher groupId change. This closes #534 --- .../project-with-inheritance/pom.xml | 2 +- .../project-with-inheritance/pom.xml | 2 +- .../org/apache/maven/lifecycle/pom.xml | 2 +- maven-embedder/pom.xml | 2 +- maven-settings-builder/pom.xml | 2 +- pom.xml | 17 ++++++----------- 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/maven-core/src/test/projects/lifecycle-executor/project-with-inheritance/pom.xml b/maven-core/src/test/projects/lifecycle-executor/project-with-inheritance/pom.xml index c9a894d9059b..7d0850e48382 100644 --- a/maven-core/src/test/projects/lifecycle-executor/project-with-inheritance/pom.xml +++ b/maven-core/src/test/projects/lifecycle-executor/project-with-inheritance/pom.xml @@ -473,7 +473,7 @@ under the License. ${mercuryMp3Version} - org.sonatype.plexus + org.codehaus.plexus plexus-sec-dispatcher ${securityDispatcherVersion} diff --git a/maven-core/src/test/projects/plugin-manager/project-with-inheritance/pom.xml b/maven-core/src/test/projects/plugin-manager/project-with-inheritance/pom.xml index c9a894d9059b..7d0850e48382 100644 --- a/maven-core/src/test/projects/plugin-manager/project-with-inheritance/pom.xml +++ b/maven-core/src/test/projects/plugin-manager/project-with-inheritance/pom.xml @@ -473,7 +473,7 @@ under the License. ${mercuryMp3Version} - org.sonatype.plexus + org.codehaus.plexus plexus-sec-dispatcher ${securityDispatcherVersion} diff --git a/maven-core/src/test/resources/org/apache/maven/lifecycle/pom.xml b/maven-core/src/test/resources/org/apache/maven/lifecycle/pom.xml index 531e5510c5a7..5caaac1ba285 100644 --- a/maven-core/src/test/resources/org/apache/maven/lifecycle/pom.xml +++ b/maven-core/src/test/resources/org/apache/maven/lifecycle/pom.xml @@ -473,7 +473,7 @@ under the License. ${mercuryMp3Version} - org.sonatype.plexus + org.codehaus.plexus plexus-sec-dispatcher ${securityDispatcherVersion} diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index e0b647902053..fc90bbc13493 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -131,7 +131,7 @@ under the License. org.eclipse.sisu.plexus - org.sonatype.plexus + org.codehaus.plexus plexus-sec-dispatcher diff --git a/maven-settings-builder/pom.xml b/maven-settings-builder/pom.xml index a85c8a8c1191..dd0c09bb9ce8 100644 --- a/maven-settings-builder/pom.xml +++ b/maven-settings-builder/pom.xml @@ -62,7 +62,7 @@ under the License. maven-settings - org.sonatype.plexus + org.codehaus.plexus plexus-sec-dispatcher diff --git a/pom.xml b/pom.xml index 4a4f69ba3f0a..40a7ee81ade0 100644 --- a/pom.xml +++ b/pom.xml @@ -61,8 +61,8 @@ under the License. 0.3.4 3.4.3 1.12.1 - 1.4 - 1.8 + 2.0 + 2.0 1.11 1.3 1.6.3 @@ -402,15 +402,9 @@ under the License. ${commonsLangVersion} - org.sonatype.plexus + org.codehaus.plexus plexus-sec-dispatcher ${securityDispatcherVersion} - - - org.sonatype.plexus - plexus-cipher - - org.codehaus.plexus @@ -641,15 +635,16 @@ under the License. enforce validate - ensure-no-org.sonatype:plexus-cipher + ensure-no-sonatype-cipher-and-sec-dispatcher + org.sonatype.plexus:plexus-sec-dispatcher org.sonatype.plexus:plexus-cipher - ensure no more org.sonatype.plexus:plexus-cipher as groupId changed. you have to add some exclusions. + ensure no more org.sonatype.plexus:plexus-cipher and org.sonatype.plexus:plexus-sec-dispatcher. From 383cabf9e4992eeff36c9b5731d95bafa72398d3 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Mon, 16 Aug 2021 18:08:39 +0200 Subject: [PATCH 079/183] [MNG-7216] [Regression] Revert MNG-7170 This reverts commit 5a8997312680a4b9c69a129801524691bc546c08. This closes #524 --- .../maven/project/ProjectBuilderTest.java | 26 ------------------- .../projects/modelsourcebasedir/pom.xml | 19 -------------- .../model/building/DefaultModelBuilder.java | 9 +------ 3 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 maven-core/src/test/resources/projects/modelsourcebasedir/pom.xml diff --git a/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java b/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java index 37d51cd49d00..6adb10e8f4e2 100644 --- a/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java @@ -39,8 +39,6 @@ import org.apache.maven.model.Plugin; import org.apache.maven.model.building.FileModelSource; import org.apache.maven.model.building.ModelBuildingRequest; -import org.apache.maven.model.building.ModelProblem; -import org.apache.maven.model.building.ModelProblem.Severity; import org.apache.maven.model.building.ModelSource; import org.apache.maven.shared.utils.io.FileUtils; @@ -85,30 +83,6 @@ public void testBuildFromModelSource() assertNotNull( result.getProject().getParentFile() ); } - public void testBuildFromModelSourceResolvesBasedir() - throws Exception - { - File pomFile = new File( "src/test/resources/projects/modelsourcebasedir/pom.xml" ); - MavenSession mavenSession = createMavenSession( null ); - ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); - configuration.setRepositorySession( mavenSession.getRepositorySession() ); - ModelSource modelSource = new FileModelSource( pomFile ); - ProjectBuildingResult result = - getContainer().lookup( org.apache.maven.project.ProjectBuilder.class ).build( modelSource, configuration ); - - assertEquals( pomFile.getAbsoluteFile(), result.getProject().getModel().getPomFile().getAbsoluteFile() ); - int errors = 0; - for ( ModelProblem p : result.getProblems() ) - { - if ( p.getSeverity() == Severity.ERROR ) - { - errors++; - } - } - assertEquals( 0, errors ); - } - - public void testVersionlessManagedDependency() throws Exception { diff --git a/maven-core/src/test/resources/projects/modelsourcebasedir/pom.xml b/maven-core/src/test/resources/projects/modelsourcebasedir/pom.xml deleted file mode 100644 index ec0f7d385a9b..000000000000 --- a/maven-core/src/test/resources/projects/modelsourcebasedir/pom.xml +++ /dev/null @@ -1,19 +0,0 @@ - - 4.0.0 - test.readparent - local-parent - pom - 1.0 - - - - blah - blah - 0.0.1-SNASPSHOT - system - ${basedir}/blah.jar - - - - diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java index a089f9d991df..70c9ed529cd2 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java @@ -624,14 +624,7 @@ private Model readModel( ModelSource modelSource, File pomFile, ModelBuildingReq throw problems.newModelBuildingException(); } - if ( pomFile != null ) - { - model.setPomFile( pomFile ); - } - else if ( modelSource instanceof FileModelSource ) - { - model.setPomFile( ( (FileModelSource) modelSource ).getFile() ); - } + model.setPomFile( pomFile ); problems.setSource( model ); modelValidator.validateRawModel( model, request, problems ); From e08834b79e9387811ece442f6e7b445b19110fcf Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Mon, 13 Sep 2021 17:56:54 +0200 Subject: [PATCH 080/183] [MNG-7250] Upgrade Sisu Inject/Plexus to 0.3.5 Since we have replaced the old JSR 250 library with javax.annotation library we go straight to 1.2. This closes #539 --- .../appended-resources/META-INF/LICENSE.vm | 6 +- .../appended-resources/META-INF/NOTICE.vm | 2 +- .../appended-resources/licenses/CDDL-1.0.txt | 384 --------- .../unrecognized-javax.annotation-api-1.2.txt | 759 ++++++++++++++++++ .../resources/META-INF/maven/extension.xml | 2 +- maven-embedder/pom.xml | 2 +- pom.xml | 16 +- 7 files changed, 772 insertions(+), 399 deletions(-) delete mode 100644 apache-maven/src/main/appended-resources/licenses/CDDL-1.0.txt create mode 100644 apache-maven/src/main/appended-resources/licenses/unrecognized-javax.annotation-api-1.2.txt diff --git a/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm b/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm index 43357d142ef0..b589e36e0222 100644 --- a/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm +++ b/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm @@ -33,9 +33,7 @@ subject to the terms and conditions of the following licenses: #* *### advertise about each non-Maven dependency #* *### #* *### infer SPDX license id -#* *##if ( $license.name == "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0" ) -#* *##set ( $spdx = 'CDDL-1.0' ) -#* *##elseif ( $MITLicenseNames.contains( $license.name ) ) +#* *##if ( $MITLicenseNames.contains( $license.name ) ) #* *##set ( $spdx = 'MIT' ) #* *##elseif ( $license.name == "Eclipse Public License, Version 1.0" ) #* *##set ( $spdx = 'EPL-1.0' ) @@ -62,7 +60,7 @@ subject to the terms and conditions of the following licenses: #* *### #* *### copy license file to lib/$artifactId.license #* *##set ( $licFile = $directory + '/' + $project.artifact.artifactId + '.license' ) -#* *##if ( $spdx == "MIT" ) +#* *##if ( $spdx == "MIT" || $spdx == "unrecognized" ) #* *### MIT license contains date and copyright that makes the file specific to each artifact #* *##set ( $downloaded = $locator.getResourceAsFile( "licenses/${spdx}-${project.artifact.artifactId}-${project.artifact.version}.txt", "licenses/${licFile}" ) ) #* *##else diff --git a/apache-maven/src/main/appended-resources/META-INF/NOTICE.vm b/apache-maven/src/main/appended-resources/META-INF/NOTICE.vm index acf7ba42e070..3cfd92583cd2 100644 --- a/apache-maven/src/main/appended-resources/META-INF/NOTICE.vm +++ b/apache-maven/src/main/appended-resources/META-INF/NOTICE.vm @@ -36,7 +36,7 @@ javolution (http://javolution.org/). This product includes software developed by Rome (https://rome.dev.java.net/). -about.html in archive lib/org.eclipse.sisu.inject-0.3.4.jar +about.html in archive lib/org.eclipse.sisu.inject-0.3.5.jar diff --git a/apache-maven/src/main/appended-resources/licenses/CDDL-1.0.txt b/apache-maven/src/main/appended-resources/licenses/CDDL-1.0.txt deleted file mode 100644 index 9bc6342e22c9..000000000000 --- a/apache-maven/src/main/appended-resources/licenses/CDDL-1.0.txt +++ /dev/null @@ -1,384 +0,0 @@ -COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 - - - 1. Definitions. - - 1.1. "Contributor" means each individual or entity that - creates or contributes to the creation of Modifications. - - 1.2. "Contributor Version" means the combination of the - Original Software, prior Modifications used by a - Contributor (if any), and the Modifications made by that - particular Contributor. - - 1.3. "Covered Software" means (a) the Original Software, or - (b) Modifications, or (c) the combination of files - containing Original Software with files containing - Modifications, in each case including portions thereof. - - 1.4. "Executable" means the Covered Software in any form - other than Source Code. - - 1.5. "Initial Developer" means the individual or entity - that first makes Original Software available under this - License. - - 1.6. "Larger Work" means a work which combines Covered - Software or portions thereof with code not governed by the - terms of this License. - - 1.7. "License" means this document. - - 1.8. "Licensable" means having the right to grant, to the - maximum extent possible, whether at the time of the initial - grant or subsequently acquired, any and all of the rights - conveyed herein. - - 1.9. "Modifications" means the Source Code and Executable - form of any of the following: - - A. Any file that results from an addition to, - deletion from or modification of the contents of a - file containing Original Software or previous - Modifications; - - B. Any new file that contains any part of the - Original Software or previous Modification; or - - C. Any new file that is contributed or otherwise made - available under the terms of this License. - - 1.10. "Original Software" means the Source Code and - Executable form of computer software code that is - originally released under this License. - - 1.11. "Patent Claims" means any patent claim(s), now owned - or hereafter acquired, including without limitation, - method, process, and apparatus claims, in any patent - Licensable by grantor. - - 1.12. "Source Code" means (a) the common form of computer - software code in which modifications are made and (b) - associated documentation included in or with such code. - - 1.13. "You" (or "Your") means an individual or a legal - entity exercising rights under, and complying with all of - the terms of, this License. For legal entities, "You" - includes any entity which controls, is controlled by, or is - under common control with You. For purposes of this - definition, "control" means (a) the power, direct or - indirect, to cause the direction or management of such - entity, whether by contract or otherwise, or (b) ownership - of more than fifty percent (50%) of the outstanding shares - or beneficial ownership of such entity. - - 2. License Grants. - - 2.1. The Initial Developer Grant. - - Conditioned upon Your compliance with Section 3.1 below and - subject to third party intellectual property claims, the - Initial Developer hereby grants You a world-wide, - royalty-free, non-exclusive license: - - (a) under intellectual property rights (other than - patent or trademark) Licensable by Initial Developer, - to use, reproduce, modify, display, perform, - sublicense and distribute the Original Software (or - portions thereof), with or without Modifications, - and/or as part of a Larger Work; and - - (b) under Patent Claims infringed by the making, - using or selling of Original Software, to make, have - made, use, practice, sell, and offer for sale, and/or - otherwise dispose of the Original Software (or - portions thereof). - - (c) The licenses granted in Sections 2.1(a) and (b) - are effective on the date Initial Developer first - distributes or otherwise makes the Original Software - available to a third party under the terms of this - License. - - (d) Notwithstanding Section 2.1(b) above, no patent - license is granted: (1) for code that You delete from - the Original Software, or (2) for infringements - caused by: (i) the modification of the Original - Software, or (ii) the combination of the Original - Software with other software or devices. - - 2.2. Contributor Grant. - - Conditioned upon Your compliance with Section 3.1 below and - subject to third party intellectual property claims, each - Contributor hereby grants You a world-wide, royalty-free, - non-exclusive license: - - (a) under intellectual property rights (other than - patent or trademark) Licensable by Contributor to - use, reproduce, modify, display, perform, sublicense - and distribute the Modifications created by such - Contributor (or portions thereof), either on an - unmodified basis, with other Modifications, as - Covered Software and/or as part of a Larger Work; and - - - (b) under Patent Claims infringed by the making, - using, or selling of Modifications made by that - Contributor either alone and/or in combination with - its Contributor Version (or portions of such - combination), to make, use, sell, offer for sale, - have made, and/or otherwise dispose of: (1) - Modifications made by that Contributor (or portions - thereof); and (2) the combination of Modifications - made by that Contributor with its Contributor Version - (or portions of such combination). - - (c) The licenses granted in Sections 2.2(a) and - 2.2(b) are effective on the date Contributor first - distributes or otherwise makes the Modifications - available to a third party. - - (d) Notwithstanding Section 2.2(b) above, no patent - license is granted: (1) for any code that Contributor - has deleted from the Contributor Version; (2) for - infringements caused by: (i) third party - modifications of Contributor Version, or (ii) the - combination of Modifications made by that Contributor - with other software (except as part of the - Contributor Version) or other devices; or (3) under - Patent Claims infringed by Covered Software in the - absence of Modifications made by that Contributor. - - 3. Distribution Obligations. - - 3.1. Availability of Source Code. - - Any Covered Software that You distribute or otherwise make - available in Executable form must also be made available in - Source Code form and that Source Code form must be - distributed only under the terms of this License. You must - include a copy of this License with every copy of the - Source Code form of the Covered Software You distribute or - otherwise make available. You must inform recipients of any - such Covered Software in Executable form as to how they can - obtain such Covered Software in Source Code form in a - reasonable manner on or through a medium customarily used - for software exchange. - - 3.2. Modifications. - - The Modifications that You create or to which You - contribute are governed by the terms of this License. You - represent that You believe Your Modifications are Your - original creation(s) and/or You have sufficient rights to - grant the rights conveyed by this License. - - 3.3. Required Notices. - - You must include a notice in each of Your Modifications - that identifies You as the Contributor of the Modification. - You may not remove or alter any copyright, patent or - trademark notices contained within the Covered Software, or - any notices of licensing or any descriptive text giving - attribution to any Contributor or the Initial Developer. - - 3.4. Application of Additional Terms. - - You may not offer or impose any terms on any Covered - Software in Source Code form that alters or restricts the - applicable version of this License or the recipients" - rights hereunder. You may choose to offer, and to charge a - fee for, warranty, support, indemnity or liability - obligations to one or more recipients of Covered Software. - However, you may do so only on Your own behalf, and not on - behalf of the Initial Developer or any Contributor. You - must make it absolutely clear that any such warranty, - support, indemnity or liability obligation is offered by - You alone, and You hereby agree to indemnify the Initial - Developer and every Contributor for any liability incurred - by the Initial Developer or such Contributor as a result of - warranty, support, indemnity or liability terms You offer. - - - 3.5. Distribution of Executable Versions. - - You may distribute the Executable form of the Covered - Software under the terms of this License or under the terms - of a license of Your choice, which may contain terms - different from this License, provided that You are in - compliance with the terms of this License and that the - license for the Executable form does not attempt to limit - or alter the recipient"s rights in the Source Code form - from the rights set forth in this License. If You - distribute the Covered Software in Executable form under a - different license, You must make it absolutely clear that - any terms which differ from this License are offered by You - alone, not by the Initial Developer or Contributor. You - hereby agree to indemnify the Initial Developer and every - Contributor for any liability incurred by the Initial - Developer or such Contributor as a result of any such terms - You offer. - - 3.6. Larger Works. - - You may create a Larger Work by combining Covered Software - with other code not governed by the terms of this License - and distribute the Larger Work as a single product. In such - a case, You must make sure the requirements of this License - are fulfilled for the Covered Software. - - 4. Versions of the License. - - 4.1. New Versions. - - Sun Microsystems, Inc. is the initial license steward and - may publish revised and/or new versions of this License - from time to time. Each version will be given a - distinguishing version number. Except as provided in - Section 4.3, no one other than the license steward has the - right to modify this License. - - 4.2. Effect of New Versions. - - You may always continue to use, distribute or otherwise - make the Covered Software available under the terms of the - version of the License under which You originally received - the Covered Software. If the Initial Developer includes a - notice in the Original Software prohibiting it from being - distributed or otherwise made available under any - subsequent version of the License, You must distribute and - make the Covered Software available under the terms of the - version of the License under which You originally received - the Covered Software. Otherwise, You may also choose to - use, distribute or otherwise make the Covered Software - available under the terms of any subsequent version of the - License published by the license steward. - - 4.3. Modified Versions. - - When You are an Initial Developer and You want to create a - new license for Your Original Software, You may create and - use a modified version of this License if You: (a) rename - the license and remove any references to the name of the - license steward (except to note that the license differs - from this License); and (b) otherwise make it clear that - the license contains terms which differ from this License. - - - 5. DISCLAIMER OF WARRANTY. - - COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" - BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, - INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED - SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR - PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND - PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY - COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE - INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF - ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF - WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF - ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS - DISCLAIMER. - - 6. TERMINATION. - - 6.1. This License and the rights granted hereunder will - terminate automatically if You fail to comply with terms - herein and fail to cure such breach within 30 days of - becoming aware of the breach. Provisions which, by their - nature, must remain in effect beyond the termination of - this License shall survive. - - 6.2. If You assert a patent infringement claim (excluding - declaratory judgment actions) against Initial Developer or - a Contributor (the Initial Developer or Contributor against - whom You assert such claim is referred to as "Participant") - alleging that the Participant Software (meaning the - Contributor Version where the Participant is a Contributor - or the Original Software where the Participant is the - Initial Developer) directly or indirectly infringes any - patent, then any and all rights granted directly or - indirectly to You by such Participant, the Initial - Developer (if the Initial Developer is not the Participant) - and all Contributors under Sections 2.1 and/or 2.2 of this - License shall, upon 60 days notice from Participant - terminate prospectively and automatically at the expiration - of such 60 day notice period, unless if within such 60 day - period You withdraw Your claim with respect to the - Participant Software against such Participant either - unilaterally or pursuant to a written agreement with - Participant. - - 6.3. In the event of termination under Sections 6.1 or 6.2 - above, all end user licenses that have been validly granted - by You or any distributor hereunder prior to termination - (excluding licenses granted to You by any distributor) - shall survive termination. - - 7. LIMITATION OF LIABILITY. - - UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT - (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE - INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF - COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE - LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR - CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT - LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK - STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER - COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN - INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF - LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL - INJURY RESULTING FROM SUCH PARTY"S NEGLIGENCE TO THE EXTENT - APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO - NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR - CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT - APPLY TO YOU. - - 8. U.S. GOVERNMENT END USERS. - - The Covered Software is a "commercial item," as that term is - defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial - computer software" (as that term is defined at 48 C.F.R. " - 252.227-7014(a)(1)) and "commercial computer software - documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. - 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 - through 227.7202-4 (June 1995), all U.S. Government End Users - acquire Covered Software with only those rights set forth herein. - This U.S. Government Rights clause is in lieu of, and supersedes, - any other FAR, DFAR, or other clause or provision that addresses - Government rights in computer software under this License. - - 9. MISCELLANEOUS. - - This License represents the complete agreement concerning subject - matter hereof. If any provision of this License is held to be - unenforceable, such provision shall be reformed only to the - extent necessary to make it enforceable. This License shall be - governed by the law of the jurisdiction specified in a notice - contained within the Original Software (except to the extent - applicable law, if any, provides otherwise), excluding such - jurisdiction"s conflict-of-law provisions. Any litigation - relating to this License shall be subject to the jurisdiction of - the courts located in the jurisdiction and venue specified in a - notice contained within the Original Software, with the losing - party responsible for costs, including, without limitation, court - costs and reasonable attorneys" fees and expenses. The - application of the United Nations Convention on Contracts for the - International Sale of Goods is expressly excluded. Any law or - regulation which provides that the language of a contract shall - be construed against the drafter shall not apply to this License. - You agree that You alone are responsible for compliance with the - United States export administration regulations (and the export - control laws and regulation of any other countries) when You use, - distribute or otherwise make available any Covered Software. - - 10. RESPONSIBILITY FOR CLAIMS. - - As between Initial Developer and the Contributors, each party is - responsible for claims and damages arising, directly or - indirectly, out of its utilization of rights under this License - and You agree to work with Initial Developer and Contributors to - distribute such responsibility on an equitable basis. Nothing - herein is intended or shall be deemed to constitute any admission - of liability. diff --git a/apache-maven/src/main/appended-resources/licenses/unrecognized-javax.annotation-api-1.2.txt b/apache-maven/src/main/appended-resources/licenses/unrecognized-javax.annotation-api-1.2.txt new file mode 100644 index 000000000000..b1c74f95ede8 --- /dev/null +++ b/apache-maven/src/main/appended-resources/licenses/unrecognized-javax.annotation-api-1.2.txt @@ -0,0 +1,759 @@ +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.1 + +1. Definitions. + + 1.1. "Contributor" means each individual or entity that creates or + contributes to the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the Original + Software, prior Modifications used by a Contributor (if any), and + the Modifications made by that particular Contributor. + + 1.3. "Covered Software" means (a) the Original Software, or (b) + Modifications, or (c) the combination of files containing Original + Software with files containing Modifications, in each case including + portions thereof. + + 1.4. "Executable" means the Covered Software in any form other than + Source Code. + + 1.5. "Initial Developer" means the individual or entity that first + makes Original Software available under this License. + + 1.6. "Larger Work" means a work which combines Covered Software or + portions thereof with code not governed by the terms of this License. + + 1.7. "License" means this document. + + 1.8. "Licensable" means having the right to grant, to the maximum + extent possible, whether at the time of the initial grant or + subsequently acquired, any and all of the rights conveyed herein. + + 1.9. "Modifications" means the Source Code and Executable form of + any of the following: + + A. Any file that results from an addition to, deletion from or + modification of the contents of a file containing Original Software + or previous Modifications; + + B. Any new file that contains any part of the Original Software or + previous Modification; or + + C. Any new file that is contributed or otherwise made available + under the terms of this License. + + 1.10. "Original Software" means the Source Code and Executable form + of computer software code that is originally released under this + License. + + 1.11. "Patent Claims" means any patent claim(s), now owned or + hereafter acquired, including without limitation, method, process, + and apparatus claims, in any patent Licensable by grantor. + + 1.12. "Source Code" means (a) the common form of computer software + code in which modifications are made and (b) associated + documentation included in or with such code. + + 1.13. "You" (or "Your") means an individual or a legal entity + exercising rights under, and complying with all of the terms of, + this License. For legal entities, "You" includes any entity which + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants. + + 2.1. The Initial Developer Grant. + + Conditioned upon Your compliance with Section 3.1 below and subject + to third party intellectual property claims, the Initial Developer + hereby grants You a world-wide, royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than patent or + trademark) Licensable by Initial Developer, to use, reproduce, + modify, display, perform, sublicense and distribute the Original + Software (or portions thereof), with or without Modifications, + and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, using or selling of + Original Software, to make, have made, use, practice, sell, and + offer for sale, and/or otherwise dispose of the Original Software + (or portions thereof). + + (c) The licenses granted in Sections 2.1(a) and (b) are effective on + the date Initial Developer first distributes or otherwise makes the + Original Software available to a third party under the terms of this + License. + + (d) Notwithstanding Section 2.1(b) above, no patent license is + granted: (1) for code that You delete from the Original Software, or + (2) for infringements caused by: (i) the modification of the + Original Software, or (ii) the combination of the Original Software + with other software or devices. + + 2.2. Contributor Grant. + + Conditioned upon Your compliance with Section 3.1 below and subject + to third party intellectual property claims, each Contributor hereby + grants You a world-wide, royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than patent or + trademark) Licensable by Contributor to use, reproduce, modify, + display, perform, sublicense and distribute the Modifications + created by such Contributor (or portions thereof), either on an + unmodified basis, with other Modifications, as Covered Software + and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, using, or selling + of Modifications made by that Contributor either alone and/or in + combination with its Contributor Version (or portions of such + combination), to make, use, sell, offer for sale, have made, and/or + otherwise dispose of: (1) Modifications made by that Contributor (or + portions thereof); and (2) the combination of Modifications made by + that Contributor with its Contributor Version (or portions of such + combination). + + (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective + on the date Contributor first distributes or otherwise makes the + Modifications available to a third party. + + (d) Notwithstanding Section 2.2(b) above, no patent license is + granted: (1) for any code that Contributor has deleted from the + Contributor Version; (2) for infringements caused by: (i) third + party modifications of Contributor Version, or (ii) the combination + of Modifications made by that Contributor with other software + (except as part of the Contributor Version) or other devices; or (3) + under Patent Claims infringed by Covered Software in the absence of + Modifications made by that Contributor. + +3. Distribution Obligations. + + 3.1. Availability of Source Code. + + Any Covered Software that You distribute or otherwise make available + in Executable form must also be made available in Source Code form + and that Source Code form must be distributed only under the terms + of this License. You must include a copy of this License with every + copy of the Source Code form of the Covered Software You distribute + or otherwise make available. You must inform recipients of any such + Covered Software in Executable form as to how they can obtain such + Covered Software in Source Code form in a reasonable manner on or + through a medium customarily used for software exchange. + + 3.2. Modifications. + + The Modifications that You create or to which You contribute are + governed by the terms of this License. You represent that You + believe Your Modifications are Your original creation(s) and/or You + have sufficient rights to grant the rights conveyed by this License. + + 3.3. Required Notices. + + You must include a notice in each of Your Modifications that + identifies You as the Contributor of the Modification. You may not + remove or alter any copyright, patent or trademark notices contained + within the Covered Software, or any notices of licensing or any + descriptive text giving attribution to any Contributor or the + Initial Developer. + + 3.4. Application of Additional Terms. + + You may not offer or impose any terms on any Covered Software in + Source Code form that alters or restricts the applicable version of + this License or the recipients' rights hereunder. You may choose to + offer, and to charge a fee for, warranty, support, indemnity or + liability obligations to one or more recipients of Covered Software. + However, you may do so only on Your own behalf, and not on behalf of + the Initial Developer or any Contributor. You must make it + absolutely clear that any such warranty, support, indemnity or + liability obligation is offered by You alone, and You hereby agree + to indemnify the Initial Developer and every Contributor for any + liability incurred by the Initial Developer or such Contributor as a + result of warranty, support, indemnity or liability terms You offer. + + 3.5. Distribution of Executable Versions. + + You may distribute the Executable form of the Covered Software under + the terms of this License or under the terms of a license of Your + choice, which may contain terms different from this License, + provided that You are in compliance with the terms of this License + and that the license for the Executable form does not attempt to + limit or alter the recipient's rights in the Source Code form from + the rights set forth in this License. If You distribute the Covered + Software in Executable form under a different license, You must make + it absolutely clear that any terms which differ from this License + are offered by You alone, not by the Initial Developer or + Contributor. You hereby agree to indemnify the Initial Developer and + every Contributor for any liability incurred by the Initial + Developer or such Contributor as a result of any such terms You offer. + + 3.6. Larger Works. + + You may create a Larger Work by combining Covered Software with + other code not governed by the terms of this License and distribute + the Larger Work as a single product. In such a case, You must make + sure the requirements of this License are fulfilled for the Covered + Software. + +4. Versions of the License. + + 4.1. New Versions. + + Oracle is the initial license steward and may publish revised and/or + new versions of this License from time to time. Each version will be + given a distinguishing version number. Except as provided in Section + 4.3, no one other than the license steward has the right to modify + this License. + + 4.2. Effect of New Versions. + + You may always continue to use, distribute or otherwise make the + Covered Software available under the terms of the version of the + License under which You originally received the Covered Software. If + the Initial Developer includes a notice in the Original Software + prohibiting it from being distributed or otherwise made available + under any subsequent version of the License, You must distribute and + make the Covered Software available under the terms of the version + of the License under which You originally received the Covered + Software. Otherwise, You may also choose to use, distribute or + otherwise make the Covered Software available under the terms of any + subsequent version of the License published by the license steward. + + 4.3. Modified Versions. + + When You are an Initial Developer and You want to create a new + license for Your Original Software, You may create and use a + modified version of this License if You: (a) rename the license and + remove any references to the name of the license steward (except to + note that the license differs from this License); and (b) otherwise + make it clear that the license contains terms which differ from this + License. + +5. DISCLAIMER OF WARRANTY. + + COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, + INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE + IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR + NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF + THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE + DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY + OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, + REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN + ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS + AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +6. TERMINATION. + + 6.1. This License and the rights granted hereunder will terminate + automatically if You fail to comply with terms herein and fail to + cure such breach within 30 days of becoming aware of the breach. + Provisions which, by their nature, must remain in effect beyond the + termination of this License shall survive. + + 6.2. If You assert a patent infringement claim (excluding + declaratory judgment actions) against Initial Developer or a + Contributor (the Initial Developer or Contributor against whom You + assert such claim is referred to as "Participant") alleging that the + Participant Software (meaning the Contributor Version where the + Participant is a Contributor or the Original Software where the + Participant is the Initial Developer) directly or indirectly + infringes any patent, then any and all rights granted directly or + indirectly to You by such Participant, the Initial Developer (if the + Initial Developer is not the Participant) and all Contributors under + Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice + from Participant terminate prospectively and automatically at the + expiration of such 60 day notice period, unless if within such 60 + day period You withdraw Your claim with respect to the Participant + Software against such Participant either unilaterally or pursuant to + a written agreement with Participant. + + 6.3. If You assert a patent infringement claim against Participant + alleging that the Participant Software directly or indirectly + infringes any patent where such claim is resolved (such as by + license or settlement) prior to the initiation of patent + infringement litigation, then the reasonable value of the licenses + granted by such Participant under Sections 2.1 or 2.2 shall be taken + into account in determining the amount or value of any payment or + license. + + 6.4. In the event of termination under Sections 6.1 or 6.2 above, + all end user licenses that have been validly granted by You or any + distributor hereunder prior to termination (excluding licenses + granted to You by any distributor) shall survive termination. + +7. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT + (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE + INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF + COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE + TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR + CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT + LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER + FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR + LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE + POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT + APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH + PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH + LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR + LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION + AND LIMITATION MAY NOT APPLY TO YOU. + +8. U.S. GOVERNMENT END USERS. + + The Covered Software is a "commercial item," as that term is defined + in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer + software" (as that term is defined at 48 C.F.R. § + 252.227-7014(a)(1)) and "commercial computer software documentation" + as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent + with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 + (June 1995), all U.S. Government End Users acquire Covered Software + with only those rights set forth herein. This U.S. Government Rights + clause is in lieu of, and supersedes, any other FAR, DFAR, or other + clause or provision that addresses Government rights in computer + software under this License. + +9. MISCELLANEOUS. + + This License represents the complete agreement concerning subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. This License shall be governed by + the law of the jurisdiction specified in a notice contained within + the Original Software (except to the extent applicable law, if any, + provides otherwise), excluding such jurisdiction's conflict-of-law + provisions. Any litigation relating to this License shall be subject + to the jurisdiction of the courts located in the jurisdiction and + venue specified in a notice contained within the Original Software, + with the losing party responsible for costs, including, without + limitation, court costs and reasonable attorneys' fees and expenses. + The application of the United Nations Convention on Contracts for + the International Sale of Goods is expressly excluded. Any law or + regulation which provides that the language of a contract shall be + construed against the drafter shall not apply to this License. You + agree that You alone are responsible for compliance with the United + States export administration regulations (and the export control + laws and regulation of any other countries) when You use, distribute + or otherwise make available any Covered Software. + +10. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or indirectly, + out of its utilization of rights under this License and You agree to + work with Initial Developer and Contributors to distribute such + responsibility on an equitable basis. Nothing herein is intended or + shall be deemed to constitute any admission of liability. + +------------------------------------------------------------------------ + +NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION +LICENSE (CDDL) + +The code released under the CDDL shall be governed by the laws of the +State of California (excluding conflict-of-law provisions). Any +litigation relating to this License shall be subject to the jurisdiction +of the Federal Courts of the Northern District of California and the +state courts of the State of California, with venue lying in Santa Clara +County, California. + + + + The GNU General Public License (GPL) Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor +Boston, MA 02110-1335 +USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to +share and change it. By contrast, the GNU General Public License is +intended to guarantee your freedom to share and change free software--to +make sure the software is free for all its users. This General Public +License applies to most of the Free Software Foundation's software and +to any other program whose authors commit to using it. (Some other Free +Software Foundation software is covered by the GNU Library General +Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. +Our General Public Licenses are designed to make sure that you have the +freedom to distribute copies of free software (and charge for this +service if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone +to deny you these rights or to ask you to surrender the rights. These +restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis +or for a fee, you must give the recipients all the rights that you have. +You must make sure that they, too, receive or can get the source code. +And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + +Finally, any free program is threatened constantly by software patents. +We wish to avoid the danger that redistributors of a free program will +individually obtain patent licenses, in effect making the program +proprietary. To prevent this, we have made it clear that any patent must +be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and +modification follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a +notice placed by the copyright holder saying it may be distributed under +the terms of this General Public License. The "Program", below, refers +to any such program or work, and a "work based on the Program" means +either the Program or any derivative work under copyright law: that is +to say, a work containing the Program or a portion of it, either +verbatim or with modifications and/or translated into another language. +(Hereinafter, translation is included without limitation in the term +"modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of running +the Program is not restricted, and the output from the Program is +covered only if its contents constitute a work based on the Program +(independent of having been made by running the Program). Whether that +is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source +code as you receive it, in any medium, provided that you conspicuously +and appropriately publish on each copy an appropriate copyright notice +and disclaimer of warranty; keep intact all the notices that refer to +this License and to the absence of any warranty; and give any other +recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of +it, thus forming a work based on the Program, and copy and distribute +such modifications or work under the terms of Section 1 above, provided +that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any part + thereof, to be licensed as a whole at no charge to all third parties + under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a notice + that there is no warranty (or else, saying that you provide a + warranty) and that users may redistribute the program under these + conditions, and telling the user how to view a copy of this License. + (Exception: if the Program itself is interactive but does not + normally print such an announcement, your work based on the Program + is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, and +can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based on +the Program, the distribution of the whole must be on the terms of this +License, whose permissions for other licensees extend to the entire +whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of a +storage or distribution medium does not bring the other work under the +scope of this License. + +3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections 1 + and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your cost + of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to + distribute corresponding source code. (This alternative is allowed + only for noncommercial distribution and only if you received the + program in object code or executable form with such an offer, in + accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source code +means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to control +compilation and installation of the executable. However, as a special +exception, the source code distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies the +executable. + +If distribution of executable or object code is made by offering access +to copy from a designated place, then offering equivalent access to copy +the source code from the same place counts as distribution of the source +code, even though third parties are not compelled to copy the source +along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt otherwise +to copy, modify, sublicense or distribute the Program is void, and will +automatically terminate your rights under this License. However, parties +who have received copies, or rights, from you under this License will +not have their licenses terminated so long as such parties remain in +full compliance. + +5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and all +its terms and conditions for copying, distributing or modifying the +Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further restrictions +on the recipients' exercise of the rights granted herein. You are not +responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot distribute +so as to satisfy simultaneously your obligations under this License and +any other pertinent obligations, then as a consequence you may not +distribute the Program at all. For example, if a patent license would +not permit royalty-free redistribution of the Program by all those who +receive copies directly or indirectly through you, then the only way you +could satisfy both it and this License would be to refrain entirely from +distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is implemented +by public license practices. Many people have made generous +contributions to the wide range of software distributed through that +system in reliance on consistent application of that system; it is up to +the author/donor to decide if he or she is willing to distribute +software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be +a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License may +add an explicit geographical distribution limitation excluding those +countries, so that distribution is permitted only in or among countries +not thus excluded. In such case, this License incorporates the +limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new +versions of the General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Program does not specify a version +number of this License, you may choose any version ever published by the +Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the +author to ask for permission. For software which is copyrighted by the +Free Software Foundation, write to the Free Software Foundation; we +sometimes make exceptions for this. Our decision will be guided by the +two goals of preserving the free status of all derivatives of our free +software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, +EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE +ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH +YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL +NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR +DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL +DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM +(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED +INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF +THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR +OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to +attach them to the start of each source file to most effectively convey +the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + One line to give the program's name and a brief idea of what it does. + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type + `show w'. This is free software, and you are welcome to redistribute + it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the +appropriate parts of the General Public License. Of course, the commands +you use may be called something other than `show w' and `show c'; they +could even be mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + program `Gnomovision' (which makes passes at compilers) written by + James Hacker. + + signature of Ty Coon, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications +with the library. If this is what you want to do, use the GNU Library +General Public License instead of this License. + +# + +Certain source files distributed by Oracle America, Inc. and/or its +affiliates are subject to the following clarification and special +exception to the GPLv2, based on the GNU Project exception for its +Classpath libraries, known as the GNU Classpath Exception, but only +where Oracle has expressly included in the particular source file's +header the words "Oracle designates this particular file as subject to +the "Classpath" exception as provided by Oracle in the LICENSE file +that accompanied this code." + +You should also note that Oracle includes multiple, independent +programs in this software package. Some of those programs are provided +under licenses deemed incompatible with the GPLv2 by the Free Software +Foundation and others. For example, the package includes programs +licensed under the Apache License, Version 2.0. Such programs are +licensed to you under their original licenses. + +Oracle facilitates your further distribution of this package by adding +the Classpath Exception to the necessary parts of its GPLv2 code, which +permits you to use that code in combination with other independent +modules not licensed under the GPLv2. However, note that this would +not permit you to commingle code under an incompatible license with +Oracle's GPLv2 licensed code by, for example, cutting and pasting such +code into a file also containing Oracle's GPLv2 licensed code and then +distributing the result. Additionally, if you were to remove the +Classpath Exception from any of the files to which it applies and +distribute the result, you would likely be required to license some or +all of the other code in that distribution under the GPLv2 as well, and +since the GPLv2 is incompatible with the license terms of some items +included in the distribution by Oracle, removing the Classpath +Exception could therefore effectively compromise your ability to +further distribute the package. + +Proceed with caution and we recommend that you obtain the advice of a +lawyer skilled in open source matters before removing the Classpath +Exception or making modifications to this package which may +subsequently be redistributed and/or involve the use of third party +software. + +CLASSPATH EXCEPTION +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License version 2 cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from or +based on this library. If you modify this library, you may extend this +exception to your version of the library, but you are not obligated to +do so. If you do not wish to do so, delete this exception statement +from your version. diff --git a/maven-core/src/main/resources/META-INF/maven/extension.xml b/maven-core/src/main/resources/META-INF/maven/extension.xml index 6bd836927364..1fa9d41750b6 100644 --- a/maven-core/src/main/resources/META-INF/maven/extension.xml +++ b/maven-core/src/main/resources/META-INF/maven/extension.xml @@ -166,7 +166,7 @@ under the License. org.apache.maven.resolver:maven-resolver-impl javax.inject:javax.inject - javax.annotation:jsr250-api + javax.annotation:javax.annotation-api org.slf4j:slf4j-api org.fusesource.jansi:jansi diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index fc90bbc13493..232bb9031048 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -116,7 +116,7 @@ under the License. javax.annotation - jsr250-api + javax.annotation-api org.codehaus.plexus diff --git a/pom.xml b/pom.xml index 40a7ee81ade0..9e68774899cc 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ under the License. 1.26 3.3.0 4.2.2 - 0.3.4 + 0.3.5 3.4.3 1.12.1 2.0 @@ -248,12 +248,12 @@ under the License. org.eclipse.sisu org.eclipse.sisu.plexus - ${sisuInjectVersion} + ${sisuVersion} org.eclipse.sisu org.eclipse.sisu.inject - ${sisuInjectVersion} + ${sisuVersion} javax.inject @@ -262,8 +262,8 @@ under the License. javax.annotation - jsr250-api - 1.0 + javax.annotation-api + 1.2 org.codehaus.plexus @@ -480,7 +480,7 @@ under the License. org.eclipse.sisu sisu-maven-plugin - ${sisuInjectVersion} + ${sisuVersion} @@ -545,10 +545,10 @@ under the License. src/test/remote-repo/** **/*.odg - src/main/appended-resources/licenses/CDDL-1.0.txt src/main/appended-resources/licenses/EPL-1.0.txt + src/main/appended-resources/licenses/unrecognized-javax.annotation-api-1.2.txt From 4e5b3d55545e5f03f05ac7b0cd1b56689df36201 Mon Sep 17 00:00:00 2001 From: Falko Modler Date: Sun, 22 Aug 2021 22:52:30 +0200 Subject: [PATCH 081/183] [MNG-7251] Fix threadLocalArtifactsHolder leaking into cloned project This closes #527 --- .../apache/maven/project/MavenProject.java | 49 ++++++++++--------- .../maven/project/MavenProjectTest.java | 43 ++++++++++++++++ 2 files changed, 68 insertions(+), 24 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java index 157b7a0f0a55..94d678814534 100644 --- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java +++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java @@ -143,13 +143,7 @@ public class MavenProject private Artifact artifact; - private final ThreadLocal threadLocalArtifactsHolder = new ThreadLocal() - { - protected ArtifactsHolder initialValue() - { - return new ArtifactsHolder(); - } - }; + private ThreadLocal threadLocalArtifactsHolder = newThreadLocalArtifactsHolder(); private Model originalModel; @@ -188,6 +182,17 @@ public MavenProject() setModel( model ); } + private static ThreadLocal newThreadLocalArtifactsHolder() + { + return new ThreadLocal() + { + protected ArtifactsHolder initialValue() + { + return new ArtifactsHolder(); + } + }; + } + public MavenProject( Model model ) { setModel( model ); @@ -1181,7 +1186,8 @@ public MavenProject clone() { throw new UnsupportedOperationException( e ); } - + // clone must have it's own TL, otherwise the artifacts are intermingled! + clone.threadLocalArtifactsHolder = newThreadLocalArtifactsHolder(); clone.deepCopy( this ); return clone; @@ -1224,6 +1230,7 @@ private void deepCopy( MavenProject project ) // copy fields file = project.file; basedir = project.basedir; + threadLocalArtifactsHolder.set( project.threadLocalArtifactsHolder.get().copy() ); // don't need a deep copy, they don't get modified or added/removed to/from - but make them unmodifiable to be // sure! @@ -1232,11 +1239,6 @@ private void deepCopy( MavenProject project ) setDependencyArtifacts( Collections.unmodifiableSet( project.getDependencyArtifacts() ) ); } - if ( project.getArtifacts() != null ) - { - setArtifacts( Collections.unmodifiableSet( project.getArtifacts() ) ); - } - if ( project.getParentFile() != null ) { parentFile = new File( project.getParentFile().getAbsolutePath() ); @@ -1479,13 +1481,7 @@ public void addLifecyclePhase( String lifecyclePhase ) // ---------------------------------------------------------------------------------------------------------------- // - // - // D E P R E C A T E D - // - // - // ---------------------------------------------------------------------------------------------------------------- - // - // Everything below will be removed for Maven 4.0.0 + // D E P R E C A T E D - Everything below will be removed for Maven 4.0.0 // // ---------------------------------------------------------------------------------------------------------------- @@ -1506,7 +1502,6 @@ public String getModulePathAdjustment( MavenProject moduleProject ) if ( moduleFile != null ) { File moduleDir = moduleFile.getCanonicalFile().getParentFile(); - module = moduleDir.getName(); } @@ -1827,7 +1822,6 @@ public Reporting getReporting() public void setReportArtifacts( Set reportArtifacts ) { this.reportArtifacts = reportArtifacts; - reportArtifactMap = null; } @@ -1851,7 +1845,6 @@ public Map getReportArtifactMap() public void setExtensionArtifacts( Set extensionArtifacts ) { this.extensionArtifacts = extensionArtifacts; - extensionArtifactMap = null; } @@ -1885,7 +1878,6 @@ public List getReportPlugins() public Xpp3Dom getReportConfiguration( String pluginGroupId, String pluginArtifactId, String reportSetId ) { Xpp3Dom dom = null; - // ---------------------------------------------------------------------- // I would like to be able to lookup the Mojo object using a key but // we have a limitation in modello that will be remedied shortly. So @@ -1995,5 +1987,14 @@ private static class ArtifactsHolder private ArtifactFilter artifactFilter; private Set artifacts; private Map artifactMap; + + ArtifactsHolder copy() + { + ArtifactsHolder copy = new ArtifactsHolder(); + copy.artifactFilter = artifactFilter; + copy.artifacts = artifacts != null ? new LinkedHashSet<>( artifacts ) : null; + copy.artifactMap = artifactMap != null ? new LinkedHashMap<>( artifactMap ) : null; + return copy; + } } } diff --git a/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java b/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java index 6b4258b3fde9..2344d8f77345 100644 --- a/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java @@ -21,13 +21,18 @@ import java.io.File; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicReference; +import org.apache.maven.artifact.Artifact; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.Profile; +import org.mockito.Mockito; public class MavenProjectTest extends AbstractMavenProjectTestCase @@ -188,6 +193,44 @@ public void testCloneWithBaseDir() assertEquals( "Base directory is preserved across clone", projectToClone.getBasedir(), clonedProject.getBasedir() ); } + public void testCloneWithArtifacts() + throws InterruptedException + { + Artifact initialArtifact = Mockito.mock( Artifact.class, "initialArtifact" ); + MavenProject originalProject = new MavenProject(); + originalProject.setArtifacts( Collections.singleton( initialArtifact ) ); + assertEquals( "Sanity check: originalProject returns artifact that has just been set", + Collections.singleton( initialArtifact ), originalProject.getArtifacts() ); + + final MavenProject clonedProject = originalProject.clone(); + + assertEquals( "Cloned project returns the artifact that was set for the original project", + Collections.singleton( initialArtifact ), clonedProject.getArtifacts() ); + + Artifact anotherArtifact = Mockito.mock( Artifact.class, "anotherArtifact" ); + clonedProject.setArtifacts( Collections.singleton( anotherArtifact ) ); + assertEquals( "Sanity check: clonedProject returns artifact that has just been set", + Collections.singleton( anotherArtifact ), clonedProject.getArtifacts() ); + + assertEquals( "Original project returns the artifact that was set initially (not the one for clonedProject)", + Collections.singleton( initialArtifact ), originalProject.getArtifacts() ); + + final AtomicReference> artifactsFromThread = new AtomicReference<>(); + Thread thread = new Thread( new Runnable() + { + @Override + public void run() + { + artifactsFromThread.set( clonedProject.getArtifacts() ); + } + } ); + thread.start(); + thread.join(); + + assertEquals( "Another thread does not see the same artifacts", + Collections.emptySet(), artifactsFromThread.get() ); + } + public void testUndefinedOutputDirectory() throws Exception { From 1ea42b0371f1bc99a4e0629c3734ad4ccfc0dcbd Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 11 Sep 2021 13:43:19 +0200 Subject: [PATCH 082/183] [MNG-7219] [Regression] plexus-cipher missing from transitive dependencies --- apache-maven/pom.xml | 4 ---- maven-compat/pom.xml | 5 ----- maven-core/pom.xml | 5 ----- 3 files changed, 14 deletions(-) diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index a4cf0396c61b..d98d4326f002 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -113,10 +113,6 @@ under the License. org.fusesource.jansi jansi - - org.codehaus.plexus - plexus-cipher - diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml index 06686b980a5d..46259815a4fe 100644 --- a/maven-compat/pom.xml +++ b/maven-compat/pom.xml @@ -99,11 +99,6 @@ under the License. wagon-provider-api - - org.codehaus.plexus - plexus-cipher - test - org.apache.maven.wagon wagon-file diff --git a/maven-core/pom.xml b/maven-core/pom.xml index 60b958f1f6fb..b3f048b3c07c 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -122,11 +122,6 @@ under the License. org.codehaus.plexus plexus-component-annotations - - org.codehaus.plexus - plexus-cipher - test - org.apache.commons commons-lang3 From 98a9d089bda8870fd658208d98bdc73a5f039b0f Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 9 Sep 2021 16:25:21 +0200 Subject: [PATCH 083/183] [MNG-7236] The DefaultPluginVersionResolver should cache results for the session --- .../DefaultPluginVersionResolver.java | 89 ++++++++++++++++++- 1 file changed, 85 insertions(+), 4 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java b/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java index 82e32fb310b3..2d2d1cba7b41 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java @@ -25,7 +25,10 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.TreeSet; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.Versioning; @@ -49,6 +52,7 @@ import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.SessionData; import org.eclipse.aether.metadata.DefaultMetadata; import org.eclipse.aether.repository.ArtifactRepository; import org.eclipse.aether.repository.RemoteRepository; @@ -72,6 +76,8 @@ public class DefaultPluginVersionResolver private static final String REPOSITORY_CONTEXT = "plugin"; + private static final Object CACHE_KEY = new Object(); + @Requirement private Logger logger; @@ -91,12 +97,26 @@ public PluginVersionResult resolve( PluginVersionRequest request ) if ( result == null ) { - result = resolveFromRepository( request ); + ConcurrentMap cache = getCache( request.getRepositorySession().getData() ); + Key key = getKey( request ); + result = cache.get( key ); - if ( logger.isDebugEnabled() ) + if ( result == null ) { - logger.debug( "Resolved plugin version for " + request.getGroupId() + ":" + request.getArtifactId() - + " to " + result.getVersion() + " from repository " + result.getRepository() ); + result = resolveFromRepository( request ); + + if ( logger.isDebugEnabled() ) + { + logger.debug( "Resolved plugin version for " + request.getGroupId() + ":" + request.getArtifactId() + + " to " + result.getVersion() + " from repository " + result.getRepository() ); + } + + cache.putIfAbsent( key, result ); + } + else if ( logger.isDebugEnabled() ) + { + logger.debug( "Reusing cached resolved plugin version for " + request.getGroupId() + ":" + + request.getArtifactId() + " to " + result.getVersion() + " from POM " + request.getPom() ); } } else if ( logger.isDebugEnabled() ) @@ -384,6 +404,67 @@ private PluginVersionResult resolveFromProject( PluginVersionRequest request, Li return null; } + @SuppressWarnings( "unchecked" ) + private ConcurrentMap getCache( SessionData data ) + { + ConcurrentMap cache = + ( ConcurrentMap ) data.get( CACHE_KEY ); + while ( cache == null ) + { + cache = new ConcurrentHashMap<>( 256 ); + if ( data.set( CACHE_KEY, null, cache ) ) + { + break; + } + cache = ( ConcurrentMap ) data.get( CACHE_KEY ); + } + return cache; + } + + private static Key getKey( PluginVersionRequest request ) + { + return new Key( request.getGroupId(), request.getArtifactId(), request.getRepositories() ); + } + + static class Key + { + final String groupId; + final String artifactId; + final List repositories; + final int hash; + + Key( String groupId, String artifactId, List repositories ) + { + this.groupId = groupId; + this.artifactId = artifactId; + this.repositories = repositories; + this.hash = Objects.hash( groupId, artifactId, repositories ); + } + + @Override + public boolean equals( Object o ) + { + if ( this == o ) + { + return true; + } + if ( o == null || getClass() != o.getClass() ) + { + return false; + } + Key key = ( Key ) o; + return groupId.equals( key.groupId ) + && artifactId.equals( key.artifactId ) + && repositories.equals( key.repositories ); + } + + @Override + public int hashCode() + { + return hash; + } + } + static class Versions { From 93f9e85955abb40bb090bad689f15fa9969ef9ba Mon Sep 17 00:00:00 2001 From: Romain Manni-Bucau Date: Thu, 3 Dec 2020 20:07:03 +0100 Subject: [PATCH 084/183] [MNG-7045] Drop CDI API from Maven This closes #540 --- maven-core/src/main/resources/META-INF/maven/extension.xml | 4 +++- pom.xml | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/maven-core/src/main/resources/META-INF/maven/extension.xml b/maven-core/src/main/resources/META-INF/maven/extension.xml index 1fa9d41750b6..73bee382de9c 100644 --- a/maven-core/src/main/resources/META-INF/maven/extension.xml +++ b/maven-core/src/main/resources/META-INF/maven/extension.xml @@ -94,9 +94,11 @@ under the License. javax.inject.* - + javax.annotation.* diff --git a/pom.xml b/pom.xml index 9e68774899cc..65f5d22411a2 100644 --- a/pom.xml +++ b/pom.xml @@ -249,6 +249,12 @@ under the License. org.eclipse.sisu org.eclipse.sisu.plexus ${sisuVersion} + + + javax.enterprise + cdi-api + + org.eclipse.sisu From d1aa1e1f0a891609256c60b2b7b5b8efaceea563 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Thu, 16 Sep 2021 10:08:23 +0200 Subject: [PATCH 085/183] [MNG-7252] Fix warnings issued by dependency:analyze This closes #541 --- maven-core/pom.xml | 8 ++++++++ maven-embedder/pom.xml | 1 + .../apache/maven/model/building/FileModelSourceTest.java | 4 ++-- maven-resolver-provider/pom.xml | 4 ---- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/maven-core/pom.xml b/maven-core/pom.xml index b3f048b3c07c..748ce6cd3960 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -118,6 +118,10 @@ under the License. org.codehaus.plexus plexus-classworlds + + org.codehaus.plexus + plexus-interpolation + org.codehaus.plexus plexus-component-annotations @@ -126,6 +130,10 @@ under the License. org.apache.commons commons-lang3 + + org.slf4j + slf4j-api + commons-jxpath commons-jxpath diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index 232bb9031048..7a3cc7e0d14a 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -114,6 +114,7 @@ under the License. javax.inject javax.inject + javax.annotation javax.annotation-api diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceTest.java index 9b0ecd9ddf57..6c8ebe0e4220 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceTest.java @@ -22,7 +22,7 @@ import java.io.IOException; import static junit.framework.TestCase.assertFalse; import static junit.framework.TestCase.assertTrue; -import org.apache.commons.lang3.SystemUtils; +import org.codehaus.plexus.util.Os;; import static org.junit.Assume.assumeTrue; import org.junit.Test; @@ -53,7 +53,7 @@ public void testEquals() public void testWindowsPaths() throws Exception { - assumeTrue( SystemUtils.IS_OS_WINDOWS ); + assumeTrue( Os.isFamily( "Windows" ) ); File upperCaseFile = createTempFile( "TESTE" ); String absolutePath = upperCaseFile.getAbsolutePath(); diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml index 70e0f4e5bc35..ca317a9edeca 100644 --- a/maven-resolver-provider/pom.xml +++ b/maven-resolver-provider/pom.xml @@ -108,10 +108,6 @@ under the License. mockito-core test - - org.slf4j - slf4j-api - org.slf4j slf4j-simple From 8c66edc0417f37540b3a6ef4b266ff88bdbd8327 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Thu, 16 Sep 2021 13:52:15 +0200 Subject: [PATCH 086/183] [MNG-7254] Expand Windows native libraries for Jansi due to JDK-8195129 (workaround) This closes #542 --- apache-maven/pom.xml | 16 ++++++++++++++++ apache-maven/src/bin/mvn | 1 + apache-maven/src/bin/mvn.cmd | 1 + apache-maven/src/lib/jansi-native/README.txt | 8 ++++++++ .../src/main/assembly/.component.xml.swp | Bin 0 -> 12288 bytes apache-maven/src/main/assembly/component.xml | 7 +++++++ 6 files changed, 33 insertions(+) create mode 100644 apache-maven/src/lib/jansi-native/README.txt create mode 100644 apache-maven/src/main/assembly/.component.xml.swp diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index d98d4326f002..b6068d0fc972 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -131,6 +131,22 @@ under the License. + + org.apache.maven.plugins + maven-dependency-plugin + + jansi + org/fusesource/jansi/internal/native/Windows/** + + + + unpack-jansi-native + + unpack-dependencies + + + + org.apache.maven.plugins maven-compiler-plugin diff --git a/apache-maven/src/bin/mvn b/apache-maven/src/bin/mvn index 29e0eabb837c..90f9a758d9cf 100755 --- a/apache-maven/src/bin/mvn +++ b/apache-maven/src/bin/mvn @@ -197,5 +197,6 @@ exec "$JAVACMD" \ -classpath "${CLASSWORLDS_JAR}" \ "-Dclassworlds.conf=${MAVEN_HOME}/bin/m2.conf" \ "-Dmaven.home=${MAVEN_HOME}" \ + "-Dlibrary.jansi.path=${MAVEN_HOME}/lib/jansi-native" \ "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ ${CLASSWORLDS_LAUNCHER} "$@" diff --git a/apache-maven/src/bin/mvn.cmd b/apache-maven/src/bin/mvn.cmd index fcb0f455a804..9fb4a98c7e24 100644 --- a/apache-maven/src/bin/mvn.cmd +++ b/apache-maven/src/bin/mvn.cmd @@ -174,6 +174,7 @@ set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher -classpath %CLASSWORLDS_JAR% ^ "-Dclassworlds.conf=%MAVEN_HOME%\bin\m2.conf" ^ "-Dmaven.home=%MAVEN_HOME%" ^ + "-Dlibrary.jansi.path=%MAVEN_HOME%\lib\jansi-native" ^ "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS% if ERRORLEVEL 1 goto error diff --git a/apache-maven/src/lib/jansi-native/README.txt b/apache-maven/src/lib/jansi-native/README.txt new file mode 100644 index 000000000000..26a957e1b564 --- /dev/null +++ b/apache-maven/src/lib/jansi-native/README.txt @@ -0,0 +1,8 @@ +This directory contains Jansi native libraries extracted from Jansi JAR. + +You can add your own build for platforms not natively supported by Jansi. +See here [1] on how to compile for your platform and and here [2] how libraries +follow Jansi's directory and filename conventions. + +[1] https://github.com/fusesource/jansi/tree/master/src/main/native +[2] https://github.com/fusesource/jansi/blob/321a8ff71c731e10f4ea05c607860180276b2215/src/main/java/org/fusesource/jansi/internal/OSInfo.java diff --git a/apache-maven/src/main/assembly/.component.xml.swp b/apache-maven/src/main/assembly/.component.xml.swp new file mode 100644 index 0000000000000000000000000000000000000000..52c487e4a78f44dad9a6220103ec18dab7e0e89c GIT binary patch literal 12288 zcmeI2Ux*t;9LJ|sYpb?O1w{mz#)@sd?B=c%+iN^X?{XNt>p#tp?;n+atIrV|a#CCfJl4>gbba*>_Y%xqgrOqiBu*)5js7nErf z)0S;d3MRDCZM%tQre9M9QUyj(AkdBM;hhTyC&qK3^@Eu`^zPjYBQ#7+QUy{4QUy{4 zQUy{4QUy{4QUy{4ZWINyw}m{1V7A5qHRI1MD?a05`jIM-Dv&CWDv&CWDv&CWDv&CW zDv&CWDv&CWD)2v4z;X!r34XsB{sI7h{~!GS|H_?&dC3Q@E!beJ0V|#3*cFB7VHQ2g00}k+X%S`UIEX5BVZT!V+SGM zf-k_Q;C*l&ya0S)g9Weye7T*F&%s;ZMG$}nI1L^Kzu!v8_uw;d5nKT0z#_S zWg8(sfUm&YKm!{T!9lPW+yj2Tg^*9cyWmyefv3PxFa{m~zugR7`z9zO{FPsEEuR3HB9!LM26tJNX%&_d<$e(r zGSFV2XSmO7E&bk<%jyQWQ|%?uTlDe+lYy?V z*ptoDT8k@+e@ar_vNWA8QPoqLwH383K|SVk>2TX}-5&J=0V75|UxrTmG@DI4Ez#c$ zs|U@sdQ8}?x;=1s7{jW}*SQ!q6OrjA6Oqu>k!sUAA29mqAH*2vCXoqPw4MK6+=G!Z z6h7(lfot#=ubsJQ3B|L*(tL@Hk~D4kO{PtUc}zG=*gZ3EZZdz@J&wARdK138+{RHk zrp$i3f7|;J=gC<3q4U==XRfDwWxiILF0L9yi7_^Z`<3cylZ__?1A}Dal^~8VI*^!E zEz4(4*7EHZMrPJ$N(R1-q?L=cLbgqn|_DL1W}2X=-CZYFU9YJePF?HQE2j+Ahv&oBgGFd%@2lqTbw^~NSaguo)&*blhGpxihUF?u9&6l*y3DVk!V19#(G7>+T60_| z%_#A%nAkTSp6kyaYlOAwfUlMy3a+d8q{0E*wlybhOute*mT772O`84lxkmqdu7Rk{ zLbX~fADcUqot`frpRW`vHFLtq89Dk-4Z6x1p5)CAPx5A?Mh0$XrbvERO>w|isLl7D z={KB2B*Vs?PRHmRjGUgpxn%Qnd9E4-ndL%hOV}(!!re%K#lw#_DRceV*dWSdHg9m7 zx|V1LR+G`DTw=b!hAQ0Nw7F6cNl{BU)a7liBheIjqEwj~ql{z6<5Sl4FjXijeahRO z%b8Z=ytVyO&rKM_y9xGH!)iHXiRC|1Wp+-*?PMj!IYNcY8&Yz&u^Oc!W ztu$XjX_gi$XNZyw-NEcc9j>&`>w#ttT@_HcSxXv70nf>Ta6|We_H=+9utV!TYI*R} zw(2fJo3I7Ux0KTITrk91#{2A?%8KioG*-uS%P(o}W?%v#)o(=}{m3)NX9y}xcR zdq9!`$Kk>`OnhgfBwLOH@uaX^IEk#cqai~eaa$sP*a!CWhl=>&eeH3SUaQ2w>937Z k&?Jr{N)NoJad_3ipqP~iJ?e+** + + target/dependency/org/fusesource/jansi/internal/native + lib/jansi-native + + ** + + src/bin bin From ab54d17dc2ec355c1e002e8751739edd9a96fcc3 Mon Sep 17 00:00:00 2001 From: George Gastaldi Date: Fri, 17 Sep 2021 12:18:27 -0300 Subject: [PATCH 087/183] [MNG-7253] Display relocation message defined in model Move logging to DefaultArtifactDescriptorReader This closes #544 --- .../DefaultProjectDependenciesResolver.java | 12 ------------ .../DefaultArtifactDescriptorReader.java | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java index 7500e43d2a38..3644b67ef408 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java @@ -181,18 +181,6 @@ public DependencyResolutionResult resolve( DependencyResolutionRequest request ) depRequest.setRoot( node ); - if ( logger.isWarnEnabled() ) - { - for ( DependencyNode child : node.getChildren() ) - { - if ( !child.getRelocations().isEmpty() ) - { - logger.warn( "The artifact " + child.getRelocations().get( 0 ) + " has been relocated to " - + child.getDependency().getArtifact() ); - } - } - } - if ( logger.isDebugEnabled() ) { node.accept( new GraphLogger( project ) ); diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java index c2ba0a3d729a..888f4581b460 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java @@ -68,6 +68,8 @@ import org.eclipse.aether.spi.locator.Service; import org.eclipse.aether.spi.locator.ServiceLocator; import org.eclipse.aether.transfer.ArtifactNotFoundException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Benjamin Bentmann @@ -77,6 +79,8 @@ public class DefaultArtifactDescriptorReader implements ArtifactDescriptorReader, Service { + private static final Logger LOGGER = LoggerFactory.getLogger( DefaultArtifactDescriptorReader.class ); + private RemoteRepositoryManager remoteRepositoryManager; private VersionResolver versionResolver; @@ -316,10 +320,20 @@ private Model loadPom( RepositorySystemSession session, ArtifactDescriptorReques if ( relocation != null ) { result.addRelocation( a ); - a = + Artifact relocatedArtifact = new RelocatedArtifact( a, relocation.getGroupId(), relocation.getArtifactId(), relocation.getVersion() ); - result.setArtifact( a ); + if ( LOGGER.isWarnEnabled() ) + { + String message = "The artifact " + a + " has been relocated to " + relocatedArtifact; + if ( relocation.getMessage() != null ) + { + message += ": " + relocation.getMessage(); + } + LOGGER.warn( message ); + } + result.setArtifact( relocatedArtifact ); + a = relocatedArtifact; } else { From 8882a9c599013182e42f0c7c321396c23b84dbe0 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 29 May 2021 09:31:49 -0400 Subject: [PATCH 088/183] [MNG-7164] Add constructor MojoExecutionException(Throwable) This closes #474 --- .../plugin/AbstractMojoExecutionException.java | 12 ++++++++++++ .../apache/maven/plugin/MojoExecutionException.java | 13 +++++++++++++ .../apache/maven/plugin/MojoFailureException.java | 13 +++++++++++++ 3 files changed, 38 insertions(+) diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojoExecutionException.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojoExecutionException.java index 52aded3d654d..e8df3095f212 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojoExecutionException.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojoExecutionException.java @@ -41,6 +41,18 @@ public AbstractMojoExecutionException( String message, Throwable cause ) super( message, cause ); } + /** + * Constructs a new {@code AbstractMojoExecutionException} exception wrapping an underlying {@code Throwable}. + * + * @param cause the cause which is saved for later retrieval by the {@link #getCause()} method. + * A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown. + * @since 3.8.3 + */ + public AbstractMojoExecutionException( Throwable cause ) + { + super( cause ); + } + public String getLongMessage() { return longMessage; diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoExecutionException.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoExecutionException.java index 4d8c416e077d..6d089898600c 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoExecutionException.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoExecutionException.java @@ -76,4 +76,17 @@ public MojoExecutionException( String message ) { super( message ); } + + /** + * Constructs a new {@code MojoExecutionException} exception wrapping an underlying {@code Throwable}. + * + * @param cause the cause which is saved for later retrieval by the {@link #getCause()} method. + * A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown. + * @since 3.8.3 + */ + public MojoExecutionException( Throwable cause ) + { + super( cause ); + } + } diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoFailureException.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoFailureException.java index 342d081f00b2..72faec679eb9 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoFailureException.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoFailureException.java @@ -65,4 +65,17 @@ public MojoFailureException( String message, Throwable cause ) { super( message, cause ); } + + /** + * Constructs a new {@code MojoFailureException} exception wrapping an underlying {@code Throwable}. + * + * @param cause the cause which is saved for later retrieval by the {@link #getCause()} method. + * A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown. + * @since 3.8.3 + */ + public MojoFailureException( Throwable cause ) + { + super( cause ); + } + } From 0a6bbb8301717d386e6588a7ea32e3e2451c7060 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 9 Sep 2021 16:10:25 +0200 Subject: [PATCH 089/183] [MNG-7235] Speed improvements when calculating the sorted project graph This closes #530 --- .../graph/DefaultProjectDependencyGraph.java | 49 ++++++++++++++++--- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/graph/DefaultProjectDependencyGraph.java b/maven-core/src/main/java/org/apache/maven/graph/DefaultProjectDependencyGraph.java index e0067f1fe4ae..7804312c9f90 100644 --- a/maven-core/src/main/java/org/apache/maven/graph/DefaultProjectDependencyGraph.java +++ b/maven-core/src/main/java/org/apache/maven/graph/DefaultProjectDependencyGraph.java @@ -22,8 +22,11 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Set; @@ -42,9 +45,13 @@ public class DefaultProjectDependencyGraph implements ProjectDependencyGraph { - private ProjectSorter sorter; + private final ProjectSorter sorter; - private List allProjects; + private final List allProjects; + + private final Map order; + + private final Map projects; /** * Creates a new project dependency graph based on the specified projects. @@ -59,6 +66,16 @@ public DefaultProjectDependencyGraph( Collection projects ) super(); this.allProjects = Collections.unmodifiableList( new ArrayList<>( projects ) ); this.sorter = new ProjectSorter( projects ); + List sorted = this.sorter.getSortedProjects(); + this.order = new HashMap<>( sorted.size() ); + this.projects = new HashMap<>( sorted.size() ); + int index = 0; + for ( MavenProject project : sorted ) + { + String id = ProjectSorter.getId( project ); + this.projects.put( id, project ); + this.order.put( project, index++ ); + } } /** @@ -78,6 +95,16 @@ public DefaultProjectDependencyGraph( final List allProjects, super(); this.allProjects = Collections.unmodifiableList( new ArrayList<>( allProjects ) ); this.sorter = new ProjectSorter( projects ); + List sorted = this.sorter.getSortedProjects(); + this.order = new HashMap<>( sorted.size() ); + this.projects = new HashMap<>( sorted.size() ); + int index = 0; + for ( MavenProject project : sorted ) + { + String id = ProjectSorter.getId( project ); + this.projects.put( id, project ); + this.order.put( project, index++ ); + } } /** @@ -140,15 +167,13 @@ private void getUpstreamProjects( String projectId, Collection projectId private List getSortedProjects( Set projectIds ) { List result = new ArrayList<>( projectIds.size() ); - - for ( MavenProject mavenProject : sorter.getSortedProjects() ) + for ( String projectId : projectIds ) { - if ( projectIds.contains( ProjectSorter.getId( mavenProject ) ) ) - { - result.add( mavenProject ); - } + result.add( projects.get( projectId ) ); } + Collections.sort( result, new MavenProjectComparator() ); + return result; } @@ -158,4 +183,12 @@ public String toString() return sorter.getSortedProjects().toString(); } + private class MavenProjectComparator implements Comparator + { + @Override + public int compare( MavenProject o1, MavenProject o2 ) + { + return order.get( o1 ) - order.get( o2 ); + } + } } From ff8e977a158738155dc465c6a97ffaf31982d739 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Mon, 27 Sep 2021 20:28:25 +0200 Subject: [PATCH 090/183] [maven-release-plugin] prepare release maven-3.8.3 --- apache-maven/pom.xml | 2 +- maven-artifact/pom.xml | 2 +- maven-builder-support/pom.xml | 2 +- maven-compat/pom.xml | 2 +- maven-core/pom.xml | 2 +- maven-embedder/pom.xml | 2 +- maven-model-builder/pom.xml | 2 +- maven-model/pom.xml | 2 +- maven-plugin-api/pom.xml | 2 +- maven-repository-metadata/pom.xml | 2 +- maven-resolver-provider/pom.xml | 2 +- maven-settings-builder/pom.xml | 2 +- maven-settings/pom.xml | 2 +- maven-slf4j-provider/pom.xml | 2 +- pom.xml | 6 +++--- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index b6068d0fc972..c17f8a6d5e6a 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3-SNAPSHOT + 3.8.3 apache-maven diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml index 5203f1b79592..6cf8468499a4 100644 --- a/maven-artifact/pom.xml +++ b/maven-artifact/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3-SNAPSHOT + 3.8.3 maven-artifact diff --git a/maven-builder-support/pom.xml b/maven-builder-support/pom.xml index 191bfc5967d0..959d8ec3fc84 100644 --- a/maven-builder-support/pom.xml +++ b/maven-builder-support/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3-SNAPSHOT + 3.8.3 maven-builder-support diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml index 46259815a4fe..75e2289d2f06 100644 --- a/maven-compat/pom.xml +++ b/maven-compat/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3-SNAPSHOT + 3.8.3 maven-compat diff --git a/maven-core/pom.xml b/maven-core/pom.xml index 748ce6cd3960..d4c5111666c3 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3-SNAPSHOT + 3.8.3 maven-core diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index 7a3cc7e0d14a..1c632c93f884 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3-SNAPSHOT + 3.8.3 maven-embedder diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml index 06d42d38e31b..8cb1008a6675 100644 --- a/maven-model-builder/pom.xml +++ b/maven-model-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3-SNAPSHOT + 3.8.3 maven-model-builder diff --git a/maven-model/pom.xml b/maven-model/pom.xml index 0e002c0c2f5e..df81d72f91c0 100644 --- a/maven-model/pom.xml +++ b/maven-model/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3-SNAPSHOT + 3.8.3 maven-model diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml index a0a708926b69..a1a72a1967b4 100644 --- a/maven-plugin-api/pom.xml +++ b/maven-plugin-api/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3-SNAPSHOT + 3.8.3 maven-plugin-api diff --git a/maven-repository-metadata/pom.xml b/maven-repository-metadata/pom.xml index b4ac0f489b00..4b4cc2b88999 100644 --- a/maven-repository-metadata/pom.xml +++ b/maven-repository-metadata/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3-SNAPSHOT + 3.8.3 maven-repository-metadata diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml index ca317a9edeca..52e94e5c3c7b 100644 --- a/maven-resolver-provider/pom.xml +++ b/maven-resolver-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3-SNAPSHOT + 3.8.3 maven-resolver-provider diff --git a/maven-settings-builder/pom.xml b/maven-settings-builder/pom.xml index dd0c09bb9ce8..677c13999c0c 100644 --- a/maven-settings-builder/pom.xml +++ b/maven-settings-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3-SNAPSHOT + 3.8.3 maven-settings-builder diff --git a/maven-settings/pom.xml b/maven-settings/pom.xml index 6fa967c38ca3..b77437c27c9a 100644 --- a/maven-settings/pom.xml +++ b/maven-settings/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3-SNAPSHOT + 3.8.3 maven-settings diff --git a/maven-slf4j-provider/pom.xml b/maven-slf4j-provider/pom.xml index 802d226c9c0a..eea89b72de1e 100644 --- a/maven-slf4j-provider/pom.xml +++ b/maven-slf4j-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3-SNAPSHOT + 3.8.3 maven-slf4j-provider diff --git a/pom.xml b/pom.xml index 65f5d22411a2..f584a2e60d55 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven - 3.8.3-SNAPSHOT + 3.8.3 pom Apache Maven @@ -77,7 +77,7 @@ under the License. ref/3-LATEST None **/package-info.java - 2021-08-04T19:03:41Z + 2021-09-27T18:25:22Z @@ -101,7 +101,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven.git scm:git:https://gitbox.apache.org/repos/asf/maven.git https://github.com/apache/maven/tree/${project.scm.tag} - maven-3.8.2 + maven-3.8.3 jira From 21e597ec777f0b74eed4e067b58b6eb8b0c9fad4 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Mon, 27 Sep 2021 20:28:37 +0200 Subject: [PATCH 091/183] [maven-release-plugin] prepare for next development iteration --- apache-maven/pom.xml | 2 +- maven-artifact/pom.xml | 2 +- maven-builder-support/pom.xml | 2 +- maven-compat/pom.xml | 2 +- maven-core/pom.xml | 2 +- maven-embedder/pom.xml | 2 +- maven-model-builder/pom.xml | 2 +- maven-model/pom.xml | 2 +- maven-plugin-api/pom.xml | 2 +- maven-repository-metadata/pom.xml | 2 +- maven-resolver-provider/pom.xml | 2 +- maven-settings-builder/pom.xml | 2 +- maven-settings/pom.xml | 2 +- maven-slf4j-provider/pom.xml | 2 +- pom.xml | 4 ++-- 15 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index c17f8a6d5e6a..5f713bb71c29 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3 + 3.8.4-SNAPSHOT apache-maven diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml index 6cf8468499a4..68af732ea550 100644 --- a/maven-artifact/pom.xml +++ b/maven-artifact/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3 + 3.8.4-SNAPSHOT maven-artifact diff --git a/maven-builder-support/pom.xml b/maven-builder-support/pom.xml index 959d8ec3fc84..897fe185f4bc 100644 --- a/maven-builder-support/pom.xml +++ b/maven-builder-support/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3 + 3.8.4-SNAPSHOT maven-builder-support diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml index 75e2289d2f06..221bf2c19ccd 100644 --- a/maven-compat/pom.xml +++ b/maven-compat/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3 + 3.8.4-SNAPSHOT maven-compat diff --git a/maven-core/pom.xml b/maven-core/pom.xml index d4c5111666c3..86aea1ff2319 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3 + 3.8.4-SNAPSHOT maven-core diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index 1c632c93f884..af2cd81ce593 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3 + 3.8.4-SNAPSHOT maven-embedder diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml index 8cb1008a6675..e08f1af28731 100644 --- a/maven-model-builder/pom.xml +++ b/maven-model-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3 + 3.8.4-SNAPSHOT maven-model-builder diff --git a/maven-model/pom.xml b/maven-model/pom.xml index df81d72f91c0..f7e07c866bac 100644 --- a/maven-model/pom.xml +++ b/maven-model/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3 + 3.8.4-SNAPSHOT maven-model diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml index a1a72a1967b4..630a46cf283b 100644 --- a/maven-plugin-api/pom.xml +++ b/maven-plugin-api/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3 + 3.8.4-SNAPSHOT maven-plugin-api diff --git a/maven-repository-metadata/pom.xml b/maven-repository-metadata/pom.xml index 4b4cc2b88999..0c9e5318dc62 100644 --- a/maven-repository-metadata/pom.xml +++ b/maven-repository-metadata/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3 + 3.8.4-SNAPSHOT maven-repository-metadata diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml index 52e94e5c3c7b..f941dd0e3577 100644 --- a/maven-resolver-provider/pom.xml +++ b/maven-resolver-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3 + 3.8.4-SNAPSHOT maven-resolver-provider diff --git a/maven-settings-builder/pom.xml b/maven-settings-builder/pom.xml index 677c13999c0c..2ffbd9457d8e 100644 --- a/maven-settings-builder/pom.xml +++ b/maven-settings-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3 + 3.8.4-SNAPSHOT maven-settings-builder diff --git a/maven-settings/pom.xml b/maven-settings/pom.xml index b77437c27c9a..c585d573387f 100644 --- a/maven-settings/pom.xml +++ b/maven-settings/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3 + 3.8.4-SNAPSHOT maven-settings diff --git a/maven-slf4j-provider/pom.xml b/maven-slf4j-provider/pom.xml index eea89b72de1e..e63956fcf359 100644 --- a/maven-slf4j-provider/pom.xml +++ b/maven-slf4j-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.3 + 3.8.4-SNAPSHOT maven-slf4j-provider diff --git a/pom.xml b/pom.xml index f584a2e60d55..a5848644d563 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven - 3.8.3 + 3.8.4-SNAPSHOT pom Apache Maven @@ -77,7 +77,7 @@ under the License. ref/3-LATEST None **/package-info.java - 2021-09-27T18:25:22Z + 2021-09-27T18:28:35Z From b6186e2c7714158b5a2709f4af9d40b194c53f55 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Mon, 27 Sep 2021 22:16:35 +0200 Subject: [PATCH 092/183] Remove swap file --- .../src/main/assembly/.component.xml.swp | Bin 12288 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 apache-maven/src/main/assembly/.component.xml.swp diff --git a/apache-maven/src/main/assembly/.component.xml.swp b/apache-maven/src/main/assembly/.component.xml.swp deleted file mode 100644 index 52c487e4a78f44dad9a6220103ec18dab7e0e89c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2Ux*t;9LJ|sYpb?O1w{mz#)@sd?B=c%+iN^X?{XNt>p#tp?;n+atIrV|a#CCfJl4>gbba*>_Y%xqgrOqiBu*)5js7nErf z)0S;d3MRDCZM%tQre9M9QUyj(AkdBM;hhTyC&qK3^@Eu`^zPjYBQ#7+QUy{4QUy{4 zQUy{4QUy{4QUy{4ZWINyw}m{1V7A5qHRI1MD?a05`jIM-Dv&CWDv&CWDv&CWDv&CW zDv&CWDv&CWD)2v4z;X!r34XsB{sI7h{~!GS|H_?&dC3Q@E!beJ0V|#3*cFB7VHQ2g00}k+X%S`UIEX5BVZT!V+SGM zf-k_Q;C*l&ya0S)g9Weye7T*F&%s;ZMG$}nI1L^Kzu!v8_uw;d5nKT0z#_S zWg8(sfUm&YKm!{T!9lPW+yj2Tg^*9cyWmyefv3PxFa{m~zugR7`z9zO{FPsEEuR3HB9!LM26tJNX%&_d<$e(r zGSFV2XSmO7E&bk<%jyQWQ|%?uTlDe+lYy?V z*ptoDT8k@+e@ar_vNWA8QPoqLwH383K|SVk>2TX}-5&J=0V75|UxrTmG@DI4Ez#c$ zs|U@sdQ8}?x;=1s7{jW}*SQ!q6OrjA6Oqu>k!sUAA29mqAH*2vCXoqPw4MK6+=G!Z z6h7(lfot#=ubsJQ3B|L*(tL@Hk~D4kO{PtUc}zG=*gZ3EZZdz@J&wARdK138+{RHk zrp$i3f7|;J=gC<3q4U==XRfDwWxiILF0L9yi7_^Z`<3cylZ__?1A}Dal^~8VI*^!E zEz4(4*7EHZMrPJ$N(R1-q?L=cLbgqn|_DL1W}2X=-CZYFU9YJePF?HQE2j+Ahv&oBgGFd%@2lqTbw^~NSaguo)&*blhGpxihUF?u9&6l*y3DVk!V19#(G7>+T60_| z%_#A%nAkTSp6kyaYlOAwfUlMy3a+d8q{0E*wlybhOute*mT772O`84lxkmqdu7Rk{ zLbX~fADcUqot`frpRW`vHFLtq89Dk-4Z6x1p5)CAPx5A?Mh0$XrbvERO>w|isLl7D z={KB2B*Vs?PRHmRjGUgpxn%Qnd9E4-ndL%hOV}(!!re%K#lw#_DRceV*dWSdHg9m7 zx|V1LR+G`DTw=b!hAQ0Nw7F6cNl{BU)a7liBheIjqEwj~ql{z6<5Sl4FjXijeahRO z%b8Z=ytVyO&rKM_y9xGH!)iHXiRC|1Wp+-*?PMj!IYNcY8&Yz&u^Oc!W ztu$XjX_gi$XNZyw-NEcc9j>&`>w#ttT@_HcSxXv70nf>Ta6|We_H=+9utV!TYI*R} zw(2fJo3I7Ux0KTITrk91#{2A?%8KioG*-uS%P(o}W?%v#)o(=}{m3)NX9y}xcR zdq9!`$Kk>`OnhgfBwLOH@uaX^IEk#cqai~eaa$sP*a!CWhl=>&eeH3SUaQ2w>937Z k&?Jr{N)NoJad_3ipqP~iJ?e+ Date: Wed, 29 Sep 2021 11:29:35 +0100 Subject: [PATCH 093/183] [MNG-7270] Switch to shell alternative to "which" In some circumstances the init script calls `which`, which may or may not be available on the host system. Instead, use `command -v`, which is nearly equivalent. One area it differs is if the command being queried is defined as a shell alias. To avoid that, call `unset -f command` to avoid the situation where "command" has been re-defined as a shell function. See here for more information on this approach: Tested with bash, sh (bash invoked as sh), posh, dash, zsh and mksh. This closes #556 --- apache-maven/src/bin/mvn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apache-maven/src/bin/mvn b/apache-maven/src/bin/mvn index 90f9a758d9cf..dfa384b8e141 100755 --- a/apache-maven/src/bin/mvn +++ b/apache-maven/src/bin/mvn @@ -94,7 +94,7 @@ if $mingw ; then fi if [ -z "$JAVA_HOME" ] ; then - JAVACMD=`which java` + JAVACMD="`\\unset -f command; \\command -v java`" else JAVACMD="$JAVA_HOME/bin/java" fi From 5c36bf5ef78a162cefea47ccdaf0d28e01c1426c Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 16 Oct 2021 15:21:28 +0200 Subject: [PATCH 094/183] [MNG-7312] Revert ThreadLocal approach from MNG-6843 and MNG-7251 Revert "[MNG-7251] Fix threadLocalArtifactsHolder leaking into cloned project" This reverts commit 4e5b3d55545e5f03f05ac7b0cd1b56689df36201. Revert "[MNG-6843] Parallel build fails due to missing JAR artifacts in compilePath" This reverts commit 76d5f0d942f52650d3bdf775b6af42d23d69066b. === This closes #595 --- .../apache/maven/project/MavenProject.java | 102 +++++++++--------- .../maven/project/MavenProjectTest.java | 43 -------- 2 files changed, 48 insertions(+), 97 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java index 94d678814534..db0f4a90116f 100644 --- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java +++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java @@ -92,9 +92,13 @@ public class MavenProject implements Cloneable { + private static final Logger LOGGER = LoggerFactory.getLogger( MavenProject.class ); + public static final String EMPTY_PROJECT_GROUP_ID = "unknown"; + public static final String EMPTY_PROJECT_ARTIFACT_ID = "empty-project"; + public static final String EMPTY_PROJECT_VERSION = "0"; private Model model; @@ -107,6 +111,10 @@ public class MavenProject private Set resolvedArtifacts; + private ArtifactFilter artifactFilter; + + private Set artifacts; + private Artifact parentArtifact; private Set pluginArtifacts; @@ -143,7 +151,8 @@ public class MavenProject private Artifact artifact; - private ThreadLocal threadLocalArtifactsHolder = newThreadLocalArtifactsHolder(); + // calculated. + private Map artifactMap; private Model originalModel; @@ -176,21 +185,12 @@ public class MavenProject public MavenProject() { Model model = new Model(); + model.setGroupId( EMPTY_PROJECT_GROUP_ID ); model.setArtifactId( EMPTY_PROJECT_ARTIFACT_ID ); model.setVersion( EMPTY_PROJECT_VERSION ); - setModel( model ); - } - private static ThreadLocal newThreadLocalArtifactsHolder() - { - return new ThreadLocal() - { - protected ArtifactsHolder initialValue() - { - return new ArtifactsHolder(); - } - }; + setModel( model ); } public MavenProject( Model model ) @@ -695,11 +695,10 @@ public void addLicense( License license ) public void setArtifacts( Set artifacts ) { - ArtifactsHolder artifactsHolder = threadLocalArtifactsHolder.get(); - artifactsHolder.artifacts = artifacts; + this.artifacts = artifacts; // flush the calculated artifactMap - artifactsHolder.artifactMap = null; + artifactMap = null; } /** @@ -712,36 +711,34 @@ public void setArtifacts( Set artifacts ) */ public Set getArtifacts() { - ArtifactsHolder artifactsHolder = threadLocalArtifactsHolder.get(); - if ( artifactsHolder.artifacts == null ) + if ( artifacts == null ) { - if ( artifactsHolder.artifactFilter == null || resolvedArtifacts == null ) + if ( artifactFilter == null || resolvedArtifacts == null ) { - artifactsHolder.artifacts = new LinkedHashSet<>(); + artifacts = new LinkedHashSet<>(); } else { - artifactsHolder.artifacts = new LinkedHashSet<>( resolvedArtifacts.size() * 2 ); + artifacts = new LinkedHashSet<>( resolvedArtifacts.size() * 2 ); for ( Artifact artifact : resolvedArtifacts ) { - if ( artifactsHolder.artifactFilter.include( artifact ) ) + if ( artifactFilter.include( artifact ) ) { - artifactsHolder.artifacts.add( artifact ); + artifacts.add( artifact ); } } } } - return artifactsHolder.artifacts; + return artifacts; } public Map getArtifactMap() { - ArtifactsHolder artifactsHolder = threadLocalArtifactsHolder.get(); - if ( artifactsHolder.artifactMap == null ) + if ( artifactMap == null ) { - artifactsHolder.artifactMap = ArtifactUtils.artifactMapByVersionlessId( getArtifacts() ); + artifactMap = ArtifactUtils.artifactMapByVersionlessId( getArtifacts() ); } - return artifactsHolder.artifactMap; + return artifactMap; } public void setPluginArtifacts( Set pluginArtifacts ) @@ -1186,8 +1183,7 @@ public MavenProject clone() { throw new UnsupportedOperationException( e ); } - // clone must have it's own TL, otherwise the artifacts are intermingled! - clone.threadLocalArtifactsHolder = newThreadLocalArtifactsHolder(); + clone.deepCopy( this ); return clone; @@ -1230,7 +1226,6 @@ private void deepCopy( MavenProject project ) // copy fields file = project.file; basedir = project.basedir; - threadLocalArtifactsHolder.set( project.threadLocalArtifactsHolder.get().copy() ); // don't need a deep copy, they don't get modified or added/removed to/from - but make them unmodifiable to be // sure! @@ -1239,6 +1234,11 @@ private void deepCopy( MavenProject project ) setDependencyArtifacts( Collections.unmodifiableSet( project.getDependencyArtifacts() ) ); } + if ( project.getArtifacts() != null ) + { + setArtifacts( Collections.unmodifiableSet( project.getArtifacts() ) ); + } + if ( project.getParentFile() != null ) { parentFile = new File( project.getParentFile().getAbsolutePath() ); @@ -1433,9 +1433,8 @@ public DependencyFilter getExtensionDependencyFilter() public void setResolvedArtifacts( Set artifacts ) { this.resolvedArtifacts = ( artifacts != null ) ? artifacts : Collections.emptySet(); - ArtifactsHolder artifactsHolder = threadLocalArtifactsHolder.get(); - artifactsHolder.artifacts = null; - artifactsHolder.artifactMap = null; + this.artifacts = null; + this.artifactMap = null; } /** @@ -1448,10 +1447,9 @@ public void setResolvedArtifacts( Set artifacts ) */ public void setArtifactFilter( ArtifactFilter artifactFilter ) { - ArtifactsHolder artifactsHolder = threadLocalArtifactsHolder.get(); - artifactsHolder.artifactFilter = artifactFilter; - artifactsHolder.artifacts = null; - artifactsHolder.artifactMap = null; + this.artifactFilter = artifactFilter; + this.artifacts = null; + this.artifactMap = null; } /** @@ -1481,7 +1479,13 @@ public void addLifecyclePhase( String lifecyclePhase ) // ---------------------------------------------------------------------------------------------------------------- // - // D E P R E C A T E D - Everything below will be removed for Maven 4.0.0 + // + // D E P R E C A T E D + // + // + // ---------------------------------------------------------------------------------------------------------------- + // + // Everything below will be removed for Maven 4.0.0 // // ---------------------------------------------------------------------------------------------------------------- @@ -1502,6 +1506,7 @@ public String getModulePathAdjustment( MavenProject moduleProject ) if ( moduleFile != null ) { File moduleDir = moduleFile.getCanonicalFile().getParentFile(); + module = moduleDir.getName(); } @@ -1822,6 +1827,7 @@ public Reporting getReporting() public void setReportArtifacts( Set reportArtifacts ) { this.reportArtifacts = reportArtifacts; + reportArtifactMap = null; } @@ -1838,6 +1844,7 @@ public Map getReportArtifactMap() { reportArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getReportArtifacts() ); } + return reportArtifactMap; } @@ -1845,6 +1852,7 @@ public Map getReportArtifactMap() public void setExtensionArtifacts( Set extensionArtifacts ) { this.extensionArtifacts = extensionArtifacts; + extensionArtifactMap = null; } @@ -1861,6 +1869,7 @@ public Map getExtensionArtifactMap() { extensionArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getExtensionArtifacts() ); } + return extensionArtifactMap; } @@ -1878,6 +1887,7 @@ public List getReportPlugins() public Xpp3Dom getReportConfiguration( String pluginGroupId, String pluginArtifactId, String reportSetId ) { Xpp3Dom dom = null; + // ---------------------------------------------------------------------- // I would like to be able to lookup the Mojo object using a key but // we have a limitation in modello that will be remedied shortly. So @@ -1981,20 +1991,4 @@ public void setProjectBuildingRequest( ProjectBuildingRequest projectBuildingReq { this.projectBuilderConfiguration = projectBuildingRequest; } - - private static class ArtifactsHolder - { - private ArtifactFilter artifactFilter; - private Set artifacts; - private Map artifactMap; - - ArtifactsHolder copy() - { - ArtifactsHolder copy = new ArtifactsHolder(); - copy.artifactFilter = artifactFilter; - copy.artifacts = artifacts != null ? new LinkedHashSet<>( artifacts ) : null; - copy.artifactMap = artifactMap != null ? new LinkedHashMap<>( artifactMap ) : null; - return copy; - } - } } diff --git a/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java b/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java index 2344d8f77345..6b4258b3fde9 100644 --- a/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java @@ -21,18 +21,13 @@ import java.io.File; import java.io.IOException; -import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; -import org.apache.maven.artifact.Artifact; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.Profile; -import org.mockito.Mockito; public class MavenProjectTest extends AbstractMavenProjectTestCase @@ -193,44 +188,6 @@ public void testCloneWithBaseDir() assertEquals( "Base directory is preserved across clone", projectToClone.getBasedir(), clonedProject.getBasedir() ); } - public void testCloneWithArtifacts() - throws InterruptedException - { - Artifact initialArtifact = Mockito.mock( Artifact.class, "initialArtifact" ); - MavenProject originalProject = new MavenProject(); - originalProject.setArtifacts( Collections.singleton( initialArtifact ) ); - assertEquals( "Sanity check: originalProject returns artifact that has just been set", - Collections.singleton( initialArtifact ), originalProject.getArtifacts() ); - - final MavenProject clonedProject = originalProject.clone(); - - assertEquals( "Cloned project returns the artifact that was set for the original project", - Collections.singleton( initialArtifact ), clonedProject.getArtifacts() ); - - Artifact anotherArtifact = Mockito.mock( Artifact.class, "anotherArtifact" ); - clonedProject.setArtifacts( Collections.singleton( anotherArtifact ) ); - assertEquals( "Sanity check: clonedProject returns artifact that has just been set", - Collections.singleton( anotherArtifact ), clonedProject.getArtifacts() ); - - assertEquals( "Original project returns the artifact that was set initially (not the one for clonedProject)", - Collections.singleton( initialArtifact ), originalProject.getArtifacts() ); - - final AtomicReference> artifactsFromThread = new AtomicReference<>(); - Thread thread = new Thread( new Runnable() - { - @Override - public void run() - { - artifactsFromThread.set( clonedProject.getArtifacts() ); - } - } ); - thread.start(); - thread.join(); - - assertEquals( "Another thread does not see the same artifacts", - Collections.emptySet(), artifactsFromThread.get() ); - } - public void testUndefinedOutputDirectory() throws Exception { From 19c3b917b3604f93fef0583a08e70f8695d3a359 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 12 Nov 2021 18:58:57 +0100 Subject: [PATCH 095/183] [MNG-7331] Upgrade Jansi to 2.4.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a5848644d563..02b9cc95604b 100644 --- a/pom.xml +++ b/pom.xml @@ -300,7 +300,7 @@ under the License. org.fusesource.jansi jansi - 2.3.4 + 2.4.0 org.slf4j From 9b656c72d54e5bacbed989b64718c159fe39b537 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 14 Nov 2021 10:14:42 +0100 Subject: [PATCH 096/183] [maven-release-plugin] prepare release maven-3.8.4 --- apache-maven/pom.xml | 2 +- maven-artifact/pom.xml | 2 +- maven-builder-support/pom.xml | 2 +- maven-compat/pom.xml | 2 +- maven-core/pom.xml | 2 +- maven-embedder/pom.xml | 2 +- maven-model-builder/pom.xml | 2 +- maven-model/pom.xml | 2 +- maven-plugin-api/pom.xml | 2 +- maven-repository-metadata/pom.xml | 2 +- maven-resolver-provider/pom.xml | 2 +- maven-settings-builder/pom.xml | 2 +- maven-settings/pom.xml | 2 +- maven-slf4j-provider/pom.xml | 2 +- pom.xml | 6 +++--- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index 5f713bb71c29..1c979bce60d0 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4-SNAPSHOT + 3.8.4 apache-maven diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml index 68af732ea550..2ddb8c761aa3 100644 --- a/maven-artifact/pom.xml +++ b/maven-artifact/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4-SNAPSHOT + 3.8.4 maven-artifact diff --git a/maven-builder-support/pom.xml b/maven-builder-support/pom.xml index 897fe185f4bc..d33e3b1e9eda 100644 --- a/maven-builder-support/pom.xml +++ b/maven-builder-support/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4-SNAPSHOT + 3.8.4 maven-builder-support diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml index 221bf2c19ccd..d95264559ccf 100644 --- a/maven-compat/pom.xml +++ b/maven-compat/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4-SNAPSHOT + 3.8.4 maven-compat diff --git a/maven-core/pom.xml b/maven-core/pom.xml index 86aea1ff2319..32fb86fb8313 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4-SNAPSHOT + 3.8.4 maven-core diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index af2cd81ce593..f732b8957d40 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4-SNAPSHOT + 3.8.4 maven-embedder diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml index e08f1af28731..485553de88c8 100644 --- a/maven-model-builder/pom.xml +++ b/maven-model-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4-SNAPSHOT + 3.8.4 maven-model-builder diff --git a/maven-model/pom.xml b/maven-model/pom.xml index f7e07c866bac..007ecbcdaf65 100644 --- a/maven-model/pom.xml +++ b/maven-model/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4-SNAPSHOT + 3.8.4 maven-model diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml index 630a46cf283b..0c399f4a83c0 100644 --- a/maven-plugin-api/pom.xml +++ b/maven-plugin-api/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4-SNAPSHOT + 3.8.4 maven-plugin-api diff --git a/maven-repository-metadata/pom.xml b/maven-repository-metadata/pom.xml index 0c9e5318dc62..9caa582bc7d7 100644 --- a/maven-repository-metadata/pom.xml +++ b/maven-repository-metadata/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4-SNAPSHOT + 3.8.4 maven-repository-metadata diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml index f941dd0e3577..cb3c950035a1 100644 --- a/maven-resolver-provider/pom.xml +++ b/maven-resolver-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4-SNAPSHOT + 3.8.4 maven-resolver-provider diff --git a/maven-settings-builder/pom.xml b/maven-settings-builder/pom.xml index 2ffbd9457d8e..3a53bd97cb40 100644 --- a/maven-settings-builder/pom.xml +++ b/maven-settings-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4-SNAPSHOT + 3.8.4 maven-settings-builder diff --git a/maven-settings/pom.xml b/maven-settings/pom.xml index c585d573387f..b2e5ef895f5e 100644 --- a/maven-settings/pom.xml +++ b/maven-settings/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4-SNAPSHOT + 3.8.4 maven-settings diff --git a/maven-slf4j-provider/pom.xml b/maven-slf4j-provider/pom.xml index e63956fcf359..e848870a9c8b 100644 --- a/maven-slf4j-provider/pom.xml +++ b/maven-slf4j-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4-SNAPSHOT + 3.8.4 maven-slf4j-provider diff --git a/pom.xml b/pom.xml index 02b9cc95604b..e739a027b0d9 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven - 3.8.4-SNAPSHOT + 3.8.4 pom Apache Maven @@ -77,7 +77,7 @@ under the License. ref/3-LATEST None **/package-info.java - 2021-09-27T18:28:35Z + 2021-11-14T09:12:47Z @@ -101,7 +101,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven.git scm:git:https://gitbox.apache.org/repos/asf/maven.git https://github.com/apache/maven/tree/${project.scm.tag} - maven-3.8.3 + maven-3.8.4 jira From 8af0a674db7cf1199d62e1cba60e29f84a144129 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 14 Nov 2021 10:14:54 +0100 Subject: [PATCH 097/183] [maven-release-plugin] prepare for next development iteration --- apache-maven/pom.xml | 2 +- maven-artifact/pom.xml | 2 +- maven-builder-support/pom.xml | 2 +- maven-compat/pom.xml | 2 +- maven-core/pom.xml | 2 +- maven-embedder/pom.xml | 2 +- maven-model-builder/pom.xml | 2 +- maven-model/pom.xml | 2 +- maven-plugin-api/pom.xml | 2 +- maven-repository-metadata/pom.xml | 2 +- maven-resolver-provider/pom.xml | 2 +- maven-settings-builder/pom.xml | 2 +- maven-settings/pom.xml | 2 +- maven-slf4j-provider/pom.xml | 2 +- pom.xml | 6 +++--- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index 1c979bce60d0..6e12bb0e4d4c 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4 + 3.8.5-SNAPSHOT apache-maven diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml index 2ddb8c761aa3..0ced0ebe53f0 100644 --- a/maven-artifact/pom.xml +++ b/maven-artifact/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4 + 3.8.5-SNAPSHOT maven-artifact diff --git a/maven-builder-support/pom.xml b/maven-builder-support/pom.xml index d33e3b1e9eda..9851384a8034 100644 --- a/maven-builder-support/pom.xml +++ b/maven-builder-support/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4 + 3.8.5-SNAPSHOT maven-builder-support diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml index d95264559ccf..c3715e6298be 100644 --- a/maven-compat/pom.xml +++ b/maven-compat/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4 + 3.8.5-SNAPSHOT maven-compat diff --git a/maven-core/pom.xml b/maven-core/pom.xml index 32fb86fb8313..ab8c71379277 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4 + 3.8.5-SNAPSHOT maven-core diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index f732b8957d40..c180c865ea66 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4 + 3.8.5-SNAPSHOT maven-embedder diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml index 485553de88c8..bf0b0f9f256a 100644 --- a/maven-model-builder/pom.xml +++ b/maven-model-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4 + 3.8.5-SNAPSHOT maven-model-builder diff --git a/maven-model/pom.xml b/maven-model/pom.xml index 007ecbcdaf65..db70815c092a 100644 --- a/maven-model/pom.xml +++ b/maven-model/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4 + 3.8.5-SNAPSHOT maven-model diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml index 0c399f4a83c0..ab836127524a 100644 --- a/maven-plugin-api/pom.xml +++ b/maven-plugin-api/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4 + 3.8.5-SNAPSHOT maven-plugin-api diff --git a/maven-repository-metadata/pom.xml b/maven-repository-metadata/pom.xml index 9caa582bc7d7..31c0418b0c98 100644 --- a/maven-repository-metadata/pom.xml +++ b/maven-repository-metadata/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4 + 3.8.5-SNAPSHOT maven-repository-metadata diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml index cb3c950035a1..62ff3f26c60c 100644 --- a/maven-resolver-provider/pom.xml +++ b/maven-resolver-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4 + 3.8.5-SNAPSHOT maven-resolver-provider diff --git a/maven-settings-builder/pom.xml b/maven-settings-builder/pom.xml index 3a53bd97cb40..6391cf223fd1 100644 --- a/maven-settings-builder/pom.xml +++ b/maven-settings-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4 + 3.8.5-SNAPSHOT maven-settings-builder diff --git a/maven-settings/pom.xml b/maven-settings/pom.xml index b2e5ef895f5e..36dd1923ab1f 100644 --- a/maven-settings/pom.xml +++ b/maven-settings/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4 + 3.8.5-SNAPSHOT maven-settings diff --git a/maven-slf4j-provider/pom.xml b/maven-slf4j-provider/pom.xml index e848870a9c8b..d12d0aedffba 100644 --- a/maven-slf4j-provider/pom.xml +++ b/maven-slf4j-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.4 + 3.8.5-SNAPSHOT maven-slf4j-provider diff --git a/pom.xml b/pom.xml index e739a027b0d9..5704043efefe 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven - 3.8.4 + 3.8.5-SNAPSHOT pom Apache Maven @@ -77,7 +77,7 @@ under the License. ref/3-LATEST None **/package-info.java - 2021-11-14T09:12:47Z + 2021-11-14T09:14:52Z @@ -101,7 +101,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven.git scm:git:https://gitbox.apache.org/repos/asf/maven.git https://github.com/apache/maven/tree/${project.scm.tag} - maven-3.8.4 + maven-3.8.3 jira From ed3279809cad6c77cd8e5c217230c612d1222d9a Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 3 Oct 2021 18:47:20 +0200 Subject: [PATCH 098/183] Update DOAP with Maven 3.8.3 release --- doap_Maven.rdf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doap_Maven.rdf b/doap_Maven.rdf index 531df1217a61..1a1f8edb036f 100644 --- a/doap_Maven.rdf +++ b/doap_Maven.rdf @@ -33,6 +33,15 @@ under the License. Latest stable release + 2021-09-27 + 3.8.3 + http://archive.apache.org/dist/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.zip + http://archive.apache.org/dist/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.tar.gz + http://archive.apache.org/dist/maven/maven-3/3.8.3/source/apache-maven-3.8.3-src.zip + http://archive.apache.org/dist/maven/maven-3/3.8.3/source/apache-maven-3.8.3-src.tar.gz + + + Apache Maven 3.8.2 2021-08-04 3.8.2 http://archive.apache.org/dist/maven/maven-3/3.8.2/binaries/apache-maven-3.8.2-bin.zip From f568170e361ee2f448227ec4c2bce5a2ab2aa99d Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 20 Nov 2021 15:55:23 +0100 Subject: [PATCH 099/183] Update DOAP with Maven 3.8.4 release --- doap_Maven.rdf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doap_Maven.rdf b/doap_Maven.rdf index 1a1f8edb036f..07185589da38 100644 --- a/doap_Maven.rdf +++ b/doap_Maven.rdf @@ -33,6 +33,15 @@ under the License. Latest stable release + 2021-11-14 + 3.8.4 + http://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.zip + http://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz + http://archive.apache.org/dist/maven/maven-3/3.8.4/source/apache-maven-3.8.4-src.zip + http://archive.apache.org/dist/maven/maven-3/3.8.4/source/apache-maven-3.8.4-src.tar.gz + + + Apache Maven 3.8.3 2021-09-27 3.8.3 http://archive.apache.org/dist/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.zip From 5bc395fd08719f221e10998db13475110d510651 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 1 Dec 2021 19:42:20 +0100 Subject: [PATCH 100/183] Add github checks to maven-3.8.x branch --- .github/workflows/maven.yml | 147 ++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 000000000000..addba89d6393 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,147 @@ +# 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. + +name: Java CI + +on: [push, pull_request] + +jobs: + build: + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + fail-fast: false + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v2 + with: + java-version: 8 + distribution: 'temurin' + cache: 'maven' + + - name: Build with Maven + run: mvn verify -e -B -V -DdistributionFileName=apache-maven + + - name: Upload built Maven + uses: actions/upload-artifact@v2 + if: ${{ matrix.os == 'ubuntu-latest' }} + with: + name: built-maven + path: apache-maven/target/ + + - name: Upload built Apache Maven Wrapper + uses: actions/upload-artifact@v2 + if: ${{ matrix.os == 'ubuntu-latest' }} + with: + name: built-apache-maven-wrapper + path: apache-maven-wrapper/target/ + + - name: Upload built Maven Wrapper + uses: actions/upload-artifact@v2 + if: ${{ matrix.os == 'ubuntu-latest' }} + with: + name: built-maven-wrapper + path: maven-wrapper/target/maven-wrapper.jar + + integration-test: + needs: build + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + java: [8, 11, 17] + + fail-fast: false + runs-on: ${{ matrix.os }} + + steps: + - name: Collect environment context variables + shell: bash + env: + PR_HEAD_LABEL: ${{ github.event.pull_request.head.label }} + run: | + set +e + repo=maven-integration-testing + target_branch=master + target_user=apache + if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then + user=${PR_HEAD_LABEL%:*} + branch=${PR_HEAD_LABEL#*:} + else + user=${GITHUB_REPOSITORY%/*} + branch=${GITHUB_REF#refs/heads/} + fi + if [ $branch != "master" ]; then + git ls-remote https://github.com/$user/$repo.git | grep "refs/heads/${branch}$" > /dev/null + if [ $? -eq 0 ]; then + echo "Found a branch \"$branch\" in fork \"$user/$repo\", configuring this for the integration tests to be run against." + target_branch=$branch + target_user=$user + else + echo "Could not find fork \"$user/$repo\" or a branch \"$branch\" in this fork. Falling back to \"$target_branch\" in \"$target_user/$repo\"." + fi + else + echo "Integration tests will run against $target_user/$repo for master builds." + fi + echo "REPO_BRANCH=$target_branch" >> $GITHUB_ENV + echo "REPO_USER=$target_user" >> $GITHUB_ENV + + - name: Checkout maven-integration-testing + uses: actions/checkout@v2 + with: + repository: ${{ env.REPO_USER }}/maven-integration-testing + path: maven-integration-testing/ + ref: ${{ env.REPO_BRANCH }} + + - name: Set up cache for ~/.m2/repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: it-m2-repo-${{ matrix.os }}-${{ hashFiles('maven-integration-testing/**/pom.xml') }} + restore-keys: | + it-m2-repo-${{ matrix.os }}- + + - name: Download built Maven + uses: actions/download-artifact@v2 + with: + name: built-maven + path: built-maven/ + + - name: Download built Apache Maven Wrapper + uses: actions/download-artifact@v2 + with: + name: built-apache-maven-wrapper + path: built-apache-maven-wrapper/ + + - name: Download built Maven Wrapper + uses: actions/download-artifact@v2 + with: + name: built-maven-wrapper + path: built-maven-wrapper/ + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: ${{ matrix.java }} + distribution: 'temurin' + cache: 'maven' + + - name: Running integration tests + shell: bash + run: mvn install -e -B -V -Prun-its,embedded -Dmaven.repo.local="$HOME/.m2/repository" -DmavenDistro="$GITHUB_WORKSPACE/built-maven/apache-maven-bin.zip" -DwrapperDistroDir="$GITHUB_WORKSPACE/built-apache-maven-wrapper/" -DmavenWrapper="$GITHUB_WORKSPACE/built-maven-wrapper/maven-wrapper.jar" -f maven-integration-testing/pom.xml From 803c2155548f7d985e2f7afeb36f29761b5b1b49 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 2 Dec 2021 08:36:32 +0100 Subject: [PATCH 101/183] Fix github checks --- .github/workflows/maven.yml | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index addba89d6393..3b82ac148897 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -46,20 +46,6 @@ jobs: name: built-maven path: apache-maven/target/ - - name: Upload built Apache Maven Wrapper - uses: actions/upload-artifact@v2 - if: ${{ matrix.os == 'ubuntu-latest' }} - with: - name: built-apache-maven-wrapper - path: apache-maven-wrapper/target/ - - - name: Upload built Maven Wrapper - uses: actions/upload-artifact@v2 - if: ${{ matrix.os == 'ubuntu-latest' }} - with: - name: built-maven-wrapper - path: maven-wrapper/target/maven-wrapper.jar - integration-test: needs: build strategy: @@ -123,18 +109,6 @@ jobs: name: built-maven path: built-maven/ - - name: Download built Apache Maven Wrapper - uses: actions/download-artifact@v2 - with: - name: built-apache-maven-wrapper - path: built-apache-maven-wrapper/ - - - name: Download built Maven Wrapper - uses: actions/download-artifact@v2 - with: - name: built-maven-wrapper - path: built-maven-wrapper/ - - name: Set up JDK uses: actions/setup-java@v2 with: @@ -144,4 +118,4 @@ jobs: - name: Running integration tests shell: bash - run: mvn install -e -B -V -Prun-its,embedded -Dmaven.repo.local="$HOME/.m2/repository" -DmavenDistro="$GITHUB_WORKSPACE/built-maven/apache-maven-bin.zip" -DwrapperDistroDir="$GITHUB_WORKSPACE/built-apache-maven-wrapper/" -DmavenWrapper="$GITHUB_WORKSPACE/built-maven-wrapper/maven-wrapper.jar" -f maven-integration-testing/pom.xml + run: mvn install -e -B -V -Prun-its,embedded -Dmaven.repo.local="$HOME/.m2/repository" -DmavenDistro="$GITHUB_WORKSPACE/built-maven/apache-maven-bin.zip" -f maven-integration-testing/pom.xml From 10a72f30f7bdd19e803820a215383b975a5283ce Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 17 Dec 2021 08:42:18 +0100 Subject: [PATCH 102/183] [MNG-7156][MNG-7285] Add locking in MojoExecutor (#628) --- .../lifecycle/internal/MojoExecutor.java | 91 +++++++++++++++++++ .../maven/project/ProjectBuilderTest.java | 13 +++ 2 files changed, 104 insertions(+) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java index b78f54dc42f3..cf97c8cab954 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java @@ -39,6 +39,7 @@ import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.StringUtils; +import org.eclipse.aether.SessionData; import java.util.ArrayList; import java.util.Arrays; @@ -48,6 +49,12 @@ import java.util.Map; import java.util.Set; import java.util.TreeSet; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; /** *

    @@ -76,6 +83,8 @@ public class MojoExecutor @Requirement private ExecutionEventCatapult eventCatapult; + private final ReadWriteLock aggregatorLock = new ReentrantReadWriteLock(); + public MojoExecutor() { } @@ -197,6 +206,88 @@ private void execute( MavenSession session, MojoExecution mojoExecution, Project } } + try ( ProjectLock lock = new ProjectLock( session, mojoDescriptor, aggregatorLock ) ) + { + doExecute( session, mojoExecution, projectIndex, dependencyContext ); + } + } + + /** + * Aggregating mojo executions (possibly) modify all MavenProjects, including those that are currently in use + * by concurrently running mojo executions. To prevent race conditions, an aggregating execution will block + * all other executions until finished. + * We also lock on a given project to forbid a forked lifecycle to be executed concurrently with the project. + * TODO: ideally, the builder should take care of the ordering in a smarter way + * TODO: and concurrency issues fixed with MNG-7157 + */ + private static class ProjectLock implements AutoCloseable + { + final Lock acquiredAggregatorLock; + final Lock acquiredProjectLock; + + ProjectLock( MavenSession session, MojoDescriptor mojoDescriptor, ReadWriteLock aggregatorLock ) + { + if ( session.getRequest().getDegreeOfConcurrency() > 1 ) + { + boolean aggregator = mojoDescriptor.isAggregator(); + acquiredAggregatorLock = aggregator ? aggregatorLock.writeLock() : aggregatorLock.readLock(); + acquiredProjectLock = getProjectLock( session ); + acquiredAggregatorLock.lock(); + acquiredProjectLock.lock(); + } + else + { + acquiredAggregatorLock = null; + acquiredProjectLock = null; + } + } + + @Override + public void close() + { + // release the lock in the reverse order of the acquisition + if ( acquiredProjectLock != null ) + { + acquiredProjectLock.unlock(); + } + if ( acquiredAggregatorLock != null ) + { + acquiredAggregatorLock.unlock(); + } + } + + @SuppressWarnings( { "unchecked", "rawtypes" } ) + private Lock getProjectLock( MavenSession session ) + { + SessionData data = session.getRepositorySession().getData(); + ConcurrentMap locks = ( ConcurrentMap ) data.get( ProjectLock.class ); + // initialize the value if not already done (in case of a concurrent access) to the method + if ( locks == null ) + { + // the call to data.set(k, null, v) is effectively a call to data.putIfAbsent(k, v) + data.set( ProjectLock.class, null, new ConcurrentHashMap<>() ); + locks = ( ConcurrentMap ) data.get( ProjectLock.class ); + } + Lock acquiredProjectLock = locks.get( session.getCurrentProject() ); + if ( acquiredProjectLock == null ) + { + acquiredProjectLock = new ReentrantLock(); + Lock prev = locks.putIfAbsent( session.getCurrentProject(), acquiredProjectLock ); + if ( prev != null ) + { + acquiredProjectLock = prev; + } + } + return acquiredProjectLock; + } + } + + private void doExecute( MavenSession session, MojoExecution mojoExecution, ProjectIndex projectIndex, + DependencyContext dependencyContext ) + throws LifecycleExecutionException + { + MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); + List forkedProjects = executeForkedExecutions( mojoExecution, session, projectIndex ); ensureDependenciesAreResolved( mojoDescriptor, session, dependencyContext ); diff --git a/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java b/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java index 6adb10e8f4e2..40ba60dadfeb 100644 --- a/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java @@ -32,6 +32,7 @@ import java.util.Collections; import java.util.List; import java.util.Properties; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.maven.AbstractCoreMavenComponentTestCase; import org.apache.maven.artifact.InvalidArtifactRTException; @@ -119,6 +120,18 @@ public void testResolveDependencies() assertEquals( 1, results.size() ); MavenProject mavenProject = results.get( 0 ).getProject(); assertEquals( 1, mavenProject.getArtifacts().size() ); + + final MavenProject project = mavenProject; + final AtomicInteger artifactsResultInAnotherThead = new AtomicInteger(); + Thread t = new Thread(new Runnable() { + @Override + public void run() { + artifactsResultInAnotherThead.set(project.getArtifacts().size()); + } + }); + t.start(); + t.join(); + assertEquals( project.getArtifacts().size(), artifactsResultInAnotherThead.get() ); } public void testDontResolveDependencies() From 4ff27db4f9111fbd4268d66b8f18dd44b61df0ee Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 17 Dec 2021 08:57:42 +0100 Subject: [PATCH 103/183] [MNG-7156][MNG-7285] Fix typo in test --- .../java/org/apache/maven/project/ProjectBuilderTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java b/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java index 40ba60dadfeb..aae5f24baa6f 100644 --- a/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java @@ -122,16 +122,16 @@ public void testResolveDependencies() assertEquals( 1, mavenProject.getArtifacts().size() ); final MavenProject project = mavenProject; - final AtomicInteger artifactsResultInAnotherThead = new AtomicInteger(); + final AtomicInteger artifactsResultInAnotherThread = new AtomicInteger(); Thread t = new Thread(new Runnable() { @Override public void run() { - artifactsResultInAnotherThead.set(project.getArtifacts().size()); + artifactsResultInAnotherThread.set(project.getArtifacts().size()); } }); t.start(); t.join(); - assertEquals( project.getArtifacts().size(), artifactsResultInAnotherThead.get() ); + assertEquals( project.getArtifacts().size(), artifactsResultInAnotherThread.get() ); } public void testDontResolveDependencies() From 6ae4f7e2c54113192fdd4b7efe8404088f21539f Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Fri, 17 Dec 2021 11:01:47 +0100 Subject: [PATCH 104/183] Bump Java to 17 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5d5d998c0398..4d411dbbde7c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,7 +23,7 @@ def buildOs = 'linux' def buildJdk = '8' def buildMvn = '3.6.0' def runITsOses = ['linux', 'windows'] -def runITsJdks = ['7', '8', '11','12'] +def runITsJdks = ['7', '8', '11','17'] def runITsMvn = '3.6.0' def runITscommand = "mvn clean install -Prun-its,embedded -B -U -V" // -DmavenDistro=... -Dmaven.test.failure.ignore=true def tests From 8348d2bd0a22bf50bbbe7401ec4e848ff0f32da3 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 26 Dec 2021 22:11:40 +0100 Subject: [PATCH 105/183] Fix SLF4J license link --- .../main/appended-resources/licenses/MIT-slf4j-api-1.7.32.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apache-maven/src/main/appended-resources/licenses/MIT-slf4j-api-1.7.32.txt b/apache-maven/src/main/appended-resources/licenses/MIT-slf4j-api-1.7.32.txt index ec8e1107be01..712cd8c141d0 100644 --- a/apache-maven/src/main/appended-resources/licenses/MIT-slf4j-api-1.7.32.txt +++ b/apache-maven/src/main/appended-resources/licenses/MIT-slf4j-api-1.7.32.txt @@ -1,4 +1,4 @@ -https://raw.githubusercontent.com/qos-ch/slf4j/v_1.7.30/LICENSE.txt +https://raw.githubusercontent.com/qos-ch/slf4j/v_1.7.32/LICENSE.txt Copyright (c) 2004-2017 QOS.ch All rights reserved. From 100b17e1d7163cd263b7ee6e372ab76b3f87dd08 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 26 Dec 2021 19:55:01 +0100 Subject: [PATCH 106/183] [MNG-7370] Upgrade Maven Wagon to 3.5.1 This closes #644 --- apache-maven/pom.xml | 8 ------- .../licenses/MIT-jsoup-1.12.1.txt | 23 ------------------- apache-maven/src/main/assembly/component.xml | 1 - pom.xml | 11 +-------- 4 files changed, 1 insertion(+), 42 deletions(-) delete mode 100644 apache-maven/src/main/appended-resources/licenses/MIT-jsoup-1.12.1.txt diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index 6e12bb0e4d4c..f8be416504c6 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -79,14 +79,6 @@ under the License. - - - org.jsoup - jsoup - runtime - org.slf4j jcl-over-slf4j diff --git a/apache-maven/src/main/appended-resources/licenses/MIT-jsoup-1.12.1.txt b/apache-maven/src/main/appended-resources/licenses/MIT-jsoup-1.12.1.txt deleted file mode 100644 index fa8a44e09e62..000000000000 --- a/apache-maven/src/main/appended-resources/licenses/MIT-jsoup-1.12.1.txt +++ /dev/null @@ -1,23 +0,0 @@ -https://raw.githubusercontent.com/jhy/jsoup/jsoup-1.12.1/LICENSE - -The MIT License - -Copyright (c) 2009-2019 Jonathan Hedley - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/apache-maven/src/main/assembly/component.xml b/apache-maven/src/main/assembly/component.xml index ad16c25fb843..c3014bd06859 100644 --- a/apache-maven/src/main/assembly/component.xml +++ b/apache-maven/src/main/assembly/component.xml @@ -31,7 +31,6 @@ under the License. lib org.codehaus.plexus:plexus-classworlds - org.jsoup:jsoup diff --git a/pom.xml b/pom.xml index 5704043efefe..102419305b62 100644 --- a/pom.xml +++ b/pom.xml @@ -59,8 +59,7 @@ under the License. 3.3.0 4.2.2 0.3.5 - 3.4.3 - 1.12.1 + 3.5.1 2.0 2.0 1.11 @@ -342,14 +341,6 @@ under the License. - - - org.jsoup - jsoup - ${jsoupVersion} - org.apache.maven.resolver From e09baa8ac4fcef82baacba4a66386f7479c753d9 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Thu, 30 Dec 2021 14:52:36 +0100 Subject: [PATCH 107/183] Improve PR template --- .github/pull_request_template.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 2208cd74948c..b4a4f833345b 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,17 +1,16 @@ -Following this checklist to help us incorporate your +Following this checklist to help us incorporate your contribution quickly and easily: - - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MNG) filed - for the change (usually before you start working on it). Trivial changes like typos do not - require a JIRA issue. Your pull request should address just this issue, without + - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MNG) filed + for the change (usually before you start working on it). Trivial changes like typos do not + require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [ ] Each commit in the pull request should have a meaningful subject line and body. - - [ ] Format the pull request title like `[MNG-XXX] - Fixes bug in ApproximateQuantiles`, - where you replace `MNG-XXX` with the appropriate JIRA issue. Best practice - is to use the JIRA issue title in the pull request title and in the first line of the - commit message. + - [ ] Format the pull request title like `[MNG-XXX] SUMMARY`, where you replace `MNG-XXX` + and `SUMMARY` with the appropriate JIRA issue. Best practice is to use the JIRA issue + title in the pull request title and in the first line of the commit message. - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - - [ ] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will + - [ ] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [ ] You have run the [Core IT][core-its] successfully. @@ -19,7 +18,7 @@ If your pull request is about ~20 lines of code you don't need to sign an [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure please ask on the developers list. -To make clear that you license your contribution under +To make clear that you license your contribution under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) you have to acknowledge this by using the following check-box. From d173bf9cc5e6a4f550a9b50f99eca3561b1ca40e Mon Sep 17 00:00:00 2001 From: Jeff Hodges Date: Wed, 29 Dec 2021 01:19:03 -0800 Subject: [PATCH 108/183] [MNG-7377] Add .vscode/ to .gitignore VS Code creates directories with configurations in project directories. This is usually fine, but triggers the `apache-rat` license alarms and future VS Code users might accidentally commit the directory. To solve the alarm and avoid future issues, we add it to .gitignore. This closes #646 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f85dc5684299..28aa49bdc335 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ out/ .java-version .factorypath .checkstyle +.vscode/ From ef74a62451684c8c60cc9db4b6720c8edb89a165 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 25 Dec 2021 12:28:18 +0100 Subject: [PATCH 109/183] [MNG-7374] Mutating RelocatedArtifact does not retain type This closes #641 --- .../internal/RelocatedArtifact.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java index 2e277f0e4c1d..4614ccfe5c5c 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java @@ -86,6 +86,40 @@ public String getVersion() } } + // Revise these three methods when MRESOLVER-233 is delivered + @Override + public Artifact setVersion( String version ) + { + String current = getVersion(); + if ( current.equals( version ) || ( version == null && current.length() <= 0 ) ) + { + return this; + } + return new RelocatedArtifact( artifact, groupId, artifactId, version ); + } + + @Override + public Artifact setFile( File file ) + { + File current = getFile(); + if ( Objects.equals( current, file ) ) + { + return this; + } + return new RelocatedArtifact( artifact.setFile( file ), groupId, artifactId, version ); + } + + @Override + public Artifact setProperties( Map properties ) + { + Map current = getProperties(); + if ( current.equals( properties ) || ( properties == null && current.isEmpty() ) ) + { + return this; + } + return new RelocatedArtifact( artifact.setProperties( properties ), groupId, artifactId, version ); + } + public String getClassifier() { return artifact.getClassifier(); From 05b748ff6aa15aa63a9c9d5f9f5679f47bf9e83d Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 25 Dec 2021 12:28:47 +0100 Subject: [PATCH 110/183] [MNG-5561] Plugin relocation loses configuration Previously, to locate plugin configuration in the project the plugin descriptor was read and the GA were extracted. This always worked because the GA from the model and the GA from plugin descriptor (plugin.xml) were identical. When a plugin is relocated the target artifact is read, thus its plugin descriptor as well. Naturally, the GA of new (relocated) does not correspond to the old (static) one in the model. Therefore, the configuration is not found. New approach is to use the original plugin GA to locate the configuration in the model regardless of relocation. --- .../internal/DefaultMojoExecutionConfigurator.java | 4 ++-- .../lifecycle/internal/stub/BuildPluginManagerStub.java | 2 +- .../maven/lifecycle/internal/stub/MojoExecutorStub.java | 9 ++++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultMojoExecutionConfigurator.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultMojoExecutionConfigurator.java index 176ba320a71a..8c809de82de3 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultMojoExecutionConfigurator.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultMojoExecutionConfigurator.java @@ -41,9 +41,9 @@ public class DefaultMojoExecutionConfigurator @Override public void configure( MavenProject project, MojoExecution mojoExecution, boolean allowPluginLevelConfig ) { - String g = mojoExecution.getGroupId(); + String g = mojoExecution.getPlugin().getGroupId(); - String a = mojoExecution.getArtifactId(); + String a = mojoExecution.getPlugin().getArtifactId(); Plugin plugin = findPlugin( g, a, project.getBuildPlugins() ); diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/BuildPluginManagerStub.java b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/BuildPluginManagerStub.java index 133bcb3a2137..cdb00fc02adf 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/BuildPluginManagerStub.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/BuildPluginManagerStub.java @@ -42,7 +42,7 @@ public PluginDescriptor loadPlugin( Plugin plugin, List reposi public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List repositories, RepositorySystemSession session ) { - return MojoExecutorStub.createMojoDescriptor( plugin.getKey() ); + return MojoExecutorStub.createMojoDescriptor( plugin ); } public ClassRealm getPluginRealm( MavenSession session, PluginDescriptor pluginDescriptor ) diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java index 8a6580b699af..763893e6ce9a 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java @@ -21,6 +21,7 @@ import org.apache.maven.lifecycle.internal.MojoExecutor; import org.apache.maven.lifecycle.internal.PhaseRecorder; import org.apache.maven.lifecycle.internal.ProjectIndex; +import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; @@ -54,12 +55,14 @@ public void execute( MavenSession session, List mojoExecutions, P } - public static MojoDescriptor createMojoDescriptor( String mojoDescription ) + public static MojoDescriptor createMojoDescriptor( Plugin plugin ) { final PluginDescriptor descriptor = new PluginDescriptor(); - descriptor.setArtifactId( mojoDescription ); + descriptor.setGroupId( plugin.getGroupId() ); + descriptor.setArtifactId( plugin.getArtifactId() ); + descriptor.setPlugin( plugin ); + descriptor.setVersion( plugin.getVersion() ); final MojoDescriptor mojoDescriptor = new MojoDescriptor(); - mojoDescriptor.setDescription( mojoDescription ); mojoDescriptor.setPluginDescriptor( descriptor ); return mojoDescriptor; } From 0f3c39b8ed1a875ec58ebe91b2b18ca8b64b2fd3 Mon Sep 17 00:00:00 2001 From: Ravil Galeyev Date: Sat, 15 May 2021 13:51:15 +0200 Subject: [PATCH 111/183] [MNG-6802] FileProfileActivator changes FileProfileActivator.exists which lets flattened resolveCiFriendliesOnly depending fail activating profile Cherry picked from 3fabb639a31d6076b1649c1a08828febabddf44a This closes #649 --- .../model/building/DefaultModelBuilder.java | 66 ++++++++- .../building/DefaultModelBuilderFactory.java | 10 +- ...ProfileActivationFilePathInterpolator.java | 103 ++++++++++++++ .../activation/FileProfileActivator.java | 66 ++------- .../DefaultModelBuilderFactoryTest.java | 36 ++++- .../activation/FileProfileActivatorTest.java | 131 ++++++++++++++++++ 6 files changed, 354 insertions(+), 58 deletions(-) create mode 100644 maven-model-builder/src/main/java/org/apache/maven/model/path/ProfileActivationFilePathInterpolator.java create mode 100644 maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/FileProfileActivatorTest.java diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java index 70c9ed529cd2..94de1d18e5a1 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java @@ -24,6 +24,7 @@ import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Activation; +import org.apache.maven.model.ActivationFile; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -46,11 +47,13 @@ import org.apache.maven.model.normalization.ModelNormalizer; import org.apache.maven.model.path.ModelPathTranslator; import org.apache.maven.model.path.ModelUrlNormalizer; +import org.apache.maven.model.path.ProfileActivationFilePathInterpolator; import org.apache.maven.model.plugin.LifecycleBindingsInjector; import org.apache.maven.model.plugin.PluginConfigurationExpander; import org.apache.maven.model.plugin.ReportConfigurationExpander; import org.apache.maven.model.plugin.ReportingConverter; import org.apache.maven.model.profile.DefaultProfileActivationContext; +import org.apache.maven.model.profile.ProfileActivationContext; import org.apache.maven.model.profile.ProfileInjector; import org.apache.maven.model.profile.ProfileSelector; import org.apache.maven.model.resolution.InvalidRepositoryException; @@ -59,8 +62,10 @@ import org.apache.maven.model.resolution.WorkspaceModelResolver; import org.apache.maven.model.superpom.SuperPomProvider; import org.apache.maven.model.validation.ModelValidator; +import org.codehaus.plexus.interpolation.InterpolationException; import org.codehaus.plexus.interpolation.MapBasedValueSource; import org.codehaus.plexus.interpolation.StringSearchInterpolator; +import org.codehaus.plexus.util.StringUtils; import org.eclipse.sisu.Nullable; import java.io.File; @@ -142,6 +147,9 @@ public class DefaultModelBuilder @Inject private ReportingConverter reportingConverter; + @Inject + private ProfileActivationFilePathInterpolator profileActivationFilePathInterpolator; + public DefaultModelBuilder setModelProcessor( ModelProcessor modelProcessor ) { this.modelProcessor = modelProcessor; @@ -244,6 +252,13 @@ public DefaultModelBuilder setReportingConverter( ReportingConverter reportingCo return this; } + public DefaultModelBuilder setProfileActivationFilePathInterpolator( + ProfileActivationFilePathInterpolator profileActivationFilePathInterpolator ) + { + this.profileActivationFilePathInterpolator = profileActivationFilePathInterpolator; + return this; + } + @SuppressWarnings( "checkstyle:methodlength" ) @Override public ModelBuildingResult build( ModelBuildingRequest request ) @@ -317,7 +332,9 @@ protected ModelBuildingResult build( ModelBuildingRequest request, Collection interpolatedActivations = getProfileActivations( rawModel, false ); + Map interpolatedActivations = getInterpolatedActivations( rawModel, + profileActivationContext, + problems ); injectProfileActivations( tmpModel, interpolatedActivations ); // profile injection @@ -440,6 +457,51 @@ else if ( !parentIds.add( parentData.getId() ) ) return result; } + private Map getInterpolatedActivations( Model rawModel, + DefaultProfileActivationContext context, + DefaultModelProblemCollector problems ) + { + Map interpolatedActivations = getProfileActivations( rawModel, true ); + for ( Activation activation : interpolatedActivations.values() ) + { + if ( activation.getFile() != null ) + { + replaceWithInterpolatedValue( activation.getFile(), context, problems ); + } + } + return interpolatedActivations; + } + + private void replaceWithInterpolatedValue( ActivationFile activationFile, ProfileActivationContext context, + DefaultModelProblemCollector problems ) + { + try + { + if ( StringUtils.isNotEmpty( activationFile.getExists() ) ) + { + String path = activationFile.getExists(); + String absolutePath = profileActivationFilePathInterpolator.interpolate( path, context ); + activationFile.setExists( absolutePath ); + } + else if ( StringUtils.isNotEmpty( activationFile.getMissing() ) ) + { + String path = activationFile.getMissing(); + String absolutePath = profileActivationFilePathInterpolator.interpolate( path, context ); + activationFile.setMissing( absolutePath ); + } + } + catch ( InterpolationException e ) + { + String path = StringUtils.isNotEmpty( + activationFile.getExists() ) ? activationFile.getExists() : activationFile.getMissing(); + + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).setMessage( + "Failed to interpolate file location " + path + ": " + e.getMessage() ).setLocation( + activationFile.getLocation( StringUtils.isNotEmpty( activationFile.getExists() ) ? "exists" : "missing" ) ) + .setException( e ) ); + } + } + @Override public ModelBuildingResult build( ModelBuildingRequest request, ModelBuildingResult result ) throws ModelBuildingException @@ -818,7 +880,7 @@ private Model interpolateModel( Model model, ModelBuildingRequest request, Model problems.add( mpcr ); } - + } interpolatedModel.setPomFile( model.getPomFile() ); diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java index 4240574ff214..730c5a29fee7 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java @@ -43,6 +43,7 @@ import org.apache.maven.model.path.ModelPathTranslator; import org.apache.maven.model.path.ModelUrlNormalizer; import org.apache.maven.model.path.PathTranslator; +import org.apache.maven.model.path.ProfileActivationFilePathInterpolator; import org.apache.maven.model.path.UrlNormalizer; import org.apache.maven.model.plugin.DefaultPluginConfigurationExpander; import org.apache.maven.model.plugin.DefaultReportConfigurationExpander; @@ -109,7 +110,13 @@ protected ProfileSelector newProfileSelector() protected ProfileActivator[] newProfileActivators() { return new ProfileActivator[] { new JdkVersionProfileActivator(), new OperatingSystemProfileActivator(), - new PropertyProfileActivator(), new FileProfileActivator().setPathTranslator( newPathTranslator() ) }; + new PropertyProfileActivator(), new FileProfileActivator() + .setProfileActivationFilePathInterpolator( newProfileActivationFilePathInterpolator() ) }; + } + + protected ProfileActivationFilePathInterpolator newProfileActivationFilePathInterpolator() + { + return new ProfileActivationFilePathInterpolator().setPathTranslator( newPathTranslator() ); } protected UrlNormalizer newUrlNormalizer() @@ -225,6 +232,7 @@ public DefaultModelBuilder newInstance() modelBuilder.setPluginConfigurationExpander( newPluginConfigurationExpander() ); modelBuilder.setReportConfigurationExpander( newReportConfigurationExpander() ); modelBuilder.setReportingConverter( newReportingConverter() ); + modelBuilder.setProfileActivationFilePathInterpolator( newProfileActivationFilePathInterpolator() ); return modelBuilder; } diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/path/ProfileActivationFilePathInterpolator.java b/maven-model-builder/src/main/java/org/apache/maven/model/path/ProfileActivationFilePathInterpolator.java new file mode 100644 index 000000000000..c2f815b7f7ba --- /dev/null +++ b/maven-model-builder/src/main/java/org/apache/maven/model/path/ProfileActivationFilePathInterpolator.java @@ -0,0 +1,103 @@ +package org.apache.maven.model.path; + +/* + * 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.model.ActivationFile; +import org.apache.maven.model.profile.ProfileActivationContext; +import org.codehaus.plexus.interpolation.AbstractValueSource; +import org.codehaus.plexus.interpolation.InterpolationException; +import org.codehaus.plexus.interpolation.MapBasedValueSource; +import org.codehaus.plexus.interpolation.RegexBasedInterpolator; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; +import java.io.File; + +/** + * Finds an absolute path for {@link ActivationFile#getExists()} or {@link ActivationFile#getMissing()} + * + * @author Ravil Galeyev + */ +@Named +@Singleton +public class ProfileActivationFilePathInterpolator +{ + + @Inject + private PathTranslator pathTranslator; + + public ProfileActivationFilePathInterpolator setPathTranslator( PathTranslator pathTranslator ) + { + this.pathTranslator = pathTranslator; + return this; + } + + /** + * Interpolates given {@code path}. + * + * @return absolute path or {@code null} if the input was {@code null} + */ + public String interpolate( String path, ProfileActivationContext context ) throws InterpolationException + { + if ( path == null ) + { + return null; + } + + RegexBasedInterpolator interpolator = new RegexBasedInterpolator(); + + final File basedir = context.getProjectDirectory(); + + if ( basedir != null ) + { + interpolator.addValueSource( new AbstractValueSource( false ) + { + @Override + public Object getValue( String expression ) + { + /* + * We intentionally only support ${basedir} and not ${project.basedir} as the latter form + * would suggest that other project.* expressions can be used which is beyond the design. + */ + if ( "basedir".equals( expression ) ) + { + return basedir.getAbsolutePath(); + } + return null; + } + } ); + } + else if ( path.contains( "${basedir}" ) ) + { + return null; + } + + interpolator.addValueSource( new MapBasedValueSource( context.getProjectProperties() ) ); + + interpolator.addValueSource( new MapBasedValueSource( context.getUserProperties() ) ); + + interpolator.addValueSource( new MapBasedValueSource( context.getSystemProperties() ) ); + + String absolutePath = interpolator.interpolate( path, "" ); + + return pathTranslator.alignToBaseDirectory( absolutePath, basedir ); + } +} diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java index abfa57edfc03..923ffd2eb3cf 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java @@ -28,15 +28,13 @@ import org.apache.maven.model.Activation; import org.apache.maven.model.ActivationFile; import org.apache.maven.model.Profile; -import org.apache.maven.model.building.ModelProblemCollector; import org.apache.maven.model.building.ModelProblem.Severity; import org.apache.maven.model.building.ModelProblem.Version; +import org.apache.maven.model.building.ModelProblemCollector; import org.apache.maven.model.building.ModelProblemCollectorRequest; -import org.apache.maven.model.path.PathTranslator; +import org.apache.maven.model.path.ProfileActivationFilePathInterpolator; import org.apache.maven.model.profile.ProfileActivationContext; -import org.codehaus.plexus.interpolation.AbstractValueSource; -import org.codehaus.plexus.interpolation.MapBasedValueSource; -import org.codehaus.plexus.interpolation.RegexBasedInterpolator; +import org.codehaus.plexus.interpolation.InterpolationException; import org.codehaus.plexus.util.StringUtils; /** @@ -58,11 +56,12 @@ public class FileProfileActivator { @Inject - private PathTranslator pathTranslator; + private ProfileActivationFilePathInterpolator profileActivationFilePathInterpolator; - public FileProfileActivator setPathTranslator( PathTranslator pathTranslator ) + public FileProfileActivator setProfileActivationFilePathInterpolator( + ProfileActivationFilePathInterpolator profileActivationFilePathInterpolator ) { - this.pathTranslator = pathTranslator; + this.profileActivationFilePathInterpolator = profileActivationFilePathInterpolator; return this; } @@ -101,64 +100,23 @@ else if ( StringUtils.isNotEmpty( file.getMissing() ) ) return false; } - RegexBasedInterpolator interpolator = new RegexBasedInterpolator(); - - final File basedir = context.getProjectDirectory(); - - if ( basedir != null ) - { - interpolator.addValueSource( new AbstractValueSource( false ) - { - @Override - public Object getValue( String expression ) - { - /* - * NOTE: We intentionally only support ${basedir} and not ${project.basedir} as the latter form - * would suggest that other project.* expressions can be used which is however beyond the design. - */ - if ( "basedir".equals( expression ) ) - { - return basedir.getAbsolutePath(); - } - return null; - } - } ); - } - else if ( path.contains( "${basedir}" ) ) - { - return false; - } - - interpolator.addValueSource( new MapBasedValueSource( context.getProjectProperties() ) ); - - interpolator.addValueSource( new MapBasedValueSource( context.getUserProperties() ) ); - - interpolator.addValueSource( new MapBasedValueSource( context.getSystemProperties() ) ); - try { - path = interpolator.interpolate( path, "" ); + path = profileActivationFilePathInterpolator.interpolate( path, context ); } - catch ( Exception e ) + catch ( InterpolationException e ) { problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) .setMessage( "Failed to interpolate file location " + path + " for profile " + profile.getId() - + ": " + e.getMessage() ) + + ": " + e.getMessage() ) .setLocation( file.getLocation( missing ? "missing" : "exists" ) ) .setException( e ) ); return false; } - path = pathTranslator.alignToBaseDirectory( path, basedir ); - - // replace activation value with interpolated value - if ( missing ) + if ( path == null ) { - file.setMissing( path ); - } - else - { - file.setExists( path ); + return false; } File f = new File( path ); diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/building/DefaultModelBuilderFactoryTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/building/DefaultModelBuilderFactoryTest.java index 90b65a4c921a..32c7d268d5cf 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/building/DefaultModelBuilderFactoryTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/building/DefaultModelBuilderFactoryTest.java @@ -20,11 +20,17 @@ */ import java.io.File; +import java.io.FileInputStream; +import java.nio.file.Paths; +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.codehaus.plexus.util.xml.Xpp3Dom; import junit.framework.TestCase; +import org.junit.Test; + /** * @author Benjamin Bentmann */ @@ -32,9 +38,11 @@ public class DefaultModelBuilderFactoryTest extends TestCase { + private static final String BASE_DIR = Paths.get( "src", "test", "resources", "poms", "factory" ).toString(); + private File getPom( String name ) { - return new File( "src/test/resources/poms/factory/" + name + ".xml" ).getAbsoluteFile(); + return new File( Paths.get( BASE_DIR, name + ".xml" ).toString() ).getAbsoluteFile(); } public void testCompleteWiring() @@ -56,4 +64,30 @@ public void testCompleteWiring() assertEquals( " 1.5 ", conf.getChild( "target" ).getValue() ); } + @Test + public void testPomChanges() throws Exception + { + ModelBuilder builder = new DefaultModelBuilderFactory().newInstance(); + assertNotNull( builder ); + File pom = getPom( "simple" ); + + String originalExists = readPom( pom ).getProfiles().get( 1 ).getActivation().getFile().getExists(); + + DefaultModelBuildingRequest request = new DefaultModelBuildingRequest(); + request.setProcessPlugins( true ); + request.setPomFile( pom ); + ModelBuildingResult result = builder.build( request ); + String resultExists = result.getRawModel().getProfiles().get( 1 ).getActivation().getFile().getExists(); + + assertEquals( originalExists, resultExists ); + assertTrue( result.getEffectiveModel().getProfiles().get( 1 ).getActivation().getFile().getExists() + .contains( BASE_DIR ) ); + } + + private static Model readPom( File file ) throws Exception + { + MavenXpp3Reader reader = new MavenXpp3Reader(); + + return reader.read( new FileInputStream( file ) ); + } } diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/FileProfileActivatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/FileProfileActivatorTest.java new file mode 100644 index 000000000000..c8b5c93b8d17 --- /dev/null +++ b/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/FileProfileActivatorTest.java @@ -0,0 +1,131 @@ +package org.apache.maven.model.profile.activation; + +/* + * 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.model.Activation; +import org.apache.maven.model.ActivationFile; +import org.apache.maven.model.Profile; +import org.apache.maven.model.path.DefaultPathTranslator; +import org.apache.maven.model.path.ProfileActivationFilePathInterpolator; +import org.apache.maven.model.profile.DefaultProfileActivationContext; + +import org.junit.Before; +import org.junit.Test; + +import java.nio.file.Files; +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; + +/** + * Tests {@link FileProfileActivator}. + * + * @author Ravil Galeyev + */ +public class FileProfileActivatorTest extends AbstractProfileActivatorTest +{ + Path tempDir; + + private final DefaultProfileActivationContext context = new DefaultProfileActivationContext(); + + public FileProfileActivatorTest() + { + super( FileProfileActivator.class ); + } + + @Before + public void setUp() throws Exception + { + super.setUp(); + + tempDir = Files.createTempDirectory( null ); + + activator.setProfileActivationFilePathInterpolator( + new ProfileActivationFilePathInterpolator().setPathTranslator( new DefaultPathTranslator() ) ); + + context.setProjectDirectory( new File( tempDir.toString() ) ); + + File file = new File( tempDir.resolve( "file.txt" ).toString() ); + if ( !file.createNewFile() ) + { + throw new IOException( "Can't create " + file ); + } + } + + @Test + public void testIsActiveNoFile() + { + assertActivation( false, newExistsProfile( null ), context ); + assertActivation( false, newExistsProfile( "someFile.txt" ), context ); + assertActivation( false, newExistsProfile( "${basedir}/someFile.txt" ), context ); + + assertActivation( false, newMissingProfile( null ), context ); + assertActivation( true, newMissingProfile( "someFile.txt" ), context ); + assertActivation( true, newMissingProfile( "${basedir}/someFile.txt" ), context ); + } + + @Test + public void testIsActiveExistsFileExists() + { + assertActivation( true, newExistsProfile( "file.txt" ), context ); + assertActivation( true, newExistsProfile( "${basedir}" ), context ); + assertActivation( true, newExistsProfile( "${basedir}/" + "file.txt" ), context ); + + assertActivation( false, newMissingProfile( "file.txt" ), context ); + assertActivation( false, newMissingProfile( "${basedir}" ), context ); + assertActivation( false, newMissingProfile( "${basedir}/" + "file.txt" ), context ); + } + + @Test + public void testIsActiveExistsLeavesFileUnchanged() + { + Profile profile = newExistsProfile( "file.txt" ); + assertEquals( "file.txt", profile.getActivation().getFile().getExists() ); + + assertActivation( true, profile, context ); + + assertEquals( "file.txt", profile.getActivation().getFile().getExists() ); + } + + private Profile newExistsProfile( String filePath ) + { + ActivationFile activationFile = new ActivationFile(); + activationFile.setExists( filePath ); + return newProfile( activationFile ); + } + + private Profile newMissingProfile( String filePath ) + { + ActivationFile activationFile = new ActivationFile(); + activationFile.setMissing( filePath ); + return newProfile( activationFile ); + } + + private Profile newProfile( ActivationFile activationFile ) + { + Activation activation = new Activation(); + activation.setFile( activationFile ); + + Profile profile = new Profile(); + profile.setActivation( activation ); + + return profile; + } +} From f4fd031828c3cd6a6b8184d4ee0e914cd86009a0 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Thu, 6 Jan 2022 22:26:58 +0100 Subject: [PATCH 112/183] Fix checkstyle issue --- .../org/apache/maven/model/building/DefaultModelBuilder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java index 94de1d18e5a1..813b76297fe6 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java @@ -497,7 +497,8 @@ else if ( StringUtils.isNotEmpty( activationFile.getMissing() ) ) problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).setMessage( "Failed to interpolate file location " + path + ": " + e.getMessage() ).setLocation( - activationFile.getLocation( StringUtils.isNotEmpty( activationFile.getExists() ) ? "exists" : "missing" ) ) + activationFile.getLocation( StringUtils.isNotEmpty( activationFile.getExists() ) + ? "exists" : "missing" ) ) .setException( e ) ); } } From 8456294977b40660ce37db853de344f0d26ee46d Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 7 Jan 2022 09:51:21 +0100 Subject: [PATCH 113/183] [MNG-6326] Make the build fail if core extensions can not be loaded (#648) --- .../java/org/apache/maven/cli/MavenCli.java | 86 ++++++++----------- .../BootstrapCoreExtensionManager.java | 37 +++++--- .../ExtensionResolutionException.java | 47 ++++++++++ .../src/main/mdo/core-extensions.mdo | 26 ++++++ 4 files changed, 134 insertions(+), 62 deletions(-) create mode 100644 maven-embedder/src/main/java/org/apache/maven/cli/internal/ExtensionResolutionException.java diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index fbcb05f91371..ed695ebbf20c 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -705,6 +705,7 @@ protected void configure() private List loadCoreExtensions( CliRequest cliRequest, ClassRealm containerRealm, Set providedArtifacts ) + throws Exception { if ( cliRequest.multiModuleProjectDirectory == null ) { @@ -717,75 +718,62 @@ private List loadCoreExtensions( CliRequest cliRequest, Clas return Collections.emptyList(); } - try + List extensions = readCoreExtensionsDescriptor( extensionsFile ); + if ( extensions.isEmpty() ) { - List extensions = readCoreExtensionsDescriptor( extensionsFile ); - if ( extensions.isEmpty() ) - { - return Collections.emptyList(); - } + return Collections.emptyList(); + } - ContainerConfiguration cc = new DefaultContainerConfiguration() // - .setClassWorld( cliRequest.classWorld ) // - .setRealm( containerRealm ) // - .setClassPathScanning( PlexusConstants.SCANNING_INDEX ) // - .setAutoWiring( true ) // - .setJSR250Lifecycle( true ) // - .setName( "maven" ); + ContainerConfiguration cc = new DefaultContainerConfiguration() // + .setClassWorld( cliRequest.classWorld ) // + .setRealm( containerRealm ) // + .setClassPathScanning( PlexusConstants.SCANNING_INDEX ) // + .setAutoWiring( true ) // + .setJSR250Lifecycle( true ) // + .setName( "maven" ); - DefaultPlexusContainer container = new DefaultPlexusContainer( cc, new AbstractModule() + DefaultPlexusContainer container = new DefaultPlexusContainer( cc, new AbstractModule() + { + @Override + protected void configure() { - @Override - protected void configure() - { - bind( ILoggerFactory.class ).toInstance( slf4jLoggerFactory ); - } - } ); + bind( ILoggerFactory.class ).toInstance( slf4jLoggerFactory ); + } + } ); - try - { - container.setLookupRealm( null ); + try + { + container.setLookupRealm( null ); - container.setLoggerManager( plexusLoggerManager ); + container.setLoggerManager( plexusLoggerManager ); - container.getLoggerManager().setThresholds( cliRequest.request.getLoggingLevel() ); + container.getLoggerManager().setThresholds( cliRequest.request.getLoggingLevel() ); - Thread.currentThread().setContextClassLoader( container.getContainerRealm() ); + Thread.currentThread().setContextClassLoader( container.getContainerRealm() ); - executionRequestPopulator = container.lookup( MavenExecutionRequestPopulator.class ); + executionRequestPopulator = container.lookup( MavenExecutionRequestPopulator.class ); - configurationProcessors = container.lookupMap( ConfigurationProcessor.class ); + configurationProcessors = container.lookupMap( ConfigurationProcessor.class ); - configure( cliRequest ); + configure( cliRequest ); - MavenExecutionRequest request = DefaultMavenExecutionRequest.copy( cliRequest.request ); + MavenExecutionRequest request = DefaultMavenExecutionRequest.copy( cliRequest.request ); - request = populateRequest( cliRequest, request ); + request = populateRequest( cliRequest, request ); - request = executionRequestPopulator.populateDefaults( request ); + request = executionRequestPopulator.populateDefaults( request ); - BootstrapCoreExtensionManager resolver = container.lookup( BootstrapCoreExtensionManager.class ); + BootstrapCoreExtensionManager resolver = container.lookup( BootstrapCoreExtensionManager.class ); - return Collections.unmodifiableList( resolver.loadCoreExtensions( request, providedArtifacts, - extensions ) ); + return Collections.unmodifiableList( resolver.loadCoreExtensions( request, providedArtifacts, + extensions ) ); - } - finally - { - executionRequestPopulator = null; - container.dispose(); - } - } - catch ( RuntimeException e ) - { - // runtime exceptions are most likely bugs in maven, let them bubble up to the user - throw e; } - catch ( Exception e ) + finally { - slf4jLogger.warn( "Failed to read extensions descriptor {}: {}", extensionsFile, e.getMessage() ); + executionRequestPopulator = null; + container.dispose(); } - return Collections.emptyList(); } private List readCoreExtensionsDescriptor( File extensionsFile ) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java b/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java index 9fada05db83b..a47326977d0e 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java @@ -128,19 +128,30 @@ private CoreExtensionEntry createExtension( CoreExtension extension, List resolveExtension( CoreExtension extension, RepositorySystemSession repoSession, List repositories, DependencyFilter dependencyFilter ) - throws PluginResolutionException + throws ExtensionResolutionException { - Plugin plugin = new Plugin(); - plugin.setGroupId( extension.getGroupId() ); - plugin.setArtifactId( extension.getArtifactId() ); - plugin.setVersion( extension.getVersion() ); - - DependencyNode root = - pluginDependenciesResolver.resolveCoreExtension( plugin, dependencyFilter, repositories, repoSession ); - PreorderNodeListGenerator nlg = new PreorderNodeListGenerator(); - root.accept( nlg ); - List artifacts = nlg.getArtifacts( false ); - - return artifacts; + try + { + // TODO: enhance the PluginDependenciesResolver to provide a + // TODO: resolveCoreExtension method which uses a CoreExtension + // TODO: object instead of a Plugin as this makes no sense + Plugin plugin = new Plugin(); + plugin.setGroupId( extension.getGroupId() ); + plugin.setArtifactId( extension.getArtifactId() ); + plugin.setVersion( extension.getVersion() ); + + DependencyNode root = pluginDependenciesResolver + .resolveCoreExtension( plugin, dependencyFilter, repositories, repoSession ); + PreorderNodeListGenerator nlg = new PreorderNodeListGenerator(); + root.accept( nlg ); + List artifacts = nlg.getArtifacts( false ); + + return artifacts; + } + catch ( PluginResolutionException e ) + { + throw new ExtensionResolutionException( extension, e.getCause() ); + } } + } diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/internal/ExtensionResolutionException.java b/maven-embedder/src/main/java/org/apache/maven/cli/internal/ExtensionResolutionException.java new file mode 100644 index 000000000000..4f8cff9cb346 --- /dev/null +++ b/maven-embedder/src/main/java/org/apache/maven/cli/internal/ExtensionResolutionException.java @@ -0,0 +1,47 @@ +package org.apache.maven.cli.internal; + +/* + * 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.cli.internal.extension.model.CoreExtension; + +/** + * Exception occurring trying to resolve a plugin. + * + * @author Brett Porter + */ +public class ExtensionResolutionException + extends Exception +{ + + private final CoreExtension extension; + + public ExtensionResolutionException( CoreExtension extension, Throwable cause ) + { + super( "Extension " + extension.getId() + " or one of its dependencies could not be resolved: " + + cause.getMessage(), cause ); + this.extension = extension; + } + + public CoreExtension getExtension() + { + return extension; + } + +} diff --git a/maven-embedder/src/main/mdo/core-extensions.mdo b/maven-embedder/src/main/mdo/core-extensions.mdo index e523d5abf325..8a74aabb5856 100644 --- a/maven-embedder/src/main/mdo/core-extensions.mdo +++ b/maven-embedder/src/main/mdo/core-extensions.mdo @@ -83,6 +83,32 @@ String + + + 1.0.0+ + + ::}, never {@code null}. + */ + public String getId() + { + StringBuilder id = new StringBuilder( 128 ); + + id.append( ( getGroupId() == null ) ? "[unknown-group-id]" : getGroupId() ); + id.append( ":" ); + id.append( ( getArtifactId() == null ) ? "[unknown-artifact-id]" : getArtifactId() ); + id.append( ":" ); + id.append( ( getVersion() == null ) ? "[unknown-version]" : getVersion() ); + + return id.toString(); + } + ]]> + + + From b4518b5fe416a552a59e5201b4569a9bc0af3153 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 10 Jan 2022 08:19:41 +0100 Subject: [PATCH 114/183] [MNG-7347] SessionScoped beans should be singletons for a given session (#653) --- .../internal/LifecycleModuleBuilder.java | 13 +- .../lifecycle/internal/LifecycleStarter.java | 3 +- .../lifecycle/internal/ReactorContext.java | 14 +- .../session/scope/internal/SessionScope.java | 159 +++++++++--------- .../scope/internal/SessionScopeTest.java | 132 +++++++++++++++ 5 files changed, 226 insertions(+), 95 deletions(-) create mode 100644 maven-core/src/test/java/org/apache/maven/session/scope/internal/SessionScopeTest.java diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java index 548fe6c8ffd6..1cbaf5334606 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java @@ -90,8 +90,12 @@ public void buildProject( MavenSession session, MavenSession rootSession, Reacto // session may be different from rootSession seeded in DefaultMaven // explicitly seed the right session here to make sure it is used by Guice - sessionScope.enter( reactorContext.getSessionScopeMemento() ); - sessionScope.seed( MavenSession.class, session ); + final boolean scoped = session != rootSession; + if ( scoped ) + { + sessionScope.enter(); + sessionScope.seed( MavenSession.class, session ); + } try { @@ -145,7 +149,10 @@ public void buildProject( MavenSession session, MavenSession rootSession, Reacto } finally { - sessionScope.exit(); + if ( scoped ) + { + sessionScope.exit(); + } session.setCurrentProject( null ); diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java index cee80739234d..834498126080 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java @@ -107,8 +107,7 @@ public void execute( MavenSession session ) ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader(); ReactorBuildStatus reactorBuildStatus = new ReactorBuildStatus( session.getProjectDependencyGraph() ); reactorContext = - new ReactorContext( result, projectIndex, oldContextClassLoader, reactorBuildStatus, - sessionScope.memento() ); + new ReactorContext( result, projectIndex, oldContextClassLoader, reactorBuildStatus ); String builderId = session.getRequest().getBuilderId(); Builder builder = builders.get( builderId ); diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ReactorContext.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ReactorContext.java index 7df531404520..076c6229f8ef 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ReactorContext.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ReactorContext.java @@ -20,7 +20,6 @@ */ import org.apache.maven.execution.MavenExecutionResult; -import org.apache.maven.session.scope.internal.SessionScope; /** * Context that is fixed for the entire reactor build. @@ -40,17 +39,13 @@ public class ReactorContext private final ReactorBuildStatus reactorBuildStatus; - private final SessionScope.Memento sessionScope; - public ReactorContext( MavenExecutionResult result, ProjectIndex projectIndex, - ClassLoader originalContextClassLoader, ReactorBuildStatus reactorBuildStatus, - SessionScope.Memento sessionScope ) + ClassLoader originalContextClassLoader, ReactorBuildStatus reactorBuildStatus ) { this.result = result; this.projectIndex = projectIndex; this.originalContextClassLoader = originalContextClassLoader; this.reactorBuildStatus = reactorBuildStatus; - this.sessionScope = sessionScope; } public ReactorBuildStatus getReactorBuildStatus() @@ -73,11 +68,4 @@ public ClassLoader getOriginalContextClassLoader() return originalContextClassLoader; } - /** - * @since 3.3.0 - */ - public SessionScope.Memento getSessionScopeMemento() - { - return sessionScope; - } } diff --git a/maven-core/src/main/java/org/apache/maven/session/scope/internal/SessionScope.java b/maven-core/src/main/java/org/apache/maven/session/scope/internal/SessionScope.java index ac423bc6c92c..41187fd80cbb 100644 --- a/maven-core/src/main/java/org/apache/maven/session/scope/internal/SessionScope.java +++ b/maven-core/src/main/java/org/apache/maven/session/scope/internal/SessionScope.java @@ -19,16 +19,16 @@ * under the License. */ -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.CopyOnWriteArrayList; import com.google.inject.Key; import com.google.inject.OutOfScopeException; import com.google.inject.Provider; import com.google.inject.Scope; -import com.google.inject.util.Providers; /** * SessionScope @@ -36,18 +36,6 @@ public class SessionScope implements Scope { - /** - * @since 3.3.0 - */ - public static class Memento - { - final Map, Provider> seeded; - - Memento( final Map, Provider> seeded ) - { - this.seeded = Collections.unmodifiableMap( new HashMap<>( seeded ) ); - } - } private static final Provider SEEDED_KEY_PROVIDER = new Provider() { @@ -60,110 +48,127 @@ public Object get() /** * ScopeState */ - private static final class ScopeState + protected static final class ScopeState { - private final Map, Provider> seeded = new HashMap<>(); + private final ConcurrentMap, CachingProvider> provided = new ConcurrentHashMap<>(); - private final Map, Object> provided = new HashMap<>(); - } + public void seed( Class clazz, Provider value ) + { + provided.put( Key.get( clazz ), new CachingProvider<>( value ) ); + } - private final ThreadLocal> values = new ThreadLocal<>(); + @SuppressWarnings( "unchecked" ) + public Provider scope( Key key, final Provider unscoped ) + { + Provider provider = provided.get( key ); + if ( provider == null ) + { + CachingProvider newValue = new CachingProvider<>( unscoped ); + provider = provided.putIfAbsent( key, newValue ); + if ( provider == null ) + { + provider = newValue; + } + } + return ( Provider ) provider; + } - public void enter() - { - LinkedList stack = values.get(); - if ( stack == null ) + public Collection> providers() { - stack = new LinkedList<>(); - values.set( stack ); + return provided.values(); } - stack.addFirst( new ScopeState() ); + } - /** - * @since 3.3.0 - */ - public void enter( Memento memento ) + private final List values = new CopyOnWriteArrayList<>(); + + public void enter() { - enter(); - getScopeState().seeded.putAll( memento.seeded ); + values.add( 0, new ScopeState() ); } - private ScopeState getScopeState() + protected ScopeState getScopeState() { - LinkedList stack = values.get(); - if ( stack == null || stack.isEmpty() ) + if ( values.isEmpty() ) { - throw new IllegalStateException(); + throw new OutOfScopeException( "Cannot access session scope outside of a scoping block" ); } - return stack.getFirst(); + return values.get( 0 ); } public void exit() { - final LinkedList stack = values.get(); - if ( stack == null || stack.isEmpty() ) + if ( values.isEmpty() ) { throw new IllegalStateException(); } - stack.removeFirst(); - if ( stack.isEmpty() ) - { - values.remove(); - } - } - - /** - * @since 3.3.0 - */ - public Memento memento() - { - LinkedList stack = values.get(); - return new Memento( stack != null ? stack.getFirst().seeded : Collections., Provider>emptyMap() ); + values.remove( 0 ); } public void seed( Class clazz, Provider value ) { - getScopeState().seeded.put( Key.get( clazz ), value ); + getScopeState().seed( clazz, value ); } public void seed( Class clazz, final T value ) { - getScopeState().seeded.put( Key.get( clazz ), Providers.of( value ) ); + seed( clazz, new Provider() + { + @Override + public T get() + { + return value; + } + } ); } public Provider scope( final Key key, final Provider unscoped ) { + // Lazy evaluating provider return new Provider() { - @SuppressWarnings( "unchecked" ) + @Override public T get() { - LinkedList stack = values.get(); - if ( stack == null || stack.isEmpty() ) - { - throw new OutOfScopeException( "Cannot access " + key + " outside of a scoping block" ); - } + return getScopeState().scope( key, unscoped ).get(); + } + }; + } - ScopeState state = stack.getFirst(); + /** + * CachingProvider + * @param + */ + protected static class CachingProvider implements Provider + { + private final Provider provider; + private volatile T value; - Provider seeded = state.seeded.get( key ); + CachingProvider( Provider provider ) + { + this.provider = provider; + } - if ( seeded != null ) - { - return (T) seeded.get(); - } + public T value() + { + return value; + } - T provided = (T) state.provided.get( key ); - if ( provided == null && unscoped != null ) + @Override + public T get() + { + if ( value == null ) + { + synchronized ( this ) { - provided = unscoped.get(); - state.provided.put( key, provided ); + if ( value == null ) + { + value = provider.get(); + } } - - return provided; } - }; + return value; + } } @SuppressWarnings( { "unchecked" } ) diff --git a/maven-core/src/test/java/org/apache/maven/session/scope/internal/SessionScopeTest.java b/maven-core/src/test/java/org/apache/maven/session/scope/internal/SessionScopeTest.java new file mode 100644 index 000000000000..099e4dddb8f5 --- /dev/null +++ b/maven-core/src/test/java/org/apache/maven/session/scope/internal/SessionScopeTest.java @@ -0,0 +1,132 @@ +package org.apache.maven.session.scope.internal; + +/* + * 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 javax.inject.Provider; + +import com.google.inject.Key; +import com.google.inject.OutOfScopeException; +import org.apache.maven.model.locator.DefaultModelLocator; +import org.apache.maven.model.locator.ModelLocator; +import org.apache.maven.plugin.DefaultPluginRealmCache; +import org.apache.maven.plugin.PluginRealmCache; +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.fail; + +public class SessionScopeTest { + + @Test + public void testScope() throws Exception + { + SessionScope scope = new SessionScope(); + + try + { + scope.seed( ModelLocator.class, new DefaultModelLocator() ); + fail( "Expected a " + OutOfScopeException.class.getName() + " exception to be thrown" ); + } + catch ( OutOfScopeException e ) + { + // expected + } + + Provider pml = scope.scope( Key.get( ModelLocator.class), new DefaultModelLocatorProvider() ); + assertNotNull( pml ); + try + { + pml.get(); + fail( "Expected a " + OutOfScopeException.class.getName() + " exception to be thrown" ); + } + catch ( OutOfScopeException e ) + { + // expected + } + + Provider pmst = scope.scope( Key.get( PluginRealmCache.class ), new DefaultPluginRealmCacheProvider() ); + assertNotNull( pmst ); + + scope.enter(); + + final DefaultModelLocator dml1 = new DefaultModelLocator(); + scope.seed( ModelLocator.class, dml1 ); + + assertSame( dml1, pml.get() ); + + PluginRealmCache mst1 = pmst.get(); + assertSame( mst1, pmst.get() ); + Provider pmst1 = scope.scope( Key.get( PluginRealmCache.class ), new DefaultPluginRealmCacheProvider() ); + assertNotNull( pmst1 ); + assertSame( mst1, pmst1.get() ); + + scope.enter(); + + pmst1 = scope.scope( Key.get( PluginRealmCache.class ), new DefaultPluginRealmCacheProvider() ); + assertNotNull( pmst1 ); + assertNotSame( mst1, pmst1.get() ); + + scope.exit(); + + assertSame( mst1, pmst.get() ); + + scope.exit(); + + try + { + pmst.get(); + fail( "Expected a " + OutOfScopeException.class.getName() + " exception to be thrown" ); + } + catch ( OutOfScopeException e ) + { + // expected + } + try + { + scope.seed( ModelLocator.class, new DefaultModelLocator() ); + fail( "Expected a " + OutOfScopeException.class.getName() + " exception to be thrown" ); + } + catch ( OutOfScopeException e ) + { + // expected + } + } + + private static class DefaultPluginRealmCacheProvider implements com.google.inject.Provider + { + @Override + public PluginRealmCache get() + { + return new DefaultPluginRealmCache(); + } + } + + private static class DefaultModelLocatorProvider implements com.google.inject.Provider + { + @Override + public ModelLocator get() + { + return new DefaultModelLocator(); + } + } + +} From 84cbe1ab2e22a12c2c108d1a0e5233f875475fff Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Tue, 11 Jan 2022 15:23:52 +0100 Subject: [PATCH 115/183] [MNG-7362] DefaultArtifactResolver has spurious "Failure detected" INFO log --- .../apache/maven/artifact/resolver/DefaultArtifactResolver.java | 1 - 1 file changed, 1 deletion(-) diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java index 2d1d8d9492d4..1968c1db41ae 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java @@ -511,7 +511,6 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request ) if ( result.hasMetadataResolutionExceptions() || result.hasVersionRangeViolations() || result.hasCircularDependencyExceptions() ) { - logger.info( "Failure detected." ); return result; } From 99de6b49ee066c102737e4cb99af4be3edb257df Mon Sep 17 00:00:00 2001 From: Falko Modler Date: Sun, 9 Jan 2022 23:58:40 +0100 Subject: [PATCH 116/183] [MNG-7380] Don't log non-threadsafe warning if only building a single module This closes #655 --- .../apache/maven/lifecycle/internal/builder/BuilderCommon.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/BuilderCommon.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/BuilderCommon.java index f5c8e3ea4802..25ab6a46a6e2 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/BuilderCommon.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/BuilderCommon.java @@ -98,7 +98,7 @@ public MavenExecutionPlan resolveBuildPlan( MavenSession session, MavenProject p lifecycleDebugLogger.debugProjectPlan( project, executionPlan ); - if ( session.getRequest().getDegreeOfConcurrency() > 1 ) + if ( session.getRequest().getDegreeOfConcurrency() > 1 && session.getProjects().size() > 1 ) { final Set unsafePlugins = executionPlan.getNonThreadSafePlugins(); if ( !unsafePlugins.isEmpty() ) From 72c483b52702687f5a4160e1fd317b01c03988d3 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 8 Jan 2022 21:32:28 +0100 Subject: [PATCH 117/183] [MNG-7384] Upgrade Maven JAR Plugin to 3.2.2 --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 102419305b62..3583a87e197f 100644 --- a/pom.xml +++ b/pom.xml @@ -487,6 +487,12 @@ under the License. + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.2 + org.apache.maven.plugins maven-release-plugin From 67ff80544866aa9256624d34a6e4178c3b913996 Mon Sep 17 00:00:00 2001 From: Falko Modler Date: Mon, 17 Jan 2022 22:07:09 +0100 Subject: [PATCH 118/183] [MNG-7381] Shorten parallel builder thread name to artifactId, conditionally with groupId This closes #663 --- .../multithreaded/MultiThreadedBuilder.java | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java index 2688a6b4357c..1be0e42ead6b 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java @@ -19,8 +19,10 @@ * under the License. */ +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.CompletionService; import java.util.concurrent.ExecutionException; @@ -127,13 +129,17 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an ThreadOutputMuxer muxer ) { + // gather artifactIds which are not unique so that the respective thread names can be extended with the groupId + Set duplicateArtifactIds = gatherDuplicateArtifactIds( projectBuildList.keySet() ); + // schedule independent projects for ( MavenProject mavenProject : analyzer.getRootSchedulableBuilds() ) { ProjectSegment projectSegment = projectBuildList.get( mavenProject ); logger.debug( "Scheduling: " + projectSegment.getProject() ); Callable cb = - createBuildCallable( rootSession, projectSegment, reactorContext, taskSegment, muxer ); + createBuildCallable( rootSession, projectSegment, reactorContext, taskSegment, muxer, + duplicateArtifactIds ); service.submit( cb ); } @@ -158,7 +164,8 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an ProjectSegment scheduledDependent = projectBuildList.get( mavenProject ); logger.debug( "Scheduling: " + scheduledDependent ); Callable cb = - createBuildCallable( rootSession, scheduledDependent, reactorContext, taskSegment, muxer ); + createBuildCallable( rootSession, scheduledDependent, reactorContext, taskSegment, muxer, + duplicateArtifactIds ); service.submit( cb ); } } @@ -180,7 +187,9 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an private Callable createBuildCallable( final MavenSession rootSession, final ProjectSegment projectBuild, final ReactorContext reactorContext, - final TaskSegment taskSegment, final ThreadOutputMuxer muxer ) + final TaskSegment taskSegment, + final ThreadOutputMuxer muxer, + final Set duplicateArtifactIds ) { return new Callable() { @@ -188,13 +197,18 @@ public ProjectSegment call() { final Thread currentThread = Thread.currentThread(); final String originalThreadName = currentThread.getName(); - currentThread.setName( "mvn-builder-" + projectBuild.getProject().getId() ); + final MavenProject project = projectBuild.getProject(); + + final String threadNameSuffix = duplicateArtifactIds.contains( project.getArtifactId() ) + ? project.getGroupId() + ":" + project.getArtifactId() + : project.getArtifactId(); + currentThread.setName( "mvn-builder-" + threadNameSuffix ); try { // muxer.associateThreadWithProjectSegment( projectBuild ); lifecycleModuleBuilder.buildProject( projectBuild.getSession(), rootSession, reactorContext, - projectBuild.getProject(), taskSegment ); + project, taskSegment ); // muxer.setThisModuleComplete( projectBuild ); return projectBuild; @@ -206,4 +220,18 @@ public ProjectSegment call() } }; } + + private Set gatherDuplicateArtifactIds( Set projects ) + { + Set artifactIds = new HashSet<>( projects.size() ); + Set duplicateArtifactIds = new HashSet<>(); + for ( MavenProject project : projects ) + { + if ( !artifactIds.add( project.getArtifactId() ) ) + { + duplicateArtifactIds.add( project.getArtifactId() ); + } + } + return duplicateArtifactIds; + } } From 27755123e30d46a73ede29cef5b4c340fcdc3fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 9 Jan 2022 19:22:55 +0100 Subject: [PATCH 119/183] [MNG-7385] improve repository metadata documentation --- .../legacy/metadata/ArtifactMetadata.java | 9 +-- .../src/main/mdo/metadata.mdo | 69 ++++++++++--------- .../src/site/apt/index.apt | 32 ++++++--- 3 files changed, 64 insertions(+), 46 deletions(-) diff --git a/maven-artifact/src/main/java/org/apache/maven/repository/legacy/metadata/ArtifactMetadata.java b/maven-artifact/src/main/java/org/apache/maven/repository/legacy/metadata/ArtifactMetadata.java index 7abdfbbe8a07..c97b4e77aefb 100644 --- a/maven-artifact/src/main/java/org/apache/maven/repository/legacy/metadata/ArtifactMetadata.java +++ b/maven-artifact/src/main/java/org/apache/maven/repository/legacy/metadata/ArtifactMetadata.java @@ -24,10 +24,10 @@ /** * Contains metadata about an artifact, and methods to retrieve/store it from an artifact repository. - * - * @author Brett Porter * TODO merge with artifactmetadatasource * TODO retrieval exception not appropriate for store + * + * @author Brett Porter */ public interface ArtifactMetadata { @@ -62,18 +62,19 @@ public interface ArtifactMetadata /** * Merge a new metadata set into this piece of metadata. + * TODO this should only be needed on the repository metadata {@link org.apache.maven.artifact.metadata.ArtifactMetadata} * * @param metadata the new metadata - * TODO this should only be needed on the repository metadata */ void merge( ArtifactMetadata metadata ); /** * Store the metadata in the local repository. + * TODO this should only be needed on the repository metadata {@link org.apache.maven.artifact.metadata.ArtifactMetadata} * * @param localRepository the local repository * @param remoteRepository the remote repository it came from - * TODO this should only be needed on the repository metadata + * @throws RepositoryMetadataStoreException in case of issue */ void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository ) diff --git a/maven-repository-metadata/src/main/mdo/metadata.mdo b/maven-repository-metadata/src/main/mdo/metadata.mdo index a6f5299fa6e1..ddaeb0a56c26 100644 --- a/maven-repository-metadata/src/main/mdo/metadata.mdo +++ b/maven-repository-metadata/src/main/mdo/metadata.mdo @@ -24,11 +24,9 @@ under the License. repository-metadata Metadata Per-directory repository metadata, for directories representing un-versioned artifact, snapshot artifact - or a group containing Maven plugins.

    -

    Notice that most metadata content has a meaning when the directory represents - an artifact (groupId, artifactId, versioning), but - plugins is used when the directory represents a group.

    ]]> +

    Per-directory repository metadata repository-metadata.xml.

    +

    A directory may represent 3 types of content: "groupId", "groupId/artifactId" or "groupId/artifactId/version".

    +

    Most metadata content has a meaning when the directory represents a "groupId/artifactId" (groupId, artifactId, versioning)

    ]]> @@ -51,19 +49,13 @@ under the License. groupId 1.0.0+ String - The groupId that this directory represents, if any. + The groupId when this directory represents "groupId/artifactId" or "groupId/artifactId/version". artifactId 1.0.0+ String - The artifactId that this directory represents, if any. - - - version - 1.0.0+ - String - The version that this directory represents, if any. It is used for artifact snapshots only. + The artifactId when this directory represents "groupId/artifactId" or "groupId/artifactId/version". versioning @@ -71,12 +63,21 @@ under the License. Versioning - Versioning information for the artifact. + Versioning information when this directory represents "groupId/artifactId" or "groupId/artifactId/version". + + + version + 1.0.0+ + String + -SNAPSHOT) when this directory represents a "groupId/artifactId/version" for a SNAPSHOT.]]> plugins 1.0.0+ - The set of plugin mappings for the group represented by this directory + The set of plugins when this directory represents a "groupId" (deprecated) + + @Deprecated + Plugin * @@ -213,42 +214,42 @@ under the License. Versioning 1.0.0+ - Versioning information for an artifact (un-versioned or snapshot) + Versioning information for "groupId/artifactId" or "groupId/artifactId/version" SNAPSHOT latest 1.0.0+ String - What the latest version in the directory is, including snapshots + What the last version added to the directory is, including both releases and snapshots ("groupId/artifactId" directory only) release 1.0.0+ String - What the latest version in the directory is, of the releases only - - - snapshot - 1.0.0+ - - Snapshot - - The current snapshot data in use for this version (artifact snapshots only) + What the last version added to the directory is, for the releases only ("groupId/artifactId" directory only) versions 1.0.0+ - Versions available of the artifact (both releases and snapshots) + Versions available of the artifact (both releases and snapshots) ("groupId/artifactId" directory only) String * - + lastUpdated 1.0.0+ String - When the metadata was last updated + When the metadata was last updated (both "groupId/artifactId" and "groupId/artifactId/version" directories) + + + snapshot + 1.0.0+ + + Snapshot + + The current snapshot data in use for this version ("groupId/artifactId/version" only) snapshotVersions @@ -283,7 +284,7 @@ under the License. Snapshot 1.0.0+ - Snapshot data for the current artifact version + Snapshot data for the last artifact corresponding to the SNAPSHOT base version timestamp @@ -322,7 +323,7 @@ under the License. extension 1.1.0+ String - The file extension of thesub-artifact. + The file extension of the sub-artifact. version @@ -338,10 +339,14 @@ under the License. + Plugin 1.0.0+ - Mapping information for a single plugin within this group + Mapping information for a single plugin within this group (deprecated). + + @Deprecated + NOTE: plugin version is _NOT_ included here, since it is resolved using a separate algorithm in plugins' artifact. diff --git a/maven-repository-metadata/src/site/apt/index.apt b/maven-repository-metadata/src/site/apt/index.apt index ed2bff9680bd..1a484f9f5c5e 100644 --- a/maven-repository-metadata/src/site/apt/index.apt +++ b/maven-repository-metadata/src/site/apt/index.apt @@ -27,26 +27,38 @@ Maven Repository Metadata Model This is strictly the model for Maven Repository Metadata, so really just plain objects. - Maven Repository Metadata is available in directories representing: - - [[1]] an un-versioned artifact: it gives informations about available versions of the artifact, + The metadata file name is: - [[2]] a snapshot artifact: it gives precise information on the snapshot, + * <<>> in a remote repository, - [[3]] a group containing Maven plugins artifacts: it gives informations on plugins available in this group. + * <<.xml>>> in a local repository, for metadata from a repository with <<>> identifier. [] - The metadata file name is: + Depending on what the directory represents ("groupId", "groupId/artifactId" or "groupId/artifactId/version"), + the Maven Repository Metadata file contains 3 different sets of metadata: - * <<>> in a remote repository, + [[1]] in a "groupId" directory: a "groupId" directory may contain Maven plugins artifacts, which are described in metadata's <<>> element, - * <<.xml>>> in a local repository, for metadata from a repository with <<>> identifier. + [[2]] in a "groupId/artifactId" directory: metadata describes <<>>, <<>> and <<>> element that + gives data about available versions (<<>>, <<>>, <<>> list and <<>>), + + [[3]] in a "groupId/artifactId/version" snapshot artifact directory: metadata describes <<>>, <<>>, <<>> (base version, i.e. ending in <<<-SNAPSHOT>>>) and + <<>> element that gives data about snaphot (<<>>, <<>> and <<>> list). Notice that a + release artifact directory is not expected to provide metadata. [] The following are generated from this model: - * {{{./apidocs/index.html}Java sources}} with Reader and Writers for the Xpp3 XML parser, to read and write <<>> files + * {{{./apidocs/index.html}Java sources}} with Reader and Writers for the Xpp3 XML parser, to read and write <<>> files, - * A {{{./repository-metadata.html}Descriptor Reference}} + * a {{{./repository-metadata.html}Descriptor Reference}}. + + Notice: data about plugins in a directory representing a groupId is deprecated and will be removed in a future Maven version. +~~ logic behind this: +~~ 1. MNG-7266: maven-compat will be removed from future Maven version +~~ 2. this will remove the code that updates plugins data: see MNG-7375/MPLUGIN-384 https://maven.apache.org/ref/3.8.4/maven-compat/apidocs/org/apache/maven/artifact/repository/metadata/GroupRepositoryMetadata.html +~~ 3. this will lead to inconsistent data: removing it will be safer/more clear +~~ but this logic still remains to be confirmed by clear consensus of the whole team + \ No newline at end of file From 0cda42477253cab11e7e0f340009da5f417d0775 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 21 Jan 2022 16:53:03 +0100 Subject: [PATCH 120/183] [MNG-7386] Make sure the ModelMerger$MergingList can be serialized --- .../apache/maven/model/merge/ModelMerger.java | 9 +++- .../maven/model/merge/ModelMergerTest.java | 49 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 maven-model/src/test/java/org/apache/maven/model/merge/ModelMergerTest.java diff --git a/maven-model/src/main/java/org/apache/maven/model/merge/ModelMerger.java b/maven-model/src/main/java/org/apache/maven/model/merge/ModelMerger.java index dbd548b6c3c4..7b7ed4dd48f8 100644 --- a/maven-model/src/main/java/org/apache/maven/model/merge/ModelMerger.java +++ b/maven-model/src/main/java/org/apache/maven/model/merge/ModelMerger.java @@ -19,6 +19,7 @@ * under the License. */ +import java.io.ObjectStreamException; import java.util.AbstractList; import java.util.ArrayList; import java.util.Collection; @@ -2870,8 +2871,9 @@ private static List merge( List tgt, List src, KeyComputer compu * Merging list * @param */ - private static class MergingList extends AbstractList + private static class MergingList extends AbstractList implements java.io.Serializable { + private final KeyComputer keyComputer; private Map map; private List list; @@ -2882,6 +2884,11 @@ private static class MergingList extends AbstractList this.keyComputer = keyComputer; } + Object writeReplace() throws ObjectStreamException + { + return new ArrayList<>( this ); + } + @Override public Iterator iterator() { diff --git a/maven-model/src/test/java/org/apache/maven/model/merge/ModelMergerTest.java b/maven-model/src/test/java/org/apache/maven/model/merge/ModelMergerTest.java new file mode 100644 index 000000000000..c347cf63ce96 --- /dev/null +++ b/maven-model/src/test/java/org/apache/maven/model/merge/ModelMergerTest.java @@ -0,0 +1,49 @@ +package org.apache.maven.model.merge; + +/* + * 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 java.io.ByteArrayOutputStream; +import java.io.ObjectOutputStream; +import java.util.ArrayList; + +import org.apache.maven.model.License; +import org.apache.maven.model.Model; +import org.junit.Test; + +public class ModelMergerTest { + + @Test + public void testMergedModelSerialization() throws Exception { + Model target = new Model(); + Model source = new Model(); + target.setLicenses(new ArrayList()); + License lic1 = new License(); + License lic2 = new License(); + target.getLicenses().add(lic1); + source.setLicenses(new ArrayList()); + source.getLicenses().add(lic2); + + new ModelMerger().mergeModel(target, source, false, null); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(target); + } +} \ No newline at end of file From 83257bfde0dd5b4d391063412494957c1b7e15e8 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 24 Jan 2022 07:53:26 +0100 Subject: [PATCH 121/183] [MNG-7349] Limit relocation warning message to direct dependencies only --- .../DefaultPluginDependenciesResolver.java | 12 +++++++++++ .../DefaultProjectDependenciesResolver.java | 16 +++++++++++++++ .../DefaultArtifactDescriptorReader.java | 20 +++---------------- .../internal/RelocatedArtifact.java | 17 +++++++++++----- 4 files changed, 43 insertions(+), 22 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java index 8d16c6136671..c4bddc5f6aea 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java @@ -108,6 +108,18 @@ public Artifact resolve( Plugin plugin, List repositories, Rep pluginArtifact = result.getArtifact(); + if ( logger.isWarnEnabled() ) + { + if ( !result.getRelocations().isEmpty() ) + { + String message = pluginArtifact instanceof org.apache.maven.repository.internal.RelocatedArtifact + ? ( ( org.apache.maven.repository.internal.RelocatedArtifact ) pluginArtifact ).getMessage() + : null; + logger.warn( "The artifact " + result.getRelocations().get( 0 ) + " has been relocated to " + + pluginArtifact + ( message != null ? ": " + message : "" ) ); + } + } + String requiredMavenVersion = (String) result.getProperties().get( "prerequisites.maven" ); if ( requiredMavenVersion != null ) { diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java index 3644b67ef408..7ce49065d03d 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java @@ -181,6 +181,22 @@ public DependencyResolutionResult resolve( DependencyResolutionRequest request ) depRequest.setRoot( node ); + if ( logger.isWarnEnabled() ) + { + for ( DependencyNode child : node.getChildren() ) + { + if ( !child.getRelocations().isEmpty() ) + { + org.eclipse.aether.artifact.Artifact relocated = child.getDependency().getArtifact(); + String message = relocated instanceof org.apache.maven.repository.internal.RelocatedArtifact + ? ( ( org.apache.maven.repository.internal.RelocatedArtifact ) relocated ).getMessage() + : null; + logger.warn( "The artifact " + child.getRelocations().get( 0 ) + " has been relocated to " + + relocated + ( message != null ? ": " + message : "" ) ); + } + } + } + if ( logger.isDebugEnabled() ) { node.accept( new GraphLogger( project ) ); diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java index 888f4581b460..e78c77ff3224 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java @@ -68,8 +68,6 @@ import org.eclipse.aether.spi.locator.Service; import org.eclipse.aether.spi.locator.ServiceLocator; import org.eclipse.aether.transfer.ArtifactNotFoundException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * @author Benjamin Bentmann @@ -79,8 +77,6 @@ public class DefaultArtifactDescriptorReader implements ArtifactDescriptorReader, Service { - private static final Logger LOGGER = LoggerFactory.getLogger( DefaultArtifactDescriptorReader.class ); - private RemoteRepositoryManager remoteRepositoryManager; private VersionResolver versionResolver; @@ -320,20 +316,10 @@ private Model loadPom( RepositorySystemSession session, ArtifactDescriptorReques if ( relocation != null ) { result.addRelocation( a ); - Artifact relocatedArtifact = + a = new RelocatedArtifact( a, relocation.getGroupId(), relocation.getArtifactId(), - relocation.getVersion() ); - if ( LOGGER.isWarnEnabled() ) - { - String message = "The artifact " + a + " has been relocated to " + relocatedArtifact; - if ( relocation.getMessage() != null ) - { - message += ": " + relocation.getMessage(); - } - LOGGER.warn( message ); - } - result.setArtifact( relocatedArtifact ); - a = relocatedArtifact; + relocation.getVersion(), relocation.getMessage() ); + result.setArtifact( a ); } else { diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java index 4614ccfe5c5c..a0a21e9a6002 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java @@ -29,7 +29,7 @@ /** * @author Benjamin Bentmann */ -final class RelocatedArtifact +public final class RelocatedArtifact extends AbstractArtifact { @@ -41,13 +41,16 @@ final class RelocatedArtifact private final String version; - RelocatedArtifact( Artifact artifact, String groupId, String artifactId, String version ) + private final String message; + + RelocatedArtifact( Artifact artifact, String groupId, String artifactId, String version, String message ) { this.artifact = Objects.requireNonNull( artifact, "artifact cannot be null" ); // TODO Use StringUtils here this.groupId = ( groupId != null && groupId.length() > 0 ) ? groupId : null; this.artifactId = ( artifactId != null && artifactId.length() > 0 ) ? artifactId : null; this.version = ( version != null && version.length() > 0 ) ? version : null; + this.message = ( message != null && message.length() > 0 ) ? message : null; } public String getGroupId() @@ -95,7 +98,7 @@ public Artifact setVersion( String version ) { return this; } - return new RelocatedArtifact( artifact, groupId, artifactId, version ); + return new RelocatedArtifact( artifact, groupId, artifactId, version, message ); } @Override @@ -106,7 +109,7 @@ public Artifact setFile( File file ) { return this; } - return new RelocatedArtifact( artifact.setFile( file ), groupId, artifactId, version ); + return new RelocatedArtifact( artifact.setFile( file ), groupId, artifactId, version, message ); } @Override @@ -117,7 +120,7 @@ public Artifact setProperties( Map properties ) { return this; } - return new RelocatedArtifact( artifact.setProperties( properties ), groupId, artifactId, version ); + return new RelocatedArtifact( artifact.setProperties( properties ), groupId, artifactId, version, message ); } public String getClassifier() @@ -145,4 +148,8 @@ public Map getProperties() return artifact.getProperties(); } + public String getMessage() + { + return message; + } } From d79485ff23c9017d47424ff24da1d6dd3c414a60 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 1 Feb 2022 14:26:54 +0100 Subject: [PATCH 122/183] [MNG-6727] Using version range in parent and CI Friendly Version fails --- .../DefaultMavenProjectBuilderTest.java | 135 +++++++++++++++++- .../pom.xml | 12 ++ .../pom.xml | 4 +- .../pom.xml | 12 ++ .../pom.xml | 12 ++ .../pom.xml | 14 ++ .../child/pom.xml | 12 ++ .../pom.xml | 7 + .../child/pom.xml | 4 +- .../pom.xml | 7 + .../child/pom.xml | 14 ++ .../pom.xml | 0 .../model/building/DefaultModelBuilder.java | 20 ++- 13 files changed, 241 insertions(+), 12 deletions(-) create mode 100644 maven-core/src/test/resources/projects/parent-version-range-external-child-pom-parent-version-expression/pom.xml rename maven-core/src/test/resources/projects/{parent-version-range-external-child-version-expression => parent-version-range-external-child-pom-version-expression}/pom.xml (69%) create mode 100644 maven-core/src/test/resources/projects/parent-version-range-external-child-project-parent-version-expression/pom.xml create mode 100644 maven-core/src/test/resources/projects/parent-version-range-external-child-project-version-expression/pom.xml create mode 100644 maven-core/src/test/resources/projects/parent-version-range-external-child-revision-expression/pom.xml create mode 100644 maven-core/src/test/resources/projects/parent-version-range-local-child-project-parent-version-expression/child/pom.xml create mode 100644 maven-core/src/test/resources/projects/parent-version-range-local-child-project-parent-version-expression/pom.xml rename maven-core/src/test/resources/projects/{parent-version-range-local-child-version-expression => parent-version-range-local-child-project-version-expression}/child/pom.xml (70%) create mode 100644 maven-core/src/test/resources/projects/parent-version-range-local-child-project-version-expression/pom.xml create mode 100644 maven-core/src/test/resources/projects/parent-version-range-local-child-revision-expression/child/pom.xml rename maven-core/src/test/resources/projects/{parent-version-range-local-child-version-expression => parent-version-range-local-child-revision-expression}/pom.xml (100%) diff --git a/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java b/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java index 008c6d3bdc31..74a3a074e191 100644 --- a/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java @@ -298,11 +298,11 @@ public void testBuildParentVersionRangeLocallyWithoutChildVersion() throws Excep * * @throws Exception */ - public void testBuildParentVersionRangeLocallyWithChildVersionExpression() throws Exception + public void testBuildParentVersionRangeLocallyWithChildProjectVersionExpression() throws Exception { File f1 = getTestFile( - "src/test/resources/projects/parent-version-range-local-child-version-expression/child/pom.xml" ); + "src/test/resources/projects/parent-version-range-local-child-project-version-expression/child/pom.xml" ); try { @@ -315,7 +315,47 @@ public void testBuildParentVersionRangeLocallyWithChildVersionExpression() throw assertThat( e.getMessage(), containsString( "Version must be a constant" ) ); } } + + /** + * Tests whether local version range parent references are build correctly. + * + * @throws Exception + */ + public void testBuildParentVersionRangeLocallyWithChildProjectParentVersionExpression() throws Exception + { + File f1 = + getTestFile( + "src/test/resources/projects/parent-version-range-local-child-project-parent-version-expression/child/pom.xml" ); + try + { + getProject( f1 ); + fail( "Expected 'ProjectBuildingException' not thrown." ); + } + catch ( final ProjectBuildingException e ) + { + assertNotNull( e.getMessage() ); + assertThat( e.getMessage(), containsString( "Version must be a constant" ) ); + } + } + + /** + * Tests whether local version range parent references are build correctly. + * + * @throws Exception + */ + public void testBuildParentVersionRangeLocallyWithChildRevisionExpression() throws Exception + { + File f1 = + getTestFile( + "src/test/resources/projects/parent-version-range-local-child-revision-expression/child/pom.xml" ); + + MavenProject mp = this.getProjectFromRemoteRepository( f1 ); + + assertEquals("1.0-SNAPSHOT", mp.getVersion()); + + } + /** * Tests whether external version range parent references are build correctly. * @@ -363,11 +403,34 @@ public void testBuildParentVersionRangeExternallyWithoutChildVersion() throws Ex * * @throws Exception */ - public void testBuildParentVersionRangeExternallyWithChildVersionExpression() throws Exception + public void testBuildParentVersionRangeExternallyWithChildProjectVersionExpression() throws Exception { File f1 = getTestFile( - "src/test/resources/projects/parent-version-range-external-child-version-expression/pom.xml" ); + "src/test/resources/projects/parent-version-range-external-child-project-version-expression/pom.xml" ); + + try + { + this.getProjectFromRemoteRepository( f1 ); + fail( "Expected 'ProjectBuildingException' not thrown." ); + } + catch ( final ProjectBuildingException e ) + { + assertNotNull( e.getMessage() ); + assertThat( e.getMessage(), containsString( "Version must be a constant" ) ); + } + } + + /** + * Tests whether external version range parent references are build correctly. + * + * @throws Exception + */ + public void testBuildParentVersionRangeExternallyWithChildPomVersionExpression() throws Exception + { + File f1 = + getTestFile( + "src/test/resources/projects/parent-version-range-external-child-pom-version-expression/pom.xml" ); try { @@ -381,4 +444,68 @@ public void testBuildParentVersionRangeExternallyWithChildVersionExpression() th } } + /** + * Tests whether external version range parent references are build correctly. + * + * @throws Exception + */ + public void testBuildParentVersionRangeExternallyWithChildPomParentVersionExpression() throws Exception + { + File f1 = + getTestFile( + "src/test/resources/projects/parent-version-range-external-child-pom-parent-version-expression/pom.xml" ); + + try + { + this.getProjectFromRemoteRepository( f1 ); + fail( "Expected 'ProjectBuildingException' not thrown." ); + } + catch ( final ProjectBuildingException e ) + { + assertNotNull( e.getMessage() ); + assertThat( e.getMessage(), containsString( "Version must be a constant" ) ); + } + } + + /** + * Tests whether external version range parent references are build correctly. + * + * @throws Exception + */ + public void testBuildParentVersionRangeExternallyWithChildProjectParentVersionExpression() throws Exception + { + File f1 = + getTestFile( + "src/test/resources/projects/parent-version-range-external-child-project-parent-version-expression/pom.xml" ); + + try + { + this.getProjectFromRemoteRepository( f1 ); + fail( "Expected 'ProjectBuildingException' not thrown." ); + } + catch ( final ProjectBuildingException e ) + { + assertNotNull( e.getMessage() ); + assertThat( e.getMessage(), containsString( "Version must be a constant" ) ); + } + } + + /** + * Tests whether external version range parent references are build correctly. + * + * @throws Exception + */ + public void testBuildParentVersionRangeExternallyWithChildRevisionExpression() throws Exception + { + File f1 = + getTestFile( + "src/test/resources/projects/parent-version-range-external-child-revision-expression/pom.xml" ); + + + MavenProject mp = this.getProjectFromRemoteRepository( f1 ); + + assertEquals("1.0-SNAPSHOT", mp.getVersion()); + + + } } diff --git a/maven-core/src/test/resources/projects/parent-version-range-external-child-pom-parent-version-expression/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-external-child-pom-parent-version-expression/pom.xml new file mode 100644 index 000000000000..b37e54a9a987 --- /dev/null +++ b/maven-core/src/test/resources/projects/parent-version-range-external-child-pom-parent-version-expression/pom.xml @@ -0,0 +1,12 @@ + + 4.0.0 + + org.apache + apache + [1,1] + + child + + ${pom.parent.version} + pom + diff --git a/maven-core/src/test/resources/projects/parent-version-range-external-child-version-expression/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-external-child-pom-version-expression/pom.xml similarity index 69% rename from maven-core/src/test/resources/projects/parent-version-range-external-child-version-expression/pom.xml rename to maven-core/src/test/resources/projects/parent-version-range-external-child-pom-version-expression/pom.xml index d07ad6eb565e..bd30a9af8e8d 100644 --- a/maven-core/src/test/resources/projects/parent-version-range-external-child-version-expression/pom.xml +++ b/maven-core/src/test/resources/projects/parent-version-range-external-child-pom-version-expression/pom.xml @@ -6,7 +6,7 @@ [1,1] child - - ${some.property} + + ${project.version} pom diff --git a/maven-core/src/test/resources/projects/parent-version-range-external-child-project-parent-version-expression/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-external-child-project-parent-version-expression/pom.xml new file mode 100644 index 000000000000..a8cf950fa2d9 --- /dev/null +++ b/maven-core/src/test/resources/projects/parent-version-range-external-child-project-parent-version-expression/pom.xml @@ -0,0 +1,12 @@ + + 4.0.0 + + org.apache + apache + [1,1] + + child + + ${project.parent.version} + pom + diff --git a/maven-core/src/test/resources/projects/parent-version-range-external-child-project-version-expression/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-external-child-project-version-expression/pom.xml new file mode 100644 index 000000000000..bd30a9af8e8d --- /dev/null +++ b/maven-core/src/test/resources/projects/parent-version-range-external-child-project-version-expression/pom.xml @@ -0,0 +1,12 @@ + + 4.0.0 + + org.apache + apache + [1,1] + + child + + ${project.version} + pom + diff --git a/maven-core/src/test/resources/projects/parent-version-range-external-child-revision-expression/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-external-child-revision-expression/pom.xml new file mode 100644 index 000000000000..aa724d854a05 --- /dev/null +++ b/maven-core/src/test/resources/projects/parent-version-range-external-child-revision-expression/pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + + org.apache + apache + [1,1] + + child + ${revision} + pom + + 1.0-SNAPSHOT + + diff --git a/maven-core/src/test/resources/projects/parent-version-range-local-child-project-parent-version-expression/child/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-local-child-project-parent-version-expression/child/pom.xml new file mode 100644 index 000000000000..ac42c932b52d --- /dev/null +++ b/maven-core/src/test/resources/projects/parent-version-range-local-child-project-parent-version-expression/child/pom.xml @@ -0,0 +1,12 @@ + + 4.0.0 + + parent-version-range-local + parent + [1,10] + + child + + ${project.parent.version} + pom + diff --git a/maven-core/src/test/resources/projects/parent-version-range-local-child-project-parent-version-expression/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-local-child-project-parent-version-expression/pom.xml new file mode 100644 index 000000000000..858cf1c3f014 --- /dev/null +++ b/maven-core/src/test/resources/projects/parent-version-range-local-child-project-parent-version-expression/pom.xml @@ -0,0 +1,7 @@ + + 4.0.0 + parent-version-range-local + parent + 1 + pom + diff --git a/maven-core/src/test/resources/projects/parent-version-range-local-child-version-expression/child/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-local-child-project-version-expression/child/pom.xml similarity index 70% rename from maven-core/src/test/resources/projects/parent-version-range-local-child-version-expression/child/pom.xml rename to maven-core/src/test/resources/projects/parent-version-range-local-child-project-version-expression/child/pom.xml index 066a11ecdb6c..1435070a8b96 100644 --- a/maven-core/src/test/resources/projects/parent-version-range-local-child-version-expression/child/pom.xml +++ b/maven-core/src/test/resources/projects/parent-version-range-local-child-project-version-expression/child/pom.xml @@ -6,7 +6,7 @@ [1,10] child - - ${some.property} + + ${project.version} pom diff --git a/maven-core/src/test/resources/projects/parent-version-range-local-child-project-version-expression/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-local-child-project-version-expression/pom.xml new file mode 100644 index 000000000000..858cf1c3f014 --- /dev/null +++ b/maven-core/src/test/resources/projects/parent-version-range-local-child-project-version-expression/pom.xml @@ -0,0 +1,7 @@ + + 4.0.0 + parent-version-range-local + parent + 1 + pom + diff --git a/maven-core/src/test/resources/projects/parent-version-range-local-child-revision-expression/child/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-local-child-revision-expression/child/pom.xml new file mode 100644 index 000000000000..b29b5d23bfc8 --- /dev/null +++ b/maven-core/src/test/resources/projects/parent-version-range-local-child-revision-expression/child/pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + + parent-version-range-local + parent + [1,10] + + child + ${revision} + pom + + 1.0-SNAPSHOT + + diff --git a/maven-core/src/test/resources/projects/parent-version-range-local-child-version-expression/pom.xml b/maven-core/src/test/resources/projects/parent-version-range-local-child-revision-expression/pom.xml similarity index 100% rename from maven-core/src/test/resources/projects/parent-version-range-local-child-version-expression/pom.xml rename to maven-core/src/test/resources/projects/parent-version-range-local-child-revision-expression/pom.xml diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java index 813b76297fe6..551f17a89858 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java @@ -1057,7 +1057,9 @@ private ModelData readParentLocally( Model childModel, ModelSource childSource, } // Validate versions aren't inherited when using parent ranges the same way as when read externally. - if ( childModel.getVersion() == null ) + String rawChildModelVersion = childModel.getVersion(); + + if ( rawChildModelVersion == null ) { // Message below is checked for in the MNG-2199 core IT. problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.V31 ) @@ -1066,7 +1068,7 @@ private ModelData readParentLocally( Model childModel, ModelSource childSource, } else { - if ( childModel.getVersion().contains( "${" ) ) + if ( rawChildVersionReferencesParent( rawChildModelVersion ) ) { // Message below is checked for in the MNG-2199 core IT. problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.V31 ) @@ -1099,6 +1101,14 @@ private ModelData readParentLocally( Model childModel, ModelSource childSource, return parentData; } + private boolean rawChildVersionReferencesParent( String rawChildModelVersion ) + { + return rawChildModelVersion.equals( "${pom.version}" ) + || rawChildModelVersion.equals( "${project.version}" ) + || rawChildModelVersion.equals( "${pom.parent.version}" ) + || rawChildModelVersion.equals( "${project.parent.version}" ); + } + private ModelSource getParentPomFile( Model childModel, ModelSource source ) { if ( !( source instanceof ModelSource2 ) ) @@ -1187,7 +1197,9 @@ public int getValidationLevel() if ( !parent.getVersion().equals( version ) ) { - if ( childModel.getVersion() == null ) + String rawChildModelVersion = childModel.getVersion(); + + if ( rawChildModelVersion == null ) { // Message below is checked for in the MNG-2199 core IT. problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.V31 ) @@ -1196,7 +1208,7 @@ public int getValidationLevel() } else { - if ( childModel.getVersion().contains( "${" ) ) + if ( rawChildVersionReferencesParent( rawChildModelVersion ) ) { // Message below is checked for in the MNG-2199 core IT. problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.V31 ) From 0a118d6e244e17cf27654ce6e17b1d3140c0967e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 6 Feb 2022 09:55:38 +0100 Subject: [PATCH 123/183] [MNG-7408] explain Maven 3 reporting plugin version selection --- maven-model/src/main/mdo/maven.mdo | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/maven-model/src/main/mdo/maven.mdo b/maven-model/src/main/mdo/maven.mdo index 61d9ceb6d5fe..5242d305353b 100644 --- a/maven-model/src/main/mdo/maven.mdo +++ b/maven-model/src/main/mdo/maven.mdo @@ -2835,7 +2835,12 @@ version 4.0.0+ - The version of the reporting plugin to be used. + + build/plugins then in build/pluginManagement. + ]]> + String From 6f141968464b4ad24e5d90f1389065141cda5e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sat, 29 Jan 2022 18:09:47 +0100 Subject: [PATCH 124/183] [MNG-7400] Allow more WorkspaceReaders to participate This closes #668 --- .../java/org/apache/maven/DefaultMaven.java | 85 ++++++++++++------- 1 file changed, 56 insertions(+), 29 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index 7f052c139d75..12b8f4ac7b4e 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -232,26 +232,15 @@ private MavenExecutionResult doExecute( MavenExecutionRequest request, MavenSess return addExceptionToResult( result, e ); } - WorkspaceReader reactorWorkspace; try { - reactorWorkspace = container.lookup( WorkspaceReader.class, ReactorReader.HINT ); + setupWorkspaceReader( session, repoSession ); } catch ( ComponentLookupException e ) { return addExceptionToResult( result, e ); } - // - // Desired order of precedence for local artifact repositories - // - // Reactor - // Workspace - // User Local Repository - // - repoSession.setWorkspaceReader( ChainedWorkspaceReader.newInstance( reactorWorkspace, - repoSession.getWorkspaceReader() ) ); - repoSession.setReadOnly(); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); @@ -326,6 +315,34 @@ private MavenExecutionResult doExecute( MavenExecutionRequest request, MavenSess return result; } + private void setupWorkspaceReader( MavenSession session, DefaultRepositorySystemSession repoSession ) + throws ComponentLookupException + { + // Desired order of precedence for workspace readers before querying the local artifact repositories + List workspaceReaders = new ArrayList(); + // 1) Reactor workspace reader + workspaceReaders.add( container.lookup( WorkspaceReader.class, ReactorReader.HINT ) ); + // 2) Repository system session-scoped workspace reader + WorkspaceReader repoWorkspaceReader = repoSession.getWorkspaceReader(); + if ( repoWorkspaceReader != null ) + { + workspaceReaders.add( repoWorkspaceReader ); + } + // 3) .. n) Project-scoped workspace readers + for ( WorkspaceReader workspaceReader : getProjectScopedExtensionComponents( session.getProjects(), + WorkspaceReader.class ) ) + { + if ( workspaceReaders.contains( workspaceReader ) ) + { + continue; + } + workspaceReaders.add( workspaceReader ); + } + WorkspaceReader[] readers = workspaceReaders.toArray( new WorkspaceReader[0] ); + repoSession.setWorkspaceReader( new ChainedWorkspaceReader( readers ) ); + + } + private void afterSessionEnd( Collection projects, MavenSession session ) throws MavenExecutionException { @@ -369,47 +386,57 @@ private Collection getLifecycleParticipants( { Collection lifecycleListeners = new LinkedHashSet<>(); - ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { - try - { - lifecycleListeners.addAll( container.lookupList( AbstractMavenLifecycleParticipant.class ) ); - } - catch ( ComponentLookupException e ) - { - // this is just silly, lookupList should return an empty list! - logger.warn( "Failed to lookup lifecycle participants: " + e.getMessage() ); - } + lifecycleListeners.addAll( container.lookupList( AbstractMavenLifecycleParticipant.class ) ); + } + catch ( ComponentLookupException e ) + { + // this is just silly, lookupList should return an empty list! + logger.warn( "Failed to lookup lifecycle participants: " + e.getMessage() ); + } + + lifecycleListeners.addAll( getProjectScopedExtensionComponents( projects, + AbstractMavenLifecycleParticipant.class ) ); - Collection scannedRealms = new HashSet<>(); + return lifecycleListeners; + } + protected Collection getProjectScopedExtensionComponents( Collection projects, Class role ) + { + + Collection foundComponents = new LinkedHashSet<>(); + Collection scannedRealms = new HashSet<>(); + + Thread currentThread = Thread.currentThread(); + ClassLoader originalContextClassLoader = currentThread.getContextClassLoader(); + try + { for ( MavenProject project : projects ) { ClassLoader projectRealm = project.getClassRealm(); if ( projectRealm != null && scannedRealms.add( projectRealm ) ) { - Thread.currentThread().setContextClassLoader( projectRealm ); + currentThread.setContextClassLoader( projectRealm ); try { - lifecycleListeners.addAll( container.lookupList( AbstractMavenLifecycleParticipant.class ) ); + foundComponents.addAll( container.lookupList( role ) ); } catch ( ComponentLookupException e ) { // this is just silly, lookupList should return an empty list! - logger.warn( "Failed to lookup lifecycle participants: " + e.getMessage() ); + logger.warn( "Failed to lookup " + role + ": " + e.getMessage() ); } } } + return foundComponents; } finally { - Thread.currentThread().setContextClassLoader( originalClassLoader ); + currentThread.setContextClassLoader( originalContextClassLoader ); } - - return lifecycleListeners; } private MavenExecutionResult addExceptionToResult( MavenExecutionResult result, Throwable e ) From 2bb1228de60e805b2f864254a0b1efef7e2d7dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Wed, 2 Feb 2022 10:00:56 +0100 Subject: [PATCH 125/183] [MNG-7407] Introduce a ModelVersionProcessor component to make CI Friendly Versions pluggable This closes #674 --- .../building/DefaultModelBuilderFactory.java | 12 +++- .../AbstractStringBasedModelInterpolator.java | 32 +++------ .../DefaultModelVersionProcessor.java | 69 +++++++++++++++++++ .../interpolation/ModelVersionProcessor.java | 47 +++++++++++++ .../validation/DefaultModelValidator.java | 27 ++++---- .../StringSearchModelInterpolatorTest.java | 5 +- .../validation/DefaultModelValidatorTest.java | 3 +- 7 files changed, 154 insertions(+), 41 deletions(-) create mode 100644 maven-model-builder/src/main/java/org/apache/maven/model/interpolation/DefaultModelVersionProcessor.java create mode 100644 maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelVersionProcessor.java diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java index 730c5a29fee7..86c9e19a94c0 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java @@ -24,7 +24,9 @@ import org.apache.maven.model.composition.DependencyManagementImporter; import org.apache.maven.model.inheritance.DefaultInheritanceAssembler; import org.apache.maven.model.inheritance.InheritanceAssembler; +import org.apache.maven.model.interpolation.DefaultModelVersionProcessor; import org.apache.maven.model.interpolation.ModelInterpolator; +import org.apache.maven.model.interpolation.ModelVersionProcessor; import org.apache.maven.model.interpolation.StringVisitorModelInterpolator; import org.apache.maven.model.io.DefaultModelReader; import org.apache.maven.model.io.ModelReader; @@ -133,12 +135,18 @@ protected ModelInterpolator newModelInterpolator() { UrlNormalizer normalizer = newUrlNormalizer(); PathTranslator pathTranslator = newPathTranslator(); - return new StringVisitorModelInterpolator().setPathTranslator( pathTranslator ).setUrlNormalizer( normalizer ); + return new StringVisitorModelInterpolator().setPathTranslator( pathTranslator ).setUrlNormalizer( normalizer ) + .setVersionPropertiesProcessor( newModelVersionPropertiesProcessor() ); + } + + protected ModelVersionProcessor newModelVersionPropertiesProcessor() + { + return new DefaultModelVersionProcessor(); } protected ModelValidator newModelValidator() { - return new DefaultModelValidator(); + return new DefaultModelValidator( newModelVersionPropertiesProcessor() ); } protected ModelNormalizer newModelNormalizer() diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java index 388671d78de2..4e535cd6455e 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java @@ -52,12 +52,6 @@ public abstract class AbstractStringBasedModelInterpolator implements ModelInterpolator { - public static final String SHA1_PROPERTY = "sha1"; - - public static final String CHANGELIST_PROPERTY = "changelist"; - - public static final String REVISION_PROPERTY = "revision"; - private static final List PROJECT_PREFIXES = Arrays.asList( "pom.", "project." ); private static final Collection TRANSLATED_PATH_EXPRESSIONS; @@ -88,9 +82,8 @@ public abstract class AbstractStringBasedModelInterpolator @Inject private UrlNormalizer urlNormalizer; - public AbstractStringBasedModelInterpolator() - { - } + @Inject + private ModelVersionProcessor versionProcessor; public AbstractStringBasedModelInterpolator setPathTranslator( PathTranslator pathTranslator ) { @@ -104,6 +97,12 @@ public AbstractStringBasedModelInterpolator setUrlNormalizer( UrlNormalizer urlN return this; } + public AbstractStringBasedModelInterpolator setVersionPropertiesProcessor( ModelVersionProcessor processor ) + { + this.versionProcessor = processor; + return this; + } + protected List createValueSources( final Model model, final File projectDir, final ModelBuildingRequest config, final ModelProblemCollector problems ) @@ -162,19 +161,8 @@ public Object getValue( String expression ) valueSources.add( new MapBasedValueSource( config.getUserProperties() ) ); // Overwrite existing values in model properties. Otherwise it's not possible - // to define the version via command line: mvn -Drevision=6.5.7 ... - if ( config.getSystemProperties().containsKey( REVISION_PROPERTY ) ) - { - modelProperties.put( REVISION_PROPERTY, config.getSystemProperties().get( REVISION_PROPERTY ) ); - } - if ( config.getSystemProperties().containsKey( CHANGELIST_PROPERTY ) ) - { - modelProperties.put( CHANGELIST_PROPERTY, config.getSystemProperties().get( CHANGELIST_PROPERTY ) ); - } - if ( config.getSystemProperties().containsKey( SHA1_PROPERTY ) ) - { - modelProperties.put( SHA1_PROPERTY, config.getSystemProperties().get( SHA1_PROPERTY ) ); - } + // to define them via command line e.g.: mvn -Drevision=6.5.7 ... + versionProcessor.overwriteModelProperties( modelProperties, config ); valueSources.add( new MapBasedValueSource( modelProperties ) ); valueSources.add( new MapBasedValueSource( config.getSystemProperties() ) ); diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/DefaultModelVersionProcessor.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/DefaultModelVersionProcessor.java new file mode 100644 index 000000000000..27e3469a3b8a --- /dev/null +++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/DefaultModelVersionProcessor.java @@ -0,0 +1,69 @@ +package org.apache.maven.model.interpolation; + +/* + * 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 java.util.Properties; + +import javax.inject.Named; +import javax.inject.Singleton; + +import org.apache.maven.model.building.ModelBuildingRequest; + +/** + * Maven default implementation of the {@link ModelVersionProcessor} to support + * CI Friendly Versions + */ +@Named +@Singleton +public class DefaultModelVersionProcessor + implements ModelVersionProcessor +{ + + private static final String SHA1_PROPERTY = "sha1"; + + private static final String CHANGELIST_PROPERTY = "changelist"; + + private static final String REVISION_PROPERTY = "revision"; + + @Override + public boolean isValidProperty( String property ) + { + return REVISION_PROPERTY.equals( property ) || CHANGELIST_PROPERTY.equals( property ) + || SHA1_PROPERTY.equals( property ); + } + + @Override + public void overwriteModelProperties( Properties modelProperties, ModelBuildingRequest request ) + { + if ( request.getSystemProperties().containsKey( REVISION_PROPERTY ) ) + { + modelProperties.put( REVISION_PROPERTY, request.getSystemProperties().get( REVISION_PROPERTY ) ); + } + if ( request.getSystemProperties().containsKey( CHANGELIST_PROPERTY ) ) + { + modelProperties.put( CHANGELIST_PROPERTY, request.getSystemProperties().get( CHANGELIST_PROPERTY ) ); + } + if ( request.getSystemProperties().containsKey( SHA1_PROPERTY ) ) + { + modelProperties.put( SHA1_PROPERTY, request.getSystemProperties().get( SHA1_PROPERTY ) ); + } + + } +} diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelVersionProcessor.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelVersionProcessor.java new file mode 100644 index 000000000000..35ce15ea0de6 --- /dev/null +++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ModelVersionProcessor.java @@ -0,0 +1,47 @@ +package org.apache.maven.model.interpolation; + +/* + * 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 java.util.Properties; + +import org.apache.maven.model.building.ModelBuildingRequest; + +/** + * Allows a fixed set of properties that are valid inside a version and that could be overwritten for example on the + * commandline + */ +public interface ModelVersionProcessor +{ + + /** + * @param property the property to check + * @return true if this is a valid property for this processor + */ + boolean isValidProperty( String property ); + + /** + * This method is responsible for examining the request and possibly overwrite of the valid properties in the model + * + * @param modelProperties + * @param request + */ + void overwriteModelProperties( Properties modelProperties, ModelBuildingRequest request ); + +} diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java index ad7e3c7e5a9f..f77321c16654 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java @@ -44,7 +44,7 @@ import org.apache.maven.model.building.ModelProblem.Version; import org.apache.maven.model.building.ModelProblemCollector; import org.apache.maven.model.building.ModelProblemCollectorRequest; -import org.apache.maven.model.interpolation.AbstractStringBasedModelInterpolator; +import org.apache.maven.model.interpolation.ModelVersionProcessor; import org.codehaus.plexus.util.StringUtils; import java.io.File; @@ -58,6 +58,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; @@ -72,11 +73,6 @@ public class DefaultModelValidator private static final Pattern CI_FRIENDLY_EXPRESSION = Pattern.compile( "\\$\\{(.+?)\\}" ); - private static final List CI_FRIENDLY_POSSIBLE_PROPERTY_NAMES = - Arrays.asList( AbstractStringBasedModelInterpolator.REVISION_PROPERTY, - AbstractStringBasedModelInterpolator.CHANGELIST_PROPERTY, - AbstractStringBasedModelInterpolator.SHA1_PROPERTY ); - private static final String ILLEGAL_FS_CHARS = "\\/:\"<>|?*"; private static final String ILLEGAL_VERSION_CHARS = ILLEGAL_FS_CHARS; @@ -87,6 +83,14 @@ public class DefaultModelValidator private final Set validIds = new HashSet<>(); + private ModelVersionProcessor versionProcessor; + + @Inject + public DefaultModelValidator( ModelVersionProcessor versionProcessor ) + { + this.versionProcessor = versionProcessor; + } + @Override public void validateRawModel( Model m, ModelBuildingRequest request, ModelProblemCollector problems ) { @@ -930,21 +934,14 @@ private boolean validateVersionNoExpression( String fieldName, ModelProblemColle return true; } - // - // Acceptable versions for continuous delivery - // - // changelist - // revision - // sha1 - // Matcher m = CI_FRIENDLY_EXPRESSION.matcher( string.trim() ); while ( m.find() ) { - if ( !CI_FRIENDLY_POSSIBLE_PROPERTY_NAMES.contains( m.group( 1 ) ) ) + String property = m.group( 1 ); + if ( !versionProcessor.isValidProperty( property ) ) { addViolation( problems, severity, version, fieldName, null, "contains an expression but should be a constant.", tracker ); - return false; } } diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java index df10511cee2b..c95e37271e29 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java @@ -54,7 +54,8 @@ protected void setUp() throws Exception { super.setUp(); - interpolator = new StringSearchModelInterpolator(); + interpolator = + new StringSearchModelInterpolator().setVersionPropertiesProcessor( new DefaultModelVersionProcessor() ); } @@ -580,6 +581,7 @@ public void testFinalFieldsExcludedFromInterpolation() SimpleProblemCollector problems = new SimpleProblemCollector(); StringSearchModelInterpolator interpolator = new StringSearchModelInterpolator(); + interpolator.setVersionPropertiesProcessor( new DefaultModelVersionProcessor() ); interpolator.interpolateObject( new ClassWithFinalField(), new Model(), null, request, problems ); assertProblemFree( problems ); @@ -605,6 +607,7 @@ public void testLocationTrackerShouldBeExcludedFromInterpolation() SimpleProblemCollector problems = new SimpleProblemCollector(); StringSearchModelInterpolator interpolator = new StringSearchModelInterpolator(); + interpolator.setVersionPropertiesProcessor( new DefaultModelVersionProcessor() ); interpolator.interpolateObject( model, model, null, request, problems ); assertProblemFree( problems ); diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java index 3e07c57754a8..c5f92c7a1424 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java @@ -26,6 +26,7 @@ import org.apache.maven.model.building.DefaultModelBuildingRequest; import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.model.building.SimpleProblemCollector; +import org.apache.maven.model.interpolation.DefaultModelVersionProcessor; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import junit.framework.TestCase; @@ -95,7 +96,7 @@ protected void setUp() { super.setUp(); - validator = new DefaultModelValidator(); + validator = new DefaultModelValidator(new DefaultModelVersionProcessor() ); } @Override From a5acd3ec6095ea2ff50191576c33685c1d038c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Mon, 24 Jan 2022 14:02:13 +0100 Subject: [PATCH 126/183] [MNG-7395] Support interpolation in extensions.xml This adds support for property interpolation in extensions.xml to allow advanced use cases where one wants to contribute certain things via the commandline. This closes #673 --- .../BootstrapCoreExtensionManager.java | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java b/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java index a47326977d0e..4f9faaea6b3e 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java @@ -40,6 +40,10 @@ import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.classworlds.ClassWorld; import org.codehaus.plexus.classworlds.realm.ClassRealm; +import org.codehaus.plexus.interpolation.InterpolationException; +import org.codehaus.plexus.interpolation.Interpolator; +import org.codehaus.plexus.interpolation.MapBasedValueSource; +import org.codehaus.plexus.interpolation.StringSearchInterpolator; import org.codehaus.plexus.logging.Logger; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; @@ -83,14 +87,16 @@ public List loadCoreExtensions( MavenExecutionRequest reques { RepositorySystemSession repoSession = repositorySystemSessionFactory.newRepositorySession( request ); List repositories = RepositoryUtils.toRepos( request.getPluginArtifactRepositories() ); + Interpolator interpolator = createInterpolator( request ); - return resolveCoreExtensions( repoSession, repositories, providedArtifacts, extensions ); + return resolveCoreExtensions( repoSession, repositories, providedArtifacts, extensions, interpolator ); } private List resolveCoreExtensions( RepositorySystemSession repoSession, List repositories, Set providedArtifacts, - List configuration ) + List configuration, + Interpolator interpolator ) throws Exception { List extensions = new ArrayList<>(); @@ -99,7 +105,8 @@ private List resolveCoreExtensions( RepositorySystemSession for ( CoreExtension extension : configuration ) { - List artifacts = resolveExtension( extension, repoSession, repositories, dependencyFilter ); + List artifacts = resolveExtension( extension, repoSession, repositories, + dependencyFilter, interpolator ); if ( !artifacts.isEmpty() ) { extensions.add( createExtension( extension, artifacts ) ); @@ -127,18 +134,20 @@ private CoreExtensionEntry createExtension( CoreExtension extension, List resolveExtension( CoreExtension extension, RepositorySystemSession repoSession, - List repositories, DependencyFilter dependencyFilter ) + List repositories, DependencyFilter dependencyFilter, + Interpolator interpolator ) throws ExtensionResolutionException { try { - // TODO: enhance the PluginDependenciesResolver to provide a - // TODO: resolveCoreExtension method which uses a CoreExtension - // TODO: object instead of a Plugin as this makes no sense + /* TODO: Enhance the PluginDependenciesResolver to provide a + * resolveCoreExtension method which uses a CoreExtension + * object instead of a Plugin as this makes no sense. + */ Plugin plugin = new Plugin(); - plugin.setGroupId( extension.getGroupId() ); - plugin.setArtifactId( extension.getArtifactId() ); - plugin.setVersion( extension.getVersion() ); + plugin.setGroupId( interpolator.interpolate( extension.getGroupId() ) ); + plugin.setArtifactId( interpolator.interpolate( extension.getArtifactId() ) ); + plugin.setVersion( interpolator.interpolate( extension.getVersion() ) ); DependencyNode root = pluginDependenciesResolver .resolveCoreExtension( plugin, dependencyFilter, repositories, repoSession ); @@ -152,6 +161,18 @@ private List resolveExtension( CoreExtension extension, RepositorySyst { throw new ExtensionResolutionException( extension, e.getCause() ); } + catch ( InterpolationException e ) + { + throw new ExtensionResolutionException( extension, e ); + } + } + + private static Interpolator createInterpolator( MavenExecutionRequest request ) + { + StringSearchInterpolator interpolator = new StringSearchInterpolator(); + interpolator.addValueSource( new MapBasedValueSource( request.getUserProperties() ) ); + interpolator.addValueSource( new MapBasedValueSource( request.getSystemProperties() ) ); + return interpolator; } } From 395411fe3184b9692ed16bafa578b40cc0051784 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Wed, 1 Jan 2020 16:01:14 +0100 Subject: [PATCH 127/183] [MNG-7417] Several classes do not set properties properly for building requests This closes #306 --- .../project/artifact/MavenMetadataSource.java | 1 + .../AbstractCoreMavenComponentTestCase.java | 3 ++- .../maven/project/PomConstructionTest.java | 22 +++++++++---------- .../DefaultArtifactDescriptorReader.java | 15 ++++--------- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java index ac55fb93eb4d..7de55e972abf 100644 --- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java +++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java @@ -587,6 +587,7 @@ private ProjectRelocation retrieveRelocatedProject( Artifact artifact, MetadataR configuration.setProcessPlugins( false ); configuration.setRepositoryMerging( ProjectBuildingRequest.RepositoryMerging.REQUEST_DOMINANT ); configuration.setSystemProperties( getSystemProperties() ); + configuration.setUserProperties( new Properties() ); configuration.setRepositorySession( legacySupport.getRepositorySession() ); project = getProjectBuilder().build( pomArtifact, configuration ).getProject(); diff --git a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java index 179b8f974180..2feeae1a1291 100644 --- a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java +++ b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java @@ -143,7 +143,8 @@ protected MavenSession createMavenSession( File pom, Properties executionPropert .setLocalRepository( request.getLocalRepository() ) .setRemoteRepositories( request.getRemoteRepositories() ) .setPluginArtifactRepositories( request.getPluginArtifactRepositories() ) - .setSystemProperties( executionProperties ); + .setSystemProperties( executionProperties ) + .setUserProperties( new Properties() ); List projects = new ArrayList<>(); diff --git a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java index e44e60f023b7..9e7eb4f09758 100644 --- a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java @@ -254,7 +254,7 @@ public void testValidationErrorUponNonUniqueDependencyManagementKeyInProfile() public void testDuplicateDependenciesCauseLastDeclarationToBePickedInLenientMode() throws Exception { - PomTestWrapper pom = buildPom( "unique-dependency-key/deps", true, null ); + PomTestWrapper pom = buildPom( "unique-dependency-key/deps", true, null, null ); assertEquals( 1, ( (List) pom.getValue( "dependencies" ) ).size() ); assertEquals( "0.2", pom.getValue( "dependencies[1]/version" ) ); } @@ -1437,7 +1437,7 @@ public void testJdkActivation() Properties props = new Properties(); props.put( "java.version", "1.5.0_15" ); - PomTestWrapper pom = buildPom( "jdk-activation", props ); + PomTestWrapper pom = buildPom( "jdk-activation", props, null ); assertEquals( 3, pom.getMavenProject().getActiveProfiles().size() ); assertEquals( "PASSED", pom.getValue( "properties/jdkProperty3" ) ); assertEquals( "PASSED", pom.getValue( "properties/jdkProperty2" ) ); @@ -1534,7 +1534,7 @@ public void testInterpolationWithSystemProperty() { Properties sysProps = new Properties(); sysProps.setProperty( "system.property", "PASSED" ); - PomTestWrapper pom = buildPom( "system-property-interpolation", sysProps ); + PomTestWrapper pom = buildPom( "system-property-interpolation", sysProps, null ); assertEquals( "PASSED", pom.getValue( "name" ) ); } @@ -1681,7 +1681,7 @@ public void testCliPropsDominateProjectPropsDuringInterpolation() { Properties props = new Properties(); props.setProperty( "testProperty", "PASSED" ); - PomTestWrapper pom = buildPom( "interpolation-cli-wins", props ); + PomTestWrapper pom = buildPom( "interpolation-cli-wins", null, props ); assertEquals( "PASSED", pom.getValue( "properties/interpolatedProperty" ) ); } @@ -1838,17 +1838,17 @@ private void assertPathWithNormalizedFileSeparators( Object value ) private PomTestWrapper buildPom( String pomPath, String... profileIds ) throws Exception { - return buildPom( pomPath, null, profileIds ); + return buildPom( pomPath, null, null, profileIds ); } - private PomTestWrapper buildPom( String pomPath, Properties executionProperties, String... profileIds ) + private PomTestWrapper buildPom( String pomPath, Properties systemProperties, Properties userProperties, String... profileIds ) throws Exception { - return buildPom( pomPath, false, executionProperties, profileIds ); + return buildPom( pomPath, false, systemProperties, userProperties, profileIds ); } - private PomTestWrapper buildPom( String pomPath, boolean lenientValidation, Properties executionProperties, - String... profileIds ) + private PomTestWrapper buildPom( String pomPath, boolean lenientValidation, Properties systemProperties, + Properties userProperties, String... profileIds ) throws Exception { File pomFile = new File( testDirectory, pomPath ); @@ -1864,8 +1864,8 @@ private PomTestWrapper buildPom( String pomPath, boolean lenientValidation, Prop localRepoUrl = "file://" + localRepoUrl; config.setLocalRepository( repositorySystem.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(), null, null ) ); config.setActiveProfileIds( Arrays.asList( profileIds ) ); - config.setSystemProperties( executionProperties ); - config.setUserProperties( executionProperties ); + config.setSystemProperties( systemProperties ); + config.setUserProperties( userProperties ); config.setValidationLevel( lenientValidation ? ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 : ModelBuildingRequest.VALIDATION_LEVEL_STRICT ); diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java index e78c77ff3224..8d57b6086790 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java @@ -274,8 +274,8 @@ private Model loadPom( RepositorySystemSession session, ArtifactDescriptorReques modelRequest.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL ); modelRequest.setProcessPlugins( false ); modelRequest.setTwoPhaseBuilding( false ); - modelRequest.setSystemProperties( toProperties( session.getUserProperties(), - session.getSystemProperties() ) ); + modelRequest.setSystemProperties( toProperties( session.getSystemProperties() ) ); + modelRequest.setUserProperties( toProperties( session.getUserProperties() ) ); modelRequest.setModelCache( DefaultModelCache.newInstance( session ) ); modelRequest.setModelResolver( new DefaultModelResolver( session, trace.newChild( modelRequest ), request.getRequestContext(), artifactResolver, @@ -328,17 +328,10 @@ private Model loadPom( RepositorySystemSession session, ArtifactDescriptorReques } } - private Properties toProperties( Map dominant, Map recessive ) + private Properties toProperties( Map map ) { Properties props = new Properties(); - if ( recessive != null ) - { - props.putAll( recessive ); - } - if ( dominant != null ) - { - props.putAll( dominant ); - } + props.putAll( map ); return props; } From d29af9018b5c80177102aaab96bd37ed5fedf26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Fri, 25 Feb 2022 11:46:07 +0100 Subject: [PATCH 128/183] [MNG-7402] BuildListCalculator never detaches the classloader This closes #683 --- .../lifecycle/internal/BuildListCalculator.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuildListCalculator.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuildListCalculator.java index 76454f810d47..4fef69b4a9c7 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuildListCalculator.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuildListCalculator.java @@ -57,10 +57,18 @@ public ProjectBuildList calculateProjectBuilds( MavenSession session, List Date: Fri, 28 Aug 2020 22:35:15 +0300 Subject: [PATCH 129/183] [MNG-5180] Versioning's snapshot version list is not included in metadata merge Co-authored-by: Konrad Windszus This closes #684 --- maven-repository-metadata/pom.xml | 5 + .../src/main/mdo/metadata.mdo | 50 ++- .../repository/metadata/MetadataTest.java | 290 ++++++++++++++++++ 3 files changed, 340 insertions(+), 5 deletions(-) create mode 100644 maven-repository-metadata/src/test/java/org/apache/maven/artifact/repository/metadata/MetadataTest.java diff --git a/maven-repository-metadata/pom.xml b/maven-repository-metadata/pom.xml index 31c0418b0c98..a9951098471e 100644 --- a/maven-repository-metadata/pom.xml +++ b/maven-repository-metadata/pom.xml @@ -38,6 +38,11 @@ under the License. org.codehaus.plexus plexus-utils + + org.apache.maven.resolver + maven-resolver-api + test + diff --git a/maven-repository-metadata/src/main/mdo/metadata.mdo b/maven-repository-metadata/src/main/mdo/metadata.mdo index ddaeb0a56c26..6ce381d4a830 100644 --- a/maven-repository-metadata/src/main/mdo/metadata.mdo +++ b/maven-repository-metadata/src/main/mdo/metadata.mdo @@ -88,6 +88,11 @@ under the License. 1.0.0+ versions = new java.util.LinkedHashMap<>(); + // never convert from legacy to new format if either source or target is legacy format + if ( !v.getSnapshotVersions().isEmpty() ) + { + for ( SnapshotVersion sv : versioning.getSnapshotVersions() ) + { + String key = getSnapshotVersionKey( sv ); + versions.put( key, sv ); + } + // never convert from legacy format + if ( !versions.isEmpty() ) + { + for ( SnapshotVersion sv : v.getSnapshotVersions() ) + { + String key = getSnapshotVersionKey( sv ); + if ( !versions.containsKey( key ) ) + { + versions.put( key, sv ); + } + } + } + v.setSnapshotVersions( new java.util.ArrayList( versions.values() ) ); + } + + changed = true; + } } } } @@ -241,7 +277,7 @@ under the License. lastUpdated 1.0.0+ String - When the metadata was last updated (both "groupId/artifactId" and "groupId/artifactId/version" directories) + When the metadata was last updated (both "groupId/artifactId" and "groupId/artifactId/version" directories). The timestamp is expressed using UTC in the format yyyyMMddHHmmss. snapshot @@ -254,7 +290,7 @@ under the License. snapshotVersions 1.1.0+ - Information for each sub-artifact available in this artifact snapshot. + Information for each sub-artifact available in this artifact snapshot. This is only the most recent SNAPSHOT for each unique extension/classifier combination. SnapshotVersion * @@ -289,7 +325,7 @@ under the License. timestamp 1.0.0+ - The time it was deployed + The timestamp when this version was deployed. The timestamp is expressed using UTC in the format yyyyMMdd.HHmmss. String @@ -316,26 +352,30 @@ under the License. classifier 1.1.0+ String - The classifier of the sub-artifact. + The classifier of the sub-artifact. Each classifier and extension pair may only appear once. + true extension 1.1.0+ String - The file extension of the sub-artifact. + The file extension of the sub-artifact. Each classifier and extension pair may only appear once. + true version 1.1.0+ String The resolved snapshot version of the sub-artifact. + true updated 1.1.0+ String The timestamp when this version information was last updated. The timestamp is expressed using UTC in the format yyyyMMddHHmmss. + true diff --git a/maven-repository-metadata/src/test/java/org/apache/maven/artifact/repository/metadata/MetadataTest.java b/maven-repository-metadata/src/test/java/org/apache/maven/artifact/repository/metadata/MetadataTest.java new file mode 100644 index 000000000000..1bf00b5ec1cf --- /dev/null +++ b/maven-repository-metadata/src/test/java/org/apache/maven/artifact/repository/metadata/MetadataTest.java @@ -0,0 +1,290 @@ +package org.apache.maven.artifact.repository.metadata; + +/* + * 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 java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class MetadataTest +{ + + Artifact artifact; + + Metadata target; + + @Before + public void before() + { + artifact = new DefaultArtifact( "myGroup:myArtifact:1.0-SNAPSHOT" ); + target = createMetadataFromArtifact( artifact ); + } + + /*--- START test common metadata ---*/ + @Test + public void mergeEmptyMetadata() + throws Exception + { + Metadata metadata = new Metadata(); + assertFalse( metadata.merge( new Metadata() ) ); + } + + @Test + public void mergeDifferentGAV() + throws Exception + { + // merge implicitly assumes that merge is only called on the same GAV and does not perform any validation here! + Metadata source = new Metadata(); + source.setArtifactId( "source-artifact" ); + source.setGroupId( "source-group" ); + source.setVersion( "2.0" ); + assertFalse( target.merge( source ) ); + assertEquals( "myArtifact", target.getArtifactId() ); + assertEquals( "myGroup", target.getGroupId() ); + assertEquals( "1.0-SNAPSHOT", target.getVersion() ); + } + /*--- END test common metadata ---*/ + + /*--- START test "groupId/artifactId/version" metadata ---*/ + @Test + public void mergeSnapshotWithEmptyList() + throws Exception + { + Snapshot snapshot = new Snapshot(); + snapshot.setBuildNumber( 3 ); + snapshot.setTimestamp( "20200710.072412" ); + target.getVersioning().setSnapshot( snapshot ); + target.getVersioning().setLastUpdated( "20200921071745" ); + SnapshotVersion sv = new SnapshotVersion(); + sv.setClassifier( "sources" ); + sv.setExtension( "jar" ); + sv.setUpdated( "20200710072412" ); + target.getVersioning().addSnapshotVersion( sv ); + + Metadata source = createMetadataFromArtifact( artifact ); + // nothing should be actually changed, but still merge returns true + assertTrue( target.merge( source ) ); + + // NOTE! Merge updates last updated to source + assertEquals( "20200921071745", source.getVersioning().getLastUpdated() ); + + assertEquals( "myArtifact", target.getArtifactId() ); + assertEquals( "myGroup", target.getGroupId() ); + + assertEquals( 3, target.getVersioning().getSnapshot().getBuildNumber() ); + assertEquals( "20200710.072412", target.getVersioning().getSnapshot().getTimestamp() ); + + assertEquals( 1, target.getVersioning().getSnapshotVersions().size() ); + assertEquals( "sources", target.getVersioning().getSnapshotVersions().get( 0 ).getClassifier() ); + assertEquals( "jar", target.getVersioning().getSnapshotVersions().get( 0 ).getExtension() ); + assertEquals( "20200710072412", target.getVersioning().getSnapshotVersions().get( 0 ).getUpdated() ); + } + + @Test + public void mergeWithSameSnapshotWithDifferentVersionsAndNewerLastUpdated() + { + Metadata source = createMetadataFromArtifact( artifact ); + Date before = new Date( System.currentTimeMillis() - 5000 ); + Date after = new Date( System.currentTimeMillis() ); + addSnapshotVersion( target.getVersioning(), "jar", before, "1", 1 ); + SnapshotVersion sv2 = + addSnapshotVersion( source.getVersioning(), "jar", after, "1.0-" + formatDate( after, true ) + "-2", 2 ); + SnapshotVersion sv3 = + addSnapshotVersion( source.getVersioning(), "pom", after, "1.0-" + formatDate( after, true ) + "-2", 2 ); + assertTrue( target.merge( source ) ); + Versioning actualVersioning = target.getVersioning(); + assertEquals( 2, actualVersioning.getSnapshotVersions().size() ); + assertEquals( sv2, actualVersioning.getSnapshotVersions().get( 0 ) ); + assertEquals( sv3, actualVersioning.getSnapshotVersions().get( 1 ) ); + assertEquals( formatDate( after, false ), actualVersioning.getLastUpdated() ); + assertEquals( formatDate( after, true ), actualVersioning.getSnapshot().getTimestamp() ); + assertEquals( 2, actualVersioning.getSnapshot().getBuildNumber() ); + } + + @Test + public void mergeWithSameSnapshotWithDifferentVersionsAndOlderLastUpdated() + { + Metadata source = createMetadataFromArtifact( artifact ); + Date before = new Date( System.currentTimeMillis() - 5000 ); + Date after = new Date( System.currentTimeMillis() ); + SnapshotVersion sv1 = addSnapshotVersion( target.getVersioning(), after, artifact ); + addSnapshotVersion( source.getVersioning(), before, artifact ); + // nothing should be updated, as the target was already updated at a later date than source + assertFalse( target.merge( source ) ); + assertEquals( 1, target.getVersioning().getSnapshotVersions().size() ); + assertEquals( sv1, target.getVersioning().getSnapshotVersions().get( 0 ) ); + assertEquals( formatDate( after, false ), target.getVersioning().getLastUpdated() ); + assertEquals( formatDate( after, true ), target.getVersioning().getSnapshot().getTimestamp() ); + } + + @Test + public void mergeWithSameSnapshotWithSameVersionAndTimestamp() + { + Metadata source = createMetadataFromArtifact( artifact ); + Date date = new Date(); + addSnapshotVersion( target.getVersioning(), date, artifact ); + SnapshotVersion sv1 = addSnapshotVersion( source.getVersioning(), date, artifact ); + // although nothing has changed merge returns true, as the last modified date is equal + // TODO: improve merge here? + assertTrue( target.merge( source ) ); + assertEquals( 1, target.getVersioning().getSnapshotVersions().size() ); + assertEquals( sv1, target.getVersioning().getSnapshotVersions().get( 0 ) ); + assertEquals( formatDate( date, false ), target.getVersioning().getLastUpdated() ); + assertEquals( formatDate( date, true ), target.getVersioning().getSnapshot().getTimestamp() ); + } + + @Test + public void mergeLegacyWithSnapshotLegacy() + { + Metadata source = createMetadataFromArtifact( artifact ); + Date before = new Date( System.currentTimeMillis() - 5000 ); + Date after = new Date( System.currentTimeMillis() ); + // legacy metadata did not have "versioning.snapshotVersions" + addSnapshotVersionLegacy( target.getVersioning(), before, 1 ); + addSnapshotVersionLegacy( source.getVersioning(), after, 2 ); + // although nothing has changed merge returns true, as the last modified date is equal + // TODO: improve merge here? + assertTrue( target.merge( source ) ); + assertEquals( 0, target.getVersioning().getSnapshotVersions().size() ); + assertEquals( formatDate( after, false ), target.getVersioning().getLastUpdated() ); + assertEquals( formatDate( after, true ), target.getVersioning().getSnapshot().getTimestamp() ); + } + + @Test + public void mergeLegacyWithSnapshot() + { + Metadata source = createMetadataFromArtifact( artifact ); + Date before = new Date( System.currentTimeMillis() - 5000 ); + Date after = new Date( System.currentTimeMillis() ); + // legacy metadata did not have "versioning.snapshotVersions" + addSnapshotVersionLegacy( target.getVersioning(), before, 1 ); + addSnapshotVersion( source.getVersioning(), after, artifact ); + // although nothing has changed merge returns true, as the last modified date is equal + // TODO: improve merge here? + assertTrue( target.merge( source ) ); + // never convert from legacy format to v1.1 format + assertEquals( 0, target.getVersioning().getSnapshotVersions().size() ); + assertEquals( formatDate( after, false ), target.getVersioning().getLastUpdated() ); + assertEquals( formatDate( after, true ), target.getVersioning().getSnapshot().getTimestamp() ); + } + + @Test + public void mergeWithSnapshotLegacy() + { + Metadata source = createMetadataFromArtifact( artifact ); + Date before = new Date( System.currentTimeMillis() - 5000 ); + Date after = new Date( System.currentTimeMillis() ); + addSnapshotVersion( target.getVersioning(), before, artifact ); + // legacy metadata did not have "versioning.snapshotVersions" + addSnapshotVersionLegacy( source.getVersioning(), after, 2 ); + // although nothing has changed merge returns true, as the last modified date is equal + // TODO: improve merge here? + assertTrue( target.merge( source ) ); + // the result must be legacy format as well + assertEquals( 0, target.getVersioning().getSnapshotVersions().size() ); + assertEquals( formatDate( after, false ), target.getVersioning().getLastUpdated() ); + assertEquals( formatDate( after, true ), target.getVersioning().getSnapshot().getTimestamp() ); + assertEquals( 2, target.getVersioning().getSnapshot().getBuildNumber() ); + } + /*-- END test "groupId/artifactId/version" metadata ---*/ + + /*-- START helper methods to populate metadata objects ---*/ + private static final String SNAPSHOT = "SNAPSHOT"; + + private static final String DEFAULT_SNAPSHOT_TIMESTAMP_FORMAT = "yyyyMMdd.HHmmss"; + + private static final String DEFAULT_DATE_FORMAT = "yyyyMMddHHmmss"; + + private static String formatDate( Date date, boolean forSnapshotTimestamp ) + { + // logic from metadata.mdo, class "Versioning" + TimeZone timezone = TimeZone.getTimeZone( "UTC" ); + DateFormat fmt = + new SimpleDateFormat( forSnapshotTimestamp ? DEFAULT_SNAPSHOT_TIMESTAMP_FORMAT : DEFAULT_DATE_FORMAT ); + fmt.setCalendar( new GregorianCalendar() ); + fmt.setTimeZone( timezone ); + return fmt.format( date ); + } + + private static Metadata createMetadataFromArtifact( Artifact artifact ) + { + Metadata metadata = new Metadata(); + metadata.setArtifactId( artifact.getArtifactId() ); + metadata.setGroupId( artifact.getGroupId() ); + metadata.setVersion( artifact.getVersion() ); + metadata.setVersioning( new Versioning() ); + return metadata; + } + + private static SnapshotVersion addSnapshotVersion( Versioning versioning, Date timestamp, Artifact artifact ) + { + int buildNumber = 1; + // this generates timestamped versions like maven-resolver-provider: + // https://github.com/apache/maven/blob/03df5f7c639db744a3597c7175c92c8e2a27767b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java#L79 + String version = artifact.getVersion(); + String qualifier = formatDate( timestamp, true ) + '-' + buildNumber; + version = version.substring( 0, version.length() - SNAPSHOT.length() ) + qualifier; + return addSnapshotVersion( versioning, artifact.getExtension(), timestamp, version, buildNumber ); + } + + private static SnapshotVersion addSnapshotVersion( Versioning versioning, String extension, Date timestamp, + String version, int buildNumber ) + { + Snapshot snapshot = new Snapshot(); + snapshot.setBuildNumber( buildNumber ); + snapshot.setTimestamp( formatDate( timestamp, true ) ); + + SnapshotVersion sv = new SnapshotVersion(); + sv.setExtension( extension ); + sv.setVersion( version ); + sv.setUpdated( formatDate( timestamp, false ) ); + versioning.addSnapshotVersion( sv ); + + // make the new snapshot the current one + versioning.setSnapshot( snapshot ); + versioning.setLastUpdatedTimestamp( timestamp ); + return sv; + } + + // the format written by Maven 2 + // (https://maven.apache.org/ref/2.2.1/maven-repository-metadata/repository-metadata.html) + private static void addSnapshotVersionLegacy( Versioning versioning, Date timestamp, int buildNumber ) + { + Snapshot snapshot = new Snapshot(); + snapshot.setBuildNumber( buildNumber ); + snapshot.setTimestamp( formatDate( timestamp, true ) ); + + versioning.setSnapshot( snapshot ); + versioning.setLastUpdatedTimestamp( timestamp ); + } + /*-- END helper methods to populate metadata objects ---*/ +} \ No newline at end of file From f0caf9c9b31e31abb91ca986fe8168867cd0ded2 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 27 Feb 2022 19:27:25 +0100 Subject: [PATCH 130/183] [MNG-6960] Use RuntimeInformation instead of reading properties --- ...DefaultRepositorySystemSessionFactory.java | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java index 9c4cede1c2c3..3bb622caa8b2 100644 --- a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java +++ b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java @@ -25,6 +25,7 @@ import org.apache.maven.eventspy.internal.EventSpyDispatcher; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; +import org.apache.maven.rtinfo.RuntimeInformation; import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Server; @@ -93,6 +94,9 @@ public class DefaultRepositorySystemSessionFactory @Inject MavenRepositorySystem mavenRepositorySystem; + @Inject + private RuntimeInformation runtimeInformation; + public DefaultRepositorySystemSession newRepositorySession( MavenExecutionRequest request ) { DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); @@ -244,28 +248,10 @@ else if ( request.isUpdateSnapshots() ) private String getUserAgent() { - return "Apache-Maven/" + getMavenVersion() + " (Java " + System.getProperty( "java.version" ) + "; " + String version = runtimeInformation.getMavenVersion(); + version = version.isEmpty() ? version : "/" + version; + return "Apache-Maven" + version + " (Java " + System.getProperty( "java.version" ) + "; " + System.getProperty( "os.name" ) + " " + System.getProperty( "os.version" ) + ")"; } - private String getMavenVersion() - { - Properties props = new Properties(); - - try ( InputStream is = getClass().getResourceAsStream( - "/META-INF/maven/org.apache.maven/maven-core/pom.properties" ) ) - { - if ( is != null ) - { - props.load( is ); - } - } - catch ( IOException e ) - { - logger.debug( "Failed to read Maven version", e ); - } - - return props.getProperty( "version", "unknown-version" ); - } - } From 572d5260b9040bd063b3dc84ce51684b8379df10 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Thu, 3 Mar 2022 12:45:18 +0100 Subject: [PATCH 131/183] [MNG-7428] Upgrade Maven Parent to 35 --- pom.xml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 3583a87e197f..d2ad92952dfb 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven-parent - 34 + 35 ../pom/maven/pom.xml @@ -487,12 +487,6 @@ under the License. - - - org.apache.maven.plugins - maven-jar-plugin - 3.2.2 - org.apache.maven.plugins maven-release-plugin @@ -632,6 +626,13 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin + + + org.codehaus.mojo + extra-enforcer-rules + 1.4 + + From cfeea9dac4c5a14c846382aa7a47a7d4e5f110f5 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 5 Mar 2022 12:39:24 +0100 Subject: [PATCH 132/183] Remove unused imports --- .../internal/aether/DefaultRepositorySystemSessionFactory.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java index 3bb622caa8b2..60c6cf17a050 100644 --- a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java +++ b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java @@ -54,11 +54,8 @@ import javax.inject.Inject; import javax.inject.Named; -import java.io.IOException; -import java.io.InputStream; import java.util.LinkedHashMap; import java.util.Map; -import java.util.Properties; /** * @since 3.3.0 From 3599d3414f046de2324203b78ddcf9b5e4388aa0 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 5 Mar 2022 12:41:04 +0100 Subject: [PATCH 133/183] [maven-release-plugin] prepare release maven-3.8.5 --- apache-maven/pom.xml | 2 +- maven-artifact/pom.xml | 2 +- maven-builder-support/pom.xml | 2 +- maven-compat/pom.xml | 2 +- maven-core/pom.xml | 2 +- maven-embedder/pom.xml | 2 +- maven-model-builder/pom.xml | 2 +- maven-model/pom.xml | 2 +- maven-plugin-api/pom.xml | 2 +- maven-repository-metadata/pom.xml | 2 +- maven-resolver-provider/pom.xml | 2 +- maven-settings-builder/pom.xml | 2 +- maven-settings/pom.xml | 2 +- maven-slf4j-provider/pom.xml | 2 +- pom.xml | 6 +++--- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index f8be416504c6..7ff4127676e2 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5-SNAPSHOT + 3.8.5 apache-maven diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml index 0ced0ebe53f0..fe5ff2511103 100644 --- a/maven-artifact/pom.xml +++ b/maven-artifact/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5-SNAPSHOT + 3.8.5 maven-artifact diff --git a/maven-builder-support/pom.xml b/maven-builder-support/pom.xml index 9851384a8034..873a183d0dce 100644 --- a/maven-builder-support/pom.xml +++ b/maven-builder-support/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5-SNAPSHOT + 3.8.5 maven-builder-support diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml index c3715e6298be..f37f57af85a6 100644 --- a/maven-compat/pom.xml +++ b/maven-compat/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5-SNAPSHOT + 3.8.5 maven-compat diff --git a/maven-core/pom.xml b/maven-core/pom.xml index ab8c71379277..8936d2f339c2 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5-SNAPSHOT + 3.8.5 maven-core diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index c180c865ea66..179473f0e548 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5-SNAPSHOT + 3.8.5 maven-embedder diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml index bf0b0f9f256a..49f7fcaedd8f 100644 --- a/maven-model-builder/pom.xml +++ b/maven-model-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5-SNAPSHOT + 3.8.5 maven-model-builder diff --git a/maven-model/pom.xml b/maven-model/pom.xml index db70815c092a..727a4ca8ad2b 100644 --- a/maven-model/pom.xml +++ b/maven-model/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5-SNAPSHOT + 3.8.5 maven-model diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml index ab836127524a..c94e6e4c5f31 100644 --- a/maven-plugin-api/pom.xml +++ b/maven-plugin-api/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5-SNAPSHOT + 3.8.5 maven-plugin-api diff --git a/maven-repository-metadata/pom.xml b/maven-repository-metadata/pom.xml index a9951098471e..eae2debf3781 100644 --- a/maven-repository-metadata/pom.xml +++ b/maven-repository-metadata/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5-SNAPSHOT + 3.8.5 maven-repository-metadata diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml index 62ff3f26c60c..a3d38be2c40d 100644 --- a/maven-resolver-provider/pom.xml +++ b/maven-resolver-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5-SNAPSHOT + 3.8.5 maven-resolver-provider diff --git a/maven-settings-builder/pom.xml b/maven-settings-builder/pom.xml index 6391cf223fd1..a8c1624a348e 100644 --- a/maven-settings-builder/pom.xml +++ b/maven-settings-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5-SNAPSHOT + 3.8.5 maven-settings-builder diff --git a/maven-settings/pom.xml b/maven-settings/pom.xml index 36dd1923ab1f..e66f11f4915e 100644 --- a/maven-settings/pom.xml +++ b/maven-settings/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5-SNAPSHOT + 3.8.5 maven-settings diff --git a/maven-slf4j-provider/pom.xml b/maven-slf4j-provider/pom.xml index d12d0aedffba..33631c887de1 100644 --- a/maven-slf4j-provider/pom.xml +++ b/maven-slf4j-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5-SNAPSHOT + 3.8.5 maven-slf4j-provider diff --git a/pom.xml b/pom.xml index d2ad92952dfb..c319cae26c92 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven - 3.8.5-SNAPSHOT + 3.8.5 pom Apache Maven @@ -76,7 +76,7 @@ under the License. ref/3-LATEST None **/package-info.java - 2021-11-14T09:14:52Z + 2022-03-05T11:30:01Z @@ -100,7 +100,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven.git scm:git:https://gitbox.apache.org/repos/asf/maven.git https://github.com/apache/maven/tree/${project.scm.tag} - maven-3.8.3 + maven-3.8.5 jira From 0a6f12fba14161e1e0f5b5b4aa44715c9e451129 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 5 Mar 2022 12:41:16 +0100 Subject: [PATCH 134/183] [maven-release-plugin] prepare for next development iteration --- apache-maven/pom.xml | 2 +- maven-artifact/pom.xml | 2 +- maven-builder-support/pom.xml | 2 +- maven-compat/pom.xml | 2 +- maven-core/pom.xml | 2 +- maven-embedder/pom.xml | 2 +- maven-model-builder/pom.xml | 2 +- maven-model/pom.xml | 2 +- maven-plugin-api/pom.xml | 2 +- maven-repository-metadata/pom.xml | 2 +- maven-resolver-provider/pom.xml | 2 +- maven-settings-builder/pom.xml | 2 +- maven-settings/pom.xml | 2 +- maven-slf4j-provider/pom.xml | 2 +- pom.xml | 4 ++-- 15 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index 7ff4127676e2..faa32dd5c71d 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5 + 3.8.6-SNAPSHOT apache-maven diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml index fe5ff2511103..7866401e76c8 100644 --- a/maven-artifact/pom.xml +++ b/maven-artifact/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5 + 3.8.6-SNAPSHOT maven-artifact diff --git a/maven-builder-support/pom.xml b/maven-builder-support/pom.xml index 873a183d0dce..87cda74f150f 100644 --- a/maven-builder-support/pom.xml +++ b/maven-builder-support/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5 + 3.8.6-SNAPSHOT maven-builder-support diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml index f37f57af85a6..8aad7437a786 100644 --- a/maven-compat/pom.xml +++ b/maven-compat/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5 + 3.8.6-SNAPSHOT maven-compat diff --git a/maven-core/pom.xml b/maven-core/pom.xml index 8936d2f339c2..ec044904f9b0 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5 + 3.8.6-SNAPSHOT maven-core diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index 179473f0e548..50e8373cfb47 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5 + 3.8.6-SNAPSHOT maven-embedder diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml index 49f7fcaedd8f..253ac211c404 100644 --- a/maven-model-builder/pom.xml +++ b/maven-model-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5 + 3.8.6-SNAPSHOT maven-model-builder diff --git a/maven-model/pom.xml b/maven-model/pom.xml index 727a4ca8ad2b..34ad8c4c476a 100644 --- a/maven-model/pom.xml +++ b/maven-model/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5 + 3.8.6-SNAPSHOT maven-model diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml index c94e6e4c5f31..ee9e3a8595f4 100644 --- a/maven-plugin-api/pom.xml +++ b/maven-plugin-api/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5 + 3.8.6-SNAPSHOT maven-plugin-api diff --git a/maven-repository-metadata/pom.xml b/maven-repository-metadata/pom.xml index eae2debf3781..ca59f0b37b9f 100644 --- a/maven-repository-metadata/pom.xml +++ b/maven-repository-metadata/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5 + 3.8.6-SNAPSHOT maven-repository-metadata diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml index a3d38be2c40d..124e5cbb32e9 100644 --- a/maven-resolver-provider/pom.xml +++ b/maven-resolver-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5 + 3.8.6-SNAPSHOT maven-resolver-provider diff --git a/maven-settings-builder/pom.xml b/maven-settings-builder/pom.xml index a8c1624a348e..24d8170196ed 100644 --- a/maven-settings-builder/pom.xml +++ b/maven-settings-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5 + 3.8.6-SNAPSHOT maven-settings-builder diff --git a/maven-settings/pom.xml b/maven-settings/pom.xml index e66f11f4915e..5113a4f96aea 100644 --- a/maven-settings/pom.xml +++ b/maven-settings/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5 + 3.8.6-SNAPSHOT maven-settings diff --git a/maven-slf4j-provider/pom.xml b/maven-slf4j-provider/pom.xml index 33631c887de1..bc1369d7df55 100644 --- a/maven-slf4j-provider/pom.xml +++ b/maven-slf4j-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.5 + 3.8.6-SNAPSHOT maven-slf4j-provider diff --git a/pom.xml b/pom.xml index c319cae26c92..528306d1c362 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven - 3.8.5 + 3.8.6-SNAPSHOT pom Apache Maven @@ -76,7 +76,7 @@ under the License. ref/3-LATEST None **/package-info.java - 2022-03-05T11:30:01Z + 2022-03-05T11:41:15Z From 78ca83e2a4271421aa3fc4f8153f8f061b09d52f Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 6 Mar 2022 10:44:32 +0100 Subject: [PATCH 135/183] Bump version to 3.9.0-SNAPSHOT --- apache-maven/pom.xml | 2 +- maven-artifact/pom.xml | 2 +- maven-builder-support/pom.xml | 2 +- maven-compat/pom.xml | 2 +- maven-core/pom.xml | 2 +- maven-embedder/pom.xml | 2 +- maven-model-builder/pom.xml | 2 +- maven-model/pom.xml | 2 +- maven-plugin-api/pom.xml | 2 +- maven-repository-metadata/pom.xml | 2 +- maven-resolver-provider/pom.xml | 2 +- maven-settings-builder/pom.xml | 2 +- maven-settings/pom.xml | 2 +- maven-slf4j-provider/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index faa32dd5c71d..07add7ef1d3e 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.6-SNAPSHOT + 3.9.0-SNAPSHOT apache-maven diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml index 7866401e76c8..212e886ca1e8 100644 --- a/maven-artifact/pom.xml +++ b/maven-artifact/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.6-SNAPSHOT + 3.9.0-SNAPSHOT maven-artifact diff --git a/maven-builder-support/pom.xml b/maven-builder-support/pom.xml index 87cda74f150f..c01cc7ca1fb0 100644 --- a/maven-builder-support/pom.xml +++ b/maven-builder-support/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.6-SNAPSHOT + 3.9.0-SNAPSHOT maven-builder-support diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml index 8aad7437a786..4f79ac828cda 100644 --- a/maven-compat/pom.xml +++ b/maven-compat/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.6-SNAPSHOT + 3.9.0-SNAPSHOT maven-compat diff --git a/maven-core/pom.xml b/maven-core/pom.xml index ec044904f9b0..522f0669b1d6 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.6-SNAPSHOT + 3.9.0-SNAPSHOT maven-core diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index 50e8373cfb47..a8bcc51372e1 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.6-SNAPSHOT + 3.9.0-SNAPSHOT maven-embedder diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml index 253ac211c404..a2ba1b00617a 100644 --- a/maven-model-builder/pom.xml +++ b/maven-model-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.6-SNAPSHOT + 3.9.0-SNAPSHOT maven-model-builder diff --git a/maven-model/pom.xml b/maven-model/pom.xml index 34ad8c4c476a..702c9858cd36 100644 --- a/maven-model/pom.xml +++ b/maven-model/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.6-SNAPSHOT + 3.9.0-SNAPSHOT maven-model diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml index ee9e3a8595f4..4f94861ff4c4 100644 --- a/maven-plugin-api/pom.xml +++ b/maven-plugin-api/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.6-SNAPSHOT + 3.9.0-SNAPSHOT maven-plugin-api diff --git a/maven-repository-metadata/pom.xml b/maven-repository-metadata/pom.xml index ca59f0b37b9f..7567df5f6b82 100644 --- a/maven-repository-metadata/pom.xml +++ b/maven-repository-metadata/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.6-SNAPSHOT + 3.9.0-SNAPSHOT maven-repository-metadata diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml index 124e5cbb32e9..06c83834da04 100644 --- a/maven-resolver-provider/pom.xml +++ b/maven-resolver-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.6-SNAPSHOT + 3.9.0-SNAPSHOT maven-resolver-provider diff --git a/maven-settings-builder/pom.xml b/maven-settings-builder/pom.xml index 24d8170196ed..80d361cb464e 100644 --- a/maven-settings-builder/pom.xml +++ b/maven-settings-builder/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.6-SNAPSHOT + 3.9.0-SNAPSHOT maven-settings-builder diff --git a/maven-settings/pom.xml b/maven-settings/pom.xml index 5113a4f96aea..cbdc405aa3e0 100644 --- a/maven-settings/pom.xml +++ b/maven-settings/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.6-SNAPSHOT + 3.9.0-SNAPSHOT maven-settings diff --git a/maven-slf4j-provider/pom.xml b/maven-slf4j-provider/pom.xml index bc1369d7df55..1ffc40f58b33 100644 --- a/maven-slf4j-provider/pom.xml +++ b/maven-slf4j-provider/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven maven - 3.8.6-SNAPSHOT + 3.9.0-SNAPSHOT maven-slf4j-provider diff --git a/pom.xml b/pom.xml index 528306d1c362..bc0377b3ccb6 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven - 3.8.6-SNAPSHOT + 3.9.0-SNAPSHOT pom Apache Maven From 52b718614ab379dd909e70e4db3b00da54b91263 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 28 Aug 2021 21:45:23 +0200 Subject: [PATCH 136/183] [MNG-6399] Lift JDK minimum to JDK 8 --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index bc0377b3ccb6..f9d305585cdb 100644 --- a/pom.xml +++ b/pom.xml @@ -47,8 +47,8 @@ under the License. 3.0.5 - 1.7 - 1.7 + 1.8 + 1.8 2.6.0 1.4 3.8.1 @@ -580,11 +580,11 @@ under the License. org.codehaus.mojo animal-sniffer-maven-plugin - 1.17 + 1.20 org.codehaus.mojo.signature - java17 + java18 1.0 From 453c17371319e985d3a6caba84ae240bb33d6870 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 25 Apr 2021 22:51:01 +0200 Subject: [PATCH 137/183] [MNG-7247] Upgrade Maven Resolver to 1.7.2 --- ...recognized-javax.annotation-api-1.3.2.txt} | 0 .../internal/DefaultVersionRangeResolver.java | 2 +- .../internal/DefaultVersionResolver.java | 2 +- .../internal/MavenAetherModule.java | 80 ------------------- .../internal/MavenRepositorySystemUtils.java | 2 + pom.xml | 6 +- 6 files changed, 7 insertions(+), 85 deletions(-) rename apache-maven/src/main/appended-resources/licenses/{unrecognized-javax.annotation-api-1.2.txt => unrecognized-javax.annotation-api-1.3.2.txt} (100%) delete mode 100644 maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenAetherModule.java diff --git a/apache-maven/src/main/appended-resources/licenses/unrecognized-javax.annotation-api-1.2.txt b/apache-maven/src/main/appended-resources/licenses/unrecognized-javax.annotation-api-1.3.2.txt similarity index 100% rename from apache-maven/src/main/appended-resources/licenses/unrecognized-javax.annotation-api-1.2.txt rename to apache-maven/src/main/appended-resources/licenses/unrecognized-javax.annotation-api-1.3.2.txt diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java index 83c82a038598..d870fbb951f4 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java @@ -28,7 +28,6 @@ import org.eclipse.aether.SyncContext; import org.eclipse.aether.impl.MetadataResolver; import org.eclipse.aether.impl.RepositoryEventDispatcher; -import org.eclipse.aether.impl.SyncContextFactory; import org.eclipse.aether.impl.VersionRangeResolver; import org.eclipse.aether.metadata.DefaultMetadata; import org.eclipse.aether.metadata.Metadata; @@ -42,6 +41,7 @@ import org.eclipse.aether.resolution.VersionRangeResult; import org.eclipse.aether.spi.locator.Service; import org.eclipse.aether.spi.locator.ServiceLocator; +import org.eclipse.aether.spi.synccontext.SyncContextFactory; import org.eclipse.aether.util.version.GenericVersionScheme; import org.eclipse.aether.version.InvalidVersionSpecificationException; import org.eclipse.aether.version.Version; diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java index d307c55a69f1..9f1680726c17 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java @@ -33,7 +33,6 @@ import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.impl.MetadataResolver; import org.eclipse.aether.impl.RepositoryEventDispatcher; -import org.eclipse.aether.impl.SyncContextFactory; import org.eclipse.aether.impl.VersionResolver; import org.eclipse.aether.metadata.DefaultMetadata; import org.eclipse.aether.metadata.Metadata; @@ -49,6 +48,7 @@ import org.eclipse.aether.resolution.VersionResult; import org.eclipse.aether.spi.locator.Service; import org.eclipse.aether.spi.locator.ServiceLocator; +import org.eclipse.aether.spi.synccontext.SyncContextFactory; import org.eclipse.aether.util.ConfigUtils; import javax.inject.Inject; diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenAetherModule.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenAetherModule.java deleted file mode 100644 index 41e98aaea8ae..000000000000 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenAetherModule.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.apache.maven.repository.internal; - -/* - * 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 java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.apache.maven.model.building.DefaultModelBuilderFactory; -import org.apache.maven.model.building.ModelBuilder; -import org.eclipse.aether.impl.AetherModule; -import org.eclipse.aether.impl.ArtifactDescriptorReader; -import org.eclipse.aether.impl.MetadataGeneratorFactory; -import org.eclipse.aether.impl.VersionRangeResolver; -import org.eclipse.aether.impl.VersionResolver; - -import com.google.inject.AbstractModule; -import com.google.inject.Provides; -import com.google.inject.name.Names; - -/** - * @deprecated As of Maven Resolver 1.0.3, please use class {@link MavenResolverModule}. - */ -@Deprecated -public final class MavenAetherModule - extends AbstractModule -{ - - @Override - protected void configure() - { - install( new AetherModule() ); - bind( ArtifactDescriptorReader.class ) // - .to( DefaultArtifactDescriptorReader.class ).in( Singleton.class ); - bind( VersionResolver.class ) // - .to( DefaultVersionResolver.class ).in( Singleton.class ); - bind( VersionRangeResolver.class ) // - .to( DefaultVersionRangeResolver.class ).in( Singleton.class ); - bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "snapshot" ) ) // - .to( SnapshotMetadataGeneratorFactory.class ).in( Singleton.class ); - bind( MetadataGeneratorFactory.class ).annotatedWith( Names.named( "versions" ) ) // - .to( VersionsMetadataGeneratorFactory.class ).in( Singleton.class ); - bind( ModelBuilder.class ) // - .toInstance( new DefaultModelBuilderFactory().newInstance() ); - } - - @Provides - @Singleton - Set provideMetadataGeneratorFactories( @Named( "snapshot" ) - MetadataGeneratorFactory snapshot, - @Named( "versions" ) - MetadataGeneratorFactory versions ) - { - Set factories = new HashSet<>(); - factories.add( snapshot ); - factories.add( versions ); - return Collections.unmodifiableSet( factories ); - } - -} diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java index 97035b3cc821..b073e2d1e5bb 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java @@ -68,7 +68,9 @@ private MavenRepositorySystemUtils() * acquire a complete repository system, clients need to add some repository connectors for remote transfers. * * @return The new service locator, never {@code null}. + * @deprecated This method is deprecated along with {@link DefaultServiceLocator} (since Maven Resolver 1.7.0). */ + @Deprecated public static DefaultServiceLocator newServiceLocator() { DefaultServiceLocator locator = new DefaultServiceLocator(); diff --git a/pom.xml b/pom.xml index f9d305585cdb..f6f9b6c829e4 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ under the License. 2.0 1.11 1.3 - 1.6.3 + 1.7.2 1.7.32 2.2.1 1.7.4 @@ -268,7 +268,7 @@ under the License. javax.annotation javax.annotation-api - 1.2 + 1.3.2 org.codehaus.plexus @@ -545,7 +545,7 @@ under the License. ! Excluded the license files itself cause they do not have have a license of themselves. --> src/main/appended-resources/licenses/EPL-1.0.txt - src/main/appended-resources/licenses/unrecognized-javax.annotation-api-1.2.txt + src/main/appended-resources/licenses/unrecognized-javax.annotation-api-1.3.2.txt From 6ddb75138dd6bb41b77fae6d5b3ae789a0c4377d Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 6 Mar 2022 11:08:52 +0100 Subject: [PATCH 138/183] Remove unnecessary plugin dependency --- pom.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pom.xml b/pom.xml index f6f9b6c829e4..c0ec2d89baff 100644 --- a/pom.xml +++ b/pom.xml @@ -626,13 +626,6 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - - - org.codehaus.mojo - extra-enforcer-rules - 1.4 - - From e820dbb24e22e12fa058c59c6b3cf555da07abb5 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 6 Mar 2022 12:16:03 +0100 Subject: [PATCH 139/183] [MNG-6878] Upgrade Guice to 4.2.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c0ec2d89baff..9781f29d9046 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ under the License. 2.1.0 1.26 3.3.0 - 4.2.2 + 4.2.3 0.3.5 3.5.1 2.0 From e1b46e233930b46f83bc47c373beb41681bb6972 Mon Sep 17 00:00:00 2001 From: boris-unckel Date: Tue, 5 Jan 2021 23:00:26 +0100 Subject: [PATCH 140/183] [MNG-7068] Active dependency management for Google Guice/Guava This closes #462 --- maven-core/pom.xml | 8 +++++ maven-embedder/pom.xml | 58 +++++++++++++-------------------- maven-model-builder/pom.xml | 10 ++++++ maven-resolver-provider/pom.xml | 14 ++++++++ pom.xml | 46 ++++++++++++++++++++++++++ 5 files changed, 101 insertions(+), 35 deletions(-) diff --git a/maven-core/pom.xml b/maven-core/pom.xml index 522f0669b1d6..5d7c10a0d9ee 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -105,6 +105,14 @@ under the License. guice no_aop + + com.google.guava + guava + + + com.google.guava + failureaccess + javax.inject javax.inject diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index a8bcc51372e1..6792e6219b1a 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -75,41 +75,29 @@ under the License. maven-shared-utils - com.google.inject - guice - no_aop - - - aopalliance - aopalliance - - - - com.google.code.findbugs - jsr305 - - - org.checkerframework - checker-compat-qual - - - com.google.errorprone - error_prone_annotations - - - com.google.j2objc - j2objc-annotations - - - org.codehaus.mojo - animal-sniffer-annotations - - - org.checkerframework - checker-qual - - - + com.google.inject + guice + no_aop + + + aopalliance + aopalliance + + + + com.google.guava + guava + + + + + com.google.guava + guava + + + com.google.guava + failureaccess + javax.inject javax.inject diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml index a2ba1b00617a..cd432cb115fd 100644 --- a/maven-model-builder/pom.xml +++ b/maven-model-builder/pom.xml @@ -74,6 +74,16 @@ under the License. no_aop test + + com.google.guava + guava + test + + + com.google.guava + failureaccess + test + org.xmlunit xmlunit-core diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml index 06c83834da04..2b9422ca3e4e 100644 --- a/maven-resolver-provider/pom.xml +++ b/maven-resolver-provider/pom.xml @@ -80,8 +80,22 @@ under the License. aopalliance aopalliance + + com.google.guava + guava + + + com.google.guava + guava + true + + + com.google.guava + failureaccess + true + org.apache.maven.resolver diff --git a/pom.xml b/pom.xml index 9781f29d9046..0815f331a40b 100644 --- a/pom.xml +++ b/pom.xml @@ -58,6 +58,8 @@ under the License. 1.26 3.3.0 4.2.3 + 30.1-jre + 1.0.1 0.3.5 3.5.1 2.0 @@ -243,6 +245,50 @@ under the License. guice ${guiceVersion} no_aop + + + com.google.guava + guava + + + + + + com.google.guava + guava + ${guavaVersion} + + + com.google.code.findbugs + jsr305 + + + com.google.errorprone + error_prone_annotations + + + com.google.guava + failureaccess + + + com.google.guava + listenablefuture + + + com.google.j2objc + j2objc-annotations + + + org.checkerframework + checker-qual + + + + + + com.google.guava + failureaccess + ${guavafailureaccessVersion} org.eclipse.sisu From 7d6f281fe3a4ccdc532c84d421c2680cfb79a68d Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 15 Dec 2019 04:15:13 +0100 Subject: [PATCH 141/183] [MNG-6826] Remove condition check for JDK8+ in FileSizeFormatTest --- .../cli/transfer/FileSizeFormatTest.java | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/maven-embedder/src/test/java/org/apache/maven/cli/transfer/FileSizeFormatTest.java b/maven-embedder/src/test/java/org/apache/maven/cli/transfer/FileSizeFormatTest.java index a870411b64f6..e595aceb9108 100644 --- a/maven-embedder/src/test/java/org/apache/maven/cli/transfer/FileSizeFormatTest.java +++ b/maven-embedder/src/test/java/org/apache/maven/cli/transfer/FileSizeFormatTest.java @@ -21,13 +21,11 @@ import java.util.Locale; -import org.apache.commons.lang3.JavaVersion; -import org.apache.commons.lang3.SystemUtils; import org.apache.maven.cli.transfer.AbstractMavenTransferListener.FileSizeFormat; import org.apache.maven.cli.transfer.AbstractMavenTransferListener.FileSizeFormat.ScaleUnit; +import org.junit.Test; import static org.junit.Assert.assertEquals; -import org.junit.Test; public class FileSizeFormatTest { @@ -136,10 +134,7 @@ public void testSizeWithSelectedScaleUnit() long _50_bytes = 50L; assertEquals( "50 B", format.format( _50_bytes ) ); assertEquals( "50 B", format.format( _50_bytes, ScaleUnit.BYTE ) ); - if ( SystemUtils.isJavaVersionAtLeast( JavaVersion.JAVA_1_8 ) ) - { - assertEquals( "0.1 kB", format.format( _50_bytes, ScaleUnit.KILOBYTE ) ); - } + assertEquals( "0.1 kB", format.format( _50_bytes, ScaleUnit.KILOBYTE ) ); assertEquals( "0 MB", format.format( _50_bytes, ScaleUnit.MEGABYTE ) ); assertEquals( "0 GB", format.format( _50_bytes, ScaleUnit.GIGABYTE ) ); @@ -168,10 +163,7 @@ public void testSizeWithSelectedScaleUnit() assertEquals( "50 kB", format.format( _50_kilobytes ) ); assertEquals( "50000 B", format.format( _50_kilobytes, ScaleUnit.BYTE ) ); assertEquals( "50 kB", format.format( _50_kilobytes, ScaleUnit.KILOBYTE ) ); - if ( SystemUtils.isJavaVersionAtLeast( JavaVersion.JAVA_1_8 ) ) - { - assertEquals( "0.1 MB", format.format( _50_kilobytes, ScaleUnit.MEGABYTE ) ); - } + assertEquals( "0.1 MB", format.format( _50_kilobytes, ScaleUnit.MEGABYTE ) ); assertEquals( "0 GB", format.format( _50_kilobytes, ScaleUnit.GIGABYTE ) ); long _999_kilobytes = 999L * 1000L; @@ -200,10 +192,7 @@ public void testSizeWithSelectedScaleUnit() assertEquals( "50000000 B", format.format( _50_megabytes, ScaleUnit.BYTE ) ); assertEquals( "50000 kB", format.format( _50_megabytes, ScaleUnit.KILOBYTE ) ); assertEquals( "50 MB", format.format( _50_megabytes, ScaleUnit.MEGABYTE ) ); - if ( SystemUtils.isJavaVersionAtLeast( JavaVersion.JAVA_1_8 ) ) - { - assertEquals( "0.1 GB", format.format( _50_megabytes, ScaleUnit.GIGABYTE ) ); - } + assertEquals( "0.1 GB", format.format( _50_megabytes, ScaleUnit.GIGABYTE ) ); long _999_megabytes = 999L * 1000L * 1000L; assertEquals( "999 MB", format.format( _999_megabytes ) ); @@ -310,4 +299,4 @@ public void testProgressedSizeWithSize() assertEquals( "15 GB", format.formatProgress( _15_gigabytes, _15_gigabytes ) ); } -} +} \ No newline at end of file From 6b7beb4db8ad15f1ed26c08df32d6ac1ae96ac0c Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 13 Nov 2020 19:49:35 +0100 Subject: [PATCH 142/183] [MNG-7019] Notify also at start when profile is missing --- maven-core/src/main/java/org/apache/maven/DefaultMaven.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index 12b8f4ac7b4e..7447b8ca5640 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -291,6 +291,8 @@ private MavenExecutionResult doExecute( MavenExecutionRequest request, MavenSess validatePrerequisitesForNonMavenPluginProjects( session.getProjects() ); + validateActivatedProfiles( session.getProjects(), request.getActiveProfiles() ); + lifecycleStarter.execute( session ); validateActivatedProfiles( session.getProjects(), request.getActiveProfiles() ); From a55300a588d3694966fd797323304e1ed0bc6de1 Mon Sep 17 00:00:00 2001 From: mickroll Date: Mon, 3 Aug 2020 12:38:34 +0200 Subject: [PATCH 143/183] [MNG-6972] Allow access to org.apache.maven.graph This is, for example, needed for rebuilding the dependency graph during build extension execution after changing dependencies. This closes #368 --- maven-core/src/main/resources/META-INF/maven/extension.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/maven-core/src/main/resources/META-INF/maven/extension.xml b/maven-core/src/main/resources/META-INF/maven/extension.xml index 73bee382de9c..905e132bdd2d 100644 --- a/maven-core/src/main/resources/META-INF/maven/extension.xml +++ b/maven-core/src/main/resources/META-INF/maven/extension.xml @@ -30,6 +30,7 @@ under the License. org.apache.maven.exception org.apache.maven.execution org.apache.maven.execution.scope + org.apache.maven.graph org.apache.maven.lifecycle org.apache.maven.model org.apache.maven.monitor From 1954d51ff2841045b4af8a515ad0719805269d8d Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 26 Nov 2021 13:41:27 +0100 Subject: [PATCH 144/183] [MNG-7391] add execution strategy+runner required by Maven Build Cache --- .../maven/lifecycle/DefaultLifecycles.java | 5 +- .../DefaultLifecyclePluginAnalyzer.java | 24 +--------- .../lifecycle/internal/MojoExecutor.java | 25 +++++++--- .../plugin/DefaultMojosExecutionStrategy.java | 46 +++++++++++++++++++ .../maven/plugin/MojoExecutionRunner.java | 36 +++++++++++++++ .../maven/plugin/MojosExecutionStrategy.java | 45 ++++++++++++++++++ .../internal/DefaultMavenPluginManager.java | 15 ++++++ .../lifecycle/DefaultLifecyclesTest.java | 8 ++-- .../internal/stub/MojoExecutorStub.java | 13 ++---- 9 files changed, 175 insertions(+), 42 deletions(-) create mode 100644 maven-core/src/main/java/org/apache/maven/plugin/DefaultMojosExecutionStrategy.java create mode 100644 maven-core/src/main/java/org/apache/maven/plugin/MojoExecutionRunner.java create mode 100644 maven-core/src/main/java/org/apache/maven/plugin/MojosExecutionStrategy.java diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java index a7d9facb2e90..1a13365c8c0b 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java @@ -43,7 +43,7 @@ @Component( role = DefaultLifecycles.class ) public class DefaultLifecycles { - public static final String[] STANDARD_LIFECYCLES = { "default", "clean", "site" }; + public static final String[] STANDARD_LIFECYCLES = { "clean", "default", "site" }; // @Configuration(source="org/apache/maven/lifecycle/lifecycles.xml") @@ -108,6 +108,9 @@ public Map getPhaseToLifecycleMap() return phaseToLifecycleMap; } + /** + * Returns an ordered list of lifecycles + */ public List getLifeCycles() { // ensure canonical order of standard lifecycles diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecyclePluginAnalyzer.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecyclePluginAnalyzer.java index 67a9057d6e4e..8c99d6729bfb 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecyclePluginAnalyzer.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecyclePluginAnalyzer.java @@ -35,9 +35,6 @@ import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; @@ -98,7 +95,7 @@ public Set getPluginsBoundByDefaultToAllLifecycles( String packaging ) Map plugins = new LinkedHashMap<>(); - for ( Lifecycle lifecycle : getOrderedLifecycles() ) + for ( Lifecycle lifecycle : defaultLifeCycles.getLifeCycles() ) { org.apache.maven.lifecycle.mapping.Lifecycle lifecycleConfiguration = lifecycleMappingForPackaging.getLifecycles().get( lifecycle.getId() ); @@ -131,25 +128,6 @@ else if ( lifecycle.getDefaultLifecyclePhases() != null ) return plugins.keySet(); } - private List getOrderedLifecycles() - { - // NOTE: The lifecycle order can affect implied execution ids so we better be deterministic. - - List lifecycles = new ArrayList<>( defaultLifeCycles.getLifeCycles() ); - - Collections.sort( lifecycles, new Comparator() - { - - public int compare( Lifecycle l1, Lifecycle l2 ) - { - return l1.getId().compareTo( l2.getId() ); - } - - } ); - - return lifecycles; - } - private void parseLifecyclePhaseDefinitions( Map plugins, String phase, LifecyclePhase goals ) { String modelId = "org.apache.maven:maven-core:" + this.getClass().getPackage().getImplementationVersion() diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java index cf97c8cab954..f81c71376d19 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java @@ -30,6 +30,8 @@ import org.apache.maven.plugin.MavenPluginManager; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoExecutionRunner; +import org.apache.maven.plugin.MojosExecutionStrategy; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.PluginConfigurationException; import org.apache.maven.plugin.PluginIncompatibleException; @@ -85,6 +87,9 @@ public class MojoExecutor private final ReadWriteLock aggregatorLock = new ReentrantReadWriteLock(); + @Requirement + private MojosExecutionStrategy mojosExecutionStrategy; + public MojoExecutor() { } @@ -144,21 +149,27 @@ else if ( Artifact.SCOPE_TEST.equals( classpath ) ) return Collections.unmodifiableCollection( scopes ); } - public void execute( MavenSession session, List mojoExecutions, ProjectIndex projectIndex ) + public void execute( final MavenSession session, + final List mojoExecutions, + final ProjectIndex projectIndex ) throws LifecycleExecutionException { - DependencyContext dependencyContext = newDependencyContext( session, mojoExecutions ); + final DependencyContext dependencyContext = newDependencyContext( session, mojoExecutions ); - PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() ); + final PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() ); - for ( MojoExecution mojoExecution : mojoExecutions ) + mojosExecutionStrategy.execute( mojoExecutions, session, new MojoExecutionRunner() { - execute( session, mojoExecution, projectIndex, dependencyContext, phaseRecorder ); - } + @Override + public void run( MojoExecution mojoExecution ) throws LifecycleExecutionException + { + MojoExecutor.this.execute( session, mojoExecution, projectIndex, dependencyContext, phaseRecorder ); + } + } ); } - public void execute( MavenSession session, MojoExecution mojoExecution, ProjectIndex projectIndex, + private void execute( MavenSession session, MojoExecution mojoExecution, ProjectIndex projectIndex, DependencyContext dependencyContext, PhaseRecorder phaseRecorder ) throws LifecycleExecutionException { diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultMojosExecutionStrategy.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultMojosExecutionStrategy.java new file mode 100644 index 000000000000..9507c7ad17c0 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultMojosExecutionStrategy.java @@ -0,0 +1,46 @@ +package org.apache.maven.plugin; + +/* + * 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.execution.MavenSession; +import org.apache.maven.lifecycle.LifecycleExecutionException; + +import javax.inject.Named; +import javax.inject.Singleton; +import java.util.List; + +/** + * Default mojo execution strategy. It just iterates over mojo executions and runs one by one + */ +@Named +@Singleton +public class DefaultMojosExecutionStrategy implements MojosExecutionStrategy +{ + @Override + public void execute( List mojos, MavenSession session, MojoExecutionRunner mojoRunner ) + throws LifecycleExecutionException + { + for ( MojoExecution mojoExecution : mojos ) + { + mojoRunner.run( mojoExecution ); + } + + } +} diff --git a/maven-core/src/main/java/org/apache/maven/plugin/MojoExecutionRunner.java b/maven-core/src/main/java/org/apache/maven/plugin/MojoExecutionRunner.java new file mode 100644 index 000000000000..314e041a71b2 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/plugin/MojoExecutionRunner.java @@ -0,0 +1,36 @@ +package org.apache.maven.plugin; + +/* + * 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.lifecycle.LifecycleExecutionException; + +/** + * Provides context for mojo execution. Invocation of #run will result in actual execution + */ +public interface MojoExecutionRunner +{ + /** + * Runs mojo execution + * + * @param execution mojo execution + * @throws LifecycleExecutionException + */ + void run( MojoExecution execution ) throws LifecycleExecutionException; +} diff --git a/maven-core/src/main/java/org/apache/maven/plugin/MojosExecutionStrategy.java b/maven-core/src/main/java/org/apache/maven/plugin/MojosExecutionStrategy.java new file mode 100644 index 000000000000..e4babf68d7db --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/plugin/MojosExecutionStrategy.java @@ -0,0 +1,45 @@ +package org.apache.maven.plugin; + +/* + * 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.execution.MavenSession; +import org.apache.maven.lifecycle.LifecycleExecutionException; + +import java.util.List; + +/** + * Interface allows overriding default mojo execution strategy For example it is possible wrap some mojo execution to + * decorate default functionality or skip some executions + */ +public interface MojosExecutionStrategy +{ + + /** + * Entry point to the execution strategy + * + * @param mojos list of mojos representing a project build + * @param session current session + * @param mojoExecutionRunner mojo execution task which must be invoked by a strategy to actually run it + * @throws LifecycleExecutionException + */ + void execute( List mojos, MavenSession session, MojoExecutionRunner mojoExecutionRunner ) + throws LifecycleExecutionException; + +} diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java index 86304714df1c..546f00435a36 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java @@ -498,6 +498,21 @@ public T getConfiguredMojo( Class mojoInterface, MavenSession session, Mo ClassRealm pluginRealm = pluginDescriptor.getClassRealm(); + if ( pluginRealm == null ) + { + try + { + setupPluginRealm( pluginDescriptor, session, null, null, null ); + } + catch ( PluginResolutionException e ) + { + String msg = "Cannot setup plugin realm [mojoDescriptor=" + mojoDescriptor.getId() + + ", pluginDescriptor=" + pluginDescriptor.getId() + "]"; + throw new PluginConfigurationException( pluginDescriptor, msg, e ); + } + pluginRealm = pluginDescriptor.getClassRealm(); + } + if ( logger.isDebugEnabled() ) { logger.debug( "Configuring mojo " + mojoDescriptor.getId() + " from plugin realm " + pluginRealm ); diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/DefaultLifecyclesTest.java b/maven-core/src/test/java/org/apache/maven/lifecycle/DefaultLifecyclesTest.java index 690532c77d85..d7a84d15a48c 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/DefaultLifecyclesTest.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/DefaultLifecyclesTest.java @@ -50,9 +50,11 @@ public void testLifecycle() { final List cycles = defaultLifeCycles.getLifeCycles(); assertNotNull( cycles ); - final Lifecycle lifecycle = cycles.get( 0 ); - assertEquals( "default", lifecycle.getId() ); - assertEquals( 23, lifecycle.getPhases().size() ); + final Lifecycle lifecycle0 = cycles.get( 0 ); + assertEquals( "clean", lifecycle0.getId() ); + final Lifecycle lifecycle1 = cycles.get( 1 ); + assertEquals( "default", lifecycle1.getId() ); + assertEquals( 23, lifecycle1.getPhases().size() ); } diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java index 763893e6ce9a..350dccd44b72 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java @@ -17,14 +17,13 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.LifecycleExecutionException; -import org.apache.maven.lifecycle.internal.DependencyContext; import org.apache.maven.lifecycle.internal.MojoExecutor; -import org.apache.maven.lifecycle.internal.PhaseRecorder; import org.apache.maven.lifecycle.internal.ProjectIndex; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; +import org.apache.maven.project.MavenProject; import java.util.ArrayList; import java.util.Collections; @@ -40,18 +39,16 @@ public class MojoExecutorStub public List executions = Collections.synchronizedList( new ArrayList() ); @Override - public void execute( MavenSession session, MojoExecution mojoExecution, ProjectIndex projectIndex, - DependencyContext dependencyContext, PhaseRecorder phaseRecorder ) + public void execute( MavenSession session, List mojoExecutions, ProjectIndex projectIndex ) throws LifecycleExecutionException { - executions.add( mojoExecution ); + executions.addAll( mojoExecutions ); } @Override - public void execute( MavenSession session, List mojoExecutions, ProjectIndex projectIndex ) - throws LifecycleExecutionException + public List executeForkedExecutions( MojoExecution mojoExecution, MavenSession session, ProjectIndex projectIndex ) throws LifecycleExecutionException { - executions.addAll(mojoExecutions); + return null; } From 14ca7234380f81e54a5643082816048f3b6b67cf Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 2 Dec 2021 14:45:17 +0100 Subject: [PATCH 145/183] [MNG-7350] Introduce a factory for ModelCache --- .../maven/project/DefaultProjectBuilder.java | 24 +++++++---- .../AbstractCoreMavenComponentTestCase.java | 4 +- .../DefaultArtifactDescriptorReader.java | 16 +++++++- .../internal/DefaultModelCacheFactory.java | 41 +++++++++++++++++++ .../internal/MavenRepositorySystemUtils.java | 1 + .../internal/MavenResolverModule.java | 1 + .../internal/ModelCacheFactory.java | 33 +++++++++++++++ 7 files changed, 107 insertions(+), 13 deletions(-) create mode 100644 maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCacheFactory.java create mode 100644 maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ModelCacheFactory.java diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java index 7e18f1ef3ce2..616dad121892 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java @@ -56,12 +56,14 @@ import org.apache.maven.model.building.ModelBuildingException; import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.model.building.ModelBuildingResult; +import org.apache.maven.model.building.ModelCache; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.building.ModelProcessor; import org.apache.maven.model.building.ModelSource; import org.apache.maven.model.building.StringModelSource; import org.apache.maven.model.resolution.ModelResolver; import org.apache.maven.repository.internal.ArtifactDescriptorUtils; +import org.apache.maven.repository.internal.ModelCacheFactory; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; @@ -111,7 +113,8 @@ public class DefaultProjectBuilder @Requirement private ProjectDependenciesResolver dependencyResolver; - private final ReactorModelCache modelCache = new ReactorModelCache(); + @Requirement + private ModelCacheFactory modelCacheFactory; // ---------------------------------------------------------------------- // MavenProjectBuilder Implementation @@ -122,7 +125,8 @@ public ProjectBuildingResult build( File pomFile, ProjectBuildingRequest request throws ProjectBuildingException { return build( pomFile, new FileModelSource( pomFile ), - new InternalConfig( request, null, useGlobalModelCache() ? getModelCache() : null ) ); + new InternalConfig( request, null, + useGlobalModelCache() ? createModelCache( request.getRepositorySession() ) : null ) ); } private boolean useGlobalModelCache() @@ -135,7 +139,8 @@ public ProjectBuildingResult build( ModelSource modelSource, ProjectBuildingRequ throws ProjectBuildingException { return build( null, modelSource, - new InternalConfig( request, null, useGlobalModelCache() ? getModelCache() : null ) ); + new InternalConfig( request, null, + useGlobalModelCache() ? createModelCache( request.getRepositorySession() ) : null ) ); } private ProjectBuildingResult build( File pomFile, ModelSource modelSource, InternalConfig config ) @@ -306,7 +311,8 @@ public ProjectBuildingResult build( Artifact artifact, boolean allowStubModel, P org.eclipse.aether.artifact.Artifact pomArtifact = RepositoryUtils.toArtifact( artifact ); pomArtifact = ArtifactDescriptorUtils.toPomArtifact( pomArtifact ); - InternalConfig config = new InternalConfig( request, null, useGlobalModelCache() ? getModelCache() : null ); + InternalConfig config = new InternalConfig( request, null, + useGlobalModelCache() ? createModelCache( request.getRepositorySession() ) : null ); boolean localProject; @@ -369,7 +375,7 @@ public List build( List pomFiles, boolean recursive ReactorModelPool modelPool = new ReactorModelPool(); InternalConfig config = new InternalConfig( request, modelPool, - useGlobalModelCache() ? getModelCache() : new ReactorModelCache() ); + useGlobalModelCache() ? createModelCache( request.getRepositorySession() ) : new ReactorModelCache() ); Map projectIndex = new HashMap<>( 256 ); @@ -1058,9 +1064,9 @@ class InternalConfig private final ReactorModelPool modelPool; - private final ReactorModelCache modelCache; + private final ModelCache modelCache; - InternalConfig( ProjectBuildingRequest request, ReactorModelPool modelPool, ReactorModelCache modelCache ) + InternalConfig( ProjectBuildingRequest request, ReactorModelPool modelPool, ModelCache modelCache ) { this.request = request; this.modelPool = modelPool; @@ -1073,9 +1079,9 @@ class InternalConfig } - private ReactorModelCache getModelCache() + private ModelCache createModelCache( RepositorySystemSession session ) { - return this.modelCache; + return modelCacheFactory.createCache( session ); } } diff --git a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java index 2feeae1a1291..db7a17f8ec63 100644 --- a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java +++ b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java @@ -146,6 +146,8 @@ protected MavenSession createMavenSession( File pom, Properties executionPropert .setSystemProperties( executionProperties ) .setUserProperties( new Properties() ); + initRepoSession( configuration ); + List projects = new ArrayList<>(); if ( pom != null ) @@ -174,8 +176,6 @@ protected MavenSession createMavenSession( File pom, Properties executionPropert projects.add( project ); } - initRepoSession( configuration ); - MavenSession session = new MavenSession( getContainer(), configuration.getRepositorySession(), request, new DefaultMavenExecutionResult() ); diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java index 8d57b6086790..9e56b03b7c60 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java @@ -89,6 +89,8 @@ public class DefaultArtifactDescriptorReader private ModelBuilder modelBuilder; + private ModelCacheFactory modelCacheFactory; + public DefaultArtifactDescriptorReader() { // enable no-arg constructor @@ -97,7 +99,8 @@ public DefaultArtifactDescriptorReader() @Inject DefaultArtifactDescriptorReader( RemoteRepositoryManager remoteRepositoryManager, VersionResolver versionResolver, VersionRangeResolver versionRangeResolver, ArtifactResolver artifactResolver, - ModelBuilder modelBuilder, RepositoryEventDispatcher repositoryEventDispatcher ) + ModelBuilder modelBuilder, RepositoryEventDispatcher repositoryEventDispatcher, + ModelCacheFactory modelCacheFactory ) { setRemoteRepositoryManager( remoteRepositoryManager ); setVersionResolver( versionResolver ); @@ -105,6 +108,7 @@ public DefaultArtifactDescriptorReader() setArtifactResolver( artifactResolver ); setModelBuilder( modelBuilder ); setRepositoryEventDispatcher( repositoryEventDispatcher ); + setModelCacheFactory( modelCacheFactory ); } public void initService( ServiceLocator locator ) @@ -119,6 +123,7 @@ public void initService( ServiceLocator locator ) setModelBuilder( new DefaultModelBuilderFactory().newInstance() ); } setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) ); + setModelCacheFactory( locator.getService( ModelCacheFactory.class ) ); } public DefaultArtifactDescriptorReader setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager ) @@ -162,6 +167,13 @@ public DefaultArtifactDescriptorReader setModelBuilder( ModelBuilder modelBuilde return this; } + public DefaultArtifactDescriptorReader setModelCacheFactory( ModelCacheFactory modelCacheFactory ) + { + this.modelCacheFactory = Objects.requireNonNull( modelCacheFactory, + "modelCacheFactory cannot be null" ); + return this; + } + public ArtifactDescriptorResult readArtifactDescriptor( RepositorySystemSession session, ArtifactDescriptorRequest request ) throws ArtifactDescriptorException @@ -276,7 +288,7 @@ private Model loadPom( RepositorySystemSession session, ArtifactDescriptorReques modelRequest.setTwoPhaseBuilding( false ); modelRequest.setSystemProperties( toProperties( session.getSystemProperties() ) ); modelRequest.setUserProperties( toProperties( session.getUserProperties() ) ); - modelRequest.setModelCache( DefaultModelCache.newInstance( session ) ); + modelRequest.setModelCache( modelCacheFactory.createCache( session ) ); modelRequest.setModelResolver( new DefaultModelResolver( session, trace.newChild( modelRequest ), request.getRequestContext(), artifactResolver, versionRangeResolver, remoteRepositoryManager, diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCacheFactory.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCacheFactory.java new file mode 100644 index 000000000000..785a4e023582 --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelCacheFactory.java @@ -0,0 +1,41 @@ +package org.apache.maven.repository.internal; + +/* + * 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 javax.inject.Named; +import javax.inject.Singleton; + +import org.apache.maven.model.building.ModelCache; +import org.eclipse.aether.RepositorySystemSession; + +/** + * Default implementation of {@link ModelCacheFactory}. + */ +@Singleton +@Named +public class DefaultModelCacheFactory implements ModelCacheFactory +{ + @Override + public ModelCache createCache( RepositorySystemSession session ) + { + return DefaultModelCache.newInstance( session ); + } + +} diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java index b073e2d1e5bb..8fa3767f7a29 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java @@ -79,6 +79,7 @@ public static DefaultServiceLocator newServiceLocator() locator.addService( VersionRangeResolver.class, DefaultVersionRangeResolver.class ); locator.addService( MetadataGeneratorFactory.class, SnapshotMetadataGeneratorFactory.class ); locator.addService( MetadataGeneratorFactory.class, VersionsMetadataGeneratorFactory.class ); + locator.addService( ModelCacheFactory.class, DefaultModelCacheFactory.class ); return locator; } diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenResolverModule.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenResolverModule.java index 1e49bfce3586..c7120c99a46d 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenResolverModule.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenResolverModule.java @@ -56,6 +56,7 @@ protected void configure() .to( VersionsMetadataGeneratorFactory.class ).in( Singleton.class ); bind( ModelBuilder.class ).toInstance( new DefaultModelBuilderFactory().newInstance() ); + bind( ModelCacheFactory.class ).to( DefaultModelCacheFactory.class ).in( Singleton.class ); } @Provides diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ModelCacheFactory.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ModelCacheFactory.java new file mode 100644 index 000000000000..0e4299042ed2 --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/ModelCacheFactory.java @@ -0,0 +1,33 @@ +package org.apache.maven.repository.internal; + +/* + * 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.model.building.ModelCache; +import org.eclipse.aether.RepositorySystemSession; + +/** + * Factory for {@link ModelCache} objects. + */ +public interface ModelCacheFactory +{ + + ModelCache createCache( RepositorySystemSession session ); + +} From 5220420212cd576725c19be09f8b351a9625d11a Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 13 Mar 2022 13:04:19 +0100 Subject: [PATCH 146/183] Update DOAP with Maven 3.8.5 release --- doap_Maven.rdf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doap_Maven.rdf b/doap_Maven.rdf index 07185589da38..73754a7ec402 100644 --- a/doap_Maven.rdf +++ b/doap_Maven.rdf @@ -33,6 +33,15 @@ under the License. Latest stable release + 2022-03-05 + 3.8.5 + http://archive.apache.org/dist/maven/maven-3/3.8.5/binaries/apache-maven-3.8.5-bin.zip + http://archive.apache.org/dist/maven/maven-3/3.8.5/binaries/apache-maven-3.8.5-bin.tar.gz + http://archive.apache.org/dist/maven/maven-3/3.8.5/source/apache-maven-3.8.5-src.zip + http://archive.apache.org/dist/maven/maven-3/3.8.5/source/apache-maven-3.8.5-src.tar.gz + + + Apache Maven 3.8.4 2021-11-14 3.8.4 http://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.zip From 3a5a40c6d23bc4af7ab7945eaac0fa689d2c6143 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 15 Mar 2022 06:55:50 +0100 Subject: [PATCH 147/183] [MNG-7391] Fix MojosExecutionStrategy lookup to be able to look into the SessionScope (#692) --- .../maven/lifecycle/internal/MojoExecutor.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java index f81c71376d19..2980e885851b 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java @@ -38,8 +38,10 @@ import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.util.StringUtils; import org.eclipse.aether.SessionData; @@ -88,7 +90,7 @@ public class MojoExecutor private final ReadWriteLock aggregatorLock = new ReentrantReadWriteLock(); @Requirement - private MojosExecutionStrategy mojosExecutionStrategy; + private PlexusContainer container; public MojoExecutor() { @@ -159,7 +161,16 @@ public void execute( final MavenSession session, final PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() ); - mojosExecutionStrategy.execute( mojoExecutions, session, new MojoExecutionRunner() + MojosExecutionStrategy strategy; + try + { + strategy = container.lookup( MojosExecutionStrategy.class ); + } + catch ( ComponentLookupException e ) + { + throw new IllegalStateException( "Unable to lookup MojosExecutionStrategy", e ); + } + strategy.execute( mojoExecutions, session, new MojoExecutionRunner() { @Override public void run( MojoExecution mojoExecution ) throws LifecycleExecutionException From 88d29675ae2a0998d5be134c7941e8fd6aa706bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 13 Feb 2022 17:49:56 +0100 Subject: [PATCH 148/183] [MNG-7413] fix anchor for XML elements with same name but not content --- maven-model/src/main/mdo/maven.mdo | 18 +++++++++--------- pom.xml | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/maven-model/src/main/mdo/maven.mdo b/maven-model/src/main/mdo/maven.mdo index 5242d305353b..00bf3d51adef 100644 --- a/maven-model/src/main/mdo/maven.mdo +++ b/maven-model/src/main/mdo/maven.mdo @@ -43,8 +43,8 @@ | definition of these types | --> - maven @@ -642,11 +642,11 @@ - + BuildBase 3.0.0+ PluginConfiguration - Generic informations for a build. + Build configuration in a profile. defaultGoal @@ -1937,12 +1937,12 @@ - + DeploymentRepository Repository 4.0.0+ - Repository contains the information needed for deploying to the remote - repository. + Deployment repository contains the information needed for deploying to the remote + repository, which adds uniqueVersion property to usual repositories for download. uniqueVersion @@ -2807,13 +2807,13 @@ --> - + ReportPlugin 4.0.0+ ConfigurationContainer <plugin> element contains informations required for a report plugin. + The <plugin> element in <reporting><plugins> contains informations required for a report plugin. ]]> diff --git a/pom.xml b/pom.xml index 0815f331a40b..391131599d67 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ under the License. 3.5.1 2.0 2.0 - 1.11 + 2.0.0 1.3 1.7.2 1.7.32 From f7b073f3eb88e4e82d5ec10a91d2bf6b442c03c6 Mon Sep 17 00:00:00 2001 From: Jacky Date: Fri, 4 Mar 2022 23:09:54 +0800 Subject: [PATCH 149/183] =?UTF-8?q?[MNG-7445]=C2=A0-=20Refactoring,=20remo?= =?UTF-8?q?ve=20the=20useless=20line=20=20=20Contribution=20by=20JakcyHu?= =?UTF-8?q?=20Gakiii?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Karl Heinz Marbaise --- .../apache/maven/settings/DefaultMavenSettingsBuilder.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java b/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java index d3ffd925ec61..5b63317bf532 100644 --- a/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java @@ -147,12 +147,8 @@ private File getFile( String pathPattern, String basedirSysProp, String altLocat // --------------------------------------------------------------------------------- // path = path.replaceAll( "//", "/" ); - return new File( path ).getAbsoluteFile(); - } - else - { - return new File( path ).getAbsoluteFile(); } + return new File( path ).getAbsoluteFile(); } } From c604db3c3a103e2212f4628d8e2a997017fe579e Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Thu, 30 Sep 2021 19:10:44 +0200 Subject: [PATCH 150/183] [MNG-7447] - Several Improvements by using Stream API --- .../java/org/apache/maven/ReactorReader.java | 120 +++++++++--------- .../org/apache/maven/RepositoryUtils.java | 47 +++---- .../filter/ExclusionArtifactFilter.java | 53 ++++---- .../apache/maven/execution/MavenSession.java | 12 +- .../maven/extension/internal/CoreExports.java | 14 +- .../mapping/DefaultLifecycleMapping.java | 32 ++++- .../DefaultProfileActivationContext.java | 27 ++-- 7 files changed, 150 insertions(+), 155 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java index 84662ff87551..d5cc3d7a2ff1 100644 --- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java +++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java @@ -20,17 +20,17 @@ */ import java.io.File; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Named; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Collectors; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.execution.MavenSession; @@ -41,6 +41,13 @@ import org.eclipse.aether.repository.WorkspaceRepository; import org.eclipse.aether.util.artifact.ArtifactIdUtils; +import javax.inject.Inject; +import javax.inject.Named; + +import static java.util.function.Function.identity; +import static java.util.stream.Collectors.groupingBy; +import static java.util.stream.Collectors.toMap; + /** * An implementation of a workspace reader that knows how to search the Maven reactor for artifacts, either as packaged * jar if it has been built, or only compile output directory if packaging hasn't happened yet. @@ -57,32 +64,27 @@ class ReactorReader private static final Collection COMPILE_PHASE_TYPES = Arrays.asList( "jar", "ejb-client", "war", "rar", "ejb3", "par", "sar", "wsr", "har", "app-client" ); - private Map projectsByGAV; + private final MavenSession session; + private final Map projectsByGAV; + private final Map> projectsByGA; + private final WorkspaceRepository repository; - private Map> projectsByGA; + private Function projectIntoKey = + s -> ArtifactUtils.key( s.getGroupId(), s.getArtifactId(), s.getVersion() ); - private WorkspaceRepository repository; + private Function projectIntoVersionlessKey = + s -> ArtifactUtils.versionlessKey( s.getGroupId(), s.getArtifactId() ); @Inject ReactorReader( MavenSession session ) { - projectsByGAV = session.getProjectMap(); - - projectsByGA = new HashMap<>( projectsByGAV.size() * 2 ); - for ( MavenProject project : projectsByGAV.values() ) - { - String key = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); - - List projects = projectsByGA.get( key ); + this.session = session; + this.projectsByGAV = + session.getAllProjects().stream() + .collect( toMap( projectIntoKey, identity() ) ); - if ( projects == null ) - { - projects = new ArrayList<>( 1 ); - projectsByGA.put( key, projects ); - } - - projects.add( project ); - } + this.projectsByGA = projectsByGAV.values().stream() + .collect( groupingBy( projectIntoVersionlessKey ) ); repository = new WorkspaceRepository( "reactor", new HashSet<>( projectsByGAV.keySet() ) ); } @@ -119,23 +121,11 @@ public List findVersions( Artifact artifact ) { String key = ArtifactUtils.versionlessKey( artifact.getGroupId(), artifact.getArtifactId() ); - List projects = projectsByGA.get( key ); - if ( projects == null || projects.isEmpty() ) - { - return Collections.emptyList(); - } - - List versions = new ArrayList<>(); - - for ( MavenProject project : projects ) - { - if ( find( project, artifact ) != null ) - { - versions.add( project.getVersion() ); - } - } - - return Collections.unmodifiableList( versions ); + return Optional.ofNullable( projectsByGA.get( key ) ) + .orElse( Collections.emptyList() ).stream() + .filter( s -> Objects.nonNull( find( s, artifact ) ) ) + .map( MavenProject::getVersion ) + .collect( Collectors.collectingAndThen( Collectors.toList(), Collections::unmodifiableList ) ); } @Override @@ -190,6 +180,17 @@ else if ( !hasBeenPackaged( project ) ) return null; } + private File determinePreviouslyPackagedArtifactFile( MavenProject project, Artifact artifact ) + { + if ( artifact == null ) + { + return null; + } + + String fileName = String.format( "%s.%s", project.getBuild().getFinalName(), artifact.getExtension() ); + return new File( project.getBuild().getDirectory(), fileName ); + } + private boolean hasArtifactFileFromPackagePhase( Artifact projectArtifact ) { return projectArtifact != null && projectArtifact.getFile() != null && projectArtifact.getFile().exists(); @@ -218,28 +219,27 @@ private Artifact findMatchingArtifact( MavenProject project, Artifact requestedA return mainArtifact; } - for ( Artifact attachedArtifact : RepositoryUtils.toArtifacts( project.getAttachedArtifacts() ) ) - { - if ( attachedArtifactComparison( requestedArtifact, attachedArtifact ) ) - { - return attachedArtifact; - } - } - - return null; + return RepositoryUtils.toArtifacts( project.getAttachedArtifacts() ).stream() + .filter( isRequestedArtifact( requestedArtifact ) ) + .findFirst() + .orElse( null ); } - private boolean attachedArtifactComparison( Artifact requested, Artifact attached ) + /** + * We are taking as much as we can from the DefaultArtifact.equals(). The requested artifact has no file, so we want + * to remove that from the comparison. + * + * @param requestArtifact checked against the given artifact. + * @return true if equals, false otherwise. + */ + private Predicate isRequestedArtifact( Artifact requestArtifact ) { - // - // We are taking as much as we can from the DefaultArtifact.equals(). The requested artifact has no file so - // we want to remove that from the comparison. - // - return requested.getArtifactId().equals( attached.getArtifactId() ) - && requested.getGroupId().equals( attached.getGroupId() ) - && requested.getVersion().equals( attached.getVersion() ) - && requested.getExtension().equals( attached.getExtension() ) - && requested.getClassifier().equals( attached.getClassifier() ); + return s -> s.getArtifactId().equals( requestArtifact.getArtifactId() ) + && s.getGroupId().equals( requestArtifact.getGroupId() ) + && s.getVersion().equals( requestArtifact.getVersion() ) + && s.getExtension().equals( requestArtifact.getExtension() ) + && s.getClassifier().equals( requestArtifact.getClassifier() ); + } /** diff --git a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java index 80e58743a736..579315628a1b 100644 --- a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java +++ b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java @@ -26,6 +26,8 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.DefaultArtifactHandler; @@ -170,32 +172,21 @@ public static Dependency toDependency( org.apache.maven.artifact.Artifact artifa Artifact result = toArtifact( artifact ); - List excl = null; - if ( exclusions != null ) - { - excl = new ArrayList<>( exclusions.size() ); - for ( org.apache.maven.model.Exclusion exclusion : exclusions ) - { - excl.add( toExclusion( exclusion ) ); - } - } - + List excl = Optional.ofNullable( exclusions ) + .orElse( Collections.emptyList() ) + .stream() + .map( RepositoryUtils::toExclusion ) + .collect( Collectors.toList() ); return new Dependency( result, artifact.getScope(), artifact.isOptional(), excl ); } public static List toRepos( List repos ) { - if ( repos == null ) - { - return null; - } - - List results = new ArrayList<>( repos.size() ); - for ( ArtifactRepository repo : repos ) - { - results.add( toRepo( repo ) ); - } - return results; + return Optional.ofNullable( repos ) + .orElse( Collections.emptyList() ) + .stream() + .map( RepositoryUtils::toRepo ) + .collect( Collectors.toList() ); } public static RemoteRepository toRepo( ArtifactRepository repo ) @@ -316,11 +307,8 @@ public static Dependency toDependency( org.apache.maven.model.Dependency depende new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, dependency.getVersion(), props, stereotype ); - List exclusions = new ArrayList<>( dependency.getExclusions().size() ); - for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() ) - { - exclusions.add( toExclusion( exclusion ) ); - } + List exclusions = + dependency.getExclusions().stream().map( RepositoryUtils::toExclusion ).collect( Collectors.toList() ); Dependency result = new Dependency( artifact, dependency.getScope(), @@ -363,12 +351,7 @@ public ArtifactType get( String stereotypeId ) public static Collection toArtifacts( Collection artifactsToConvert ) { - List artifacts = new ArrayList<>(); - for ( org.apache.maven.artifact.Artifact a : artifactsToConvert ) - { - artifacts.add( toArtifact( a ) ); - } - return artifacts; + return artifactsToConvert.stream().map( RepositoryUtils::toArtifact ).collect( Collectors.toList() ); } public static WorkspaceRepository getWorkspace( RepositorySystemSession session ) diff --git a/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilter.java b/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilter.java index dd50c317481f..18d4e833a0f8 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilter.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilter.java @@ -19,11 +19,12 @@ * under the License. */ +import java.util.List; +import java.util.function.Predicate; + import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Exclusion; -import java.util.List; - /** * Filter to exclude from a list of artifact patterns. */ @@ -38,31 +39,33 @@ public ExclusionArtifactFilter( List exclusions ) this.exclusions = exclusions; } + private Predicate sameArtifactId( Artifact artifact ) + { + return exclusion -> exclusion.getArtifactId().equals( artifact.getArtifactId() ); + } + + private Predicate sameGroupId( Artifact artifact ) + { + return exclusion -> exclusion.getGroupId().equals( artifact.getGroupId() ); + } + + private Predicate groupIdIsWildcard = exclusion -> WILDCARD.equals( exclusion.getGroupId() ); + + private Predicate artifactIdIsWildcard = exclusion -> WILDCARD.equals( exclusion.getArtifactId() ); + + private Predicate groupIdAndArtifactIdIsWildcard = groupIdIsWildcard.and( artifactIdIsWildcard ); + + private Predicate exclude( Artifact artifact ) + { + return groupIdAndArtifactIdIsWildcard + .or( groupIdIsWildcard.and( sameArtifactId( artifact ) ) ) + .or( artifactIdIsWildcard.and( sameGroupId( artifact ) ) ) + .or( sameGroupId( artifact ).and( sameArtifactId( artifact ) ) ); + } + @Override public boolean include( Artifact artifact ) { - for ( Exclusion exclusion : exclusions ) - { - if ( WILDCARD.equals( exclusion.getGroupId() ) && WILDCARD.equals( exclusion.getArtifactId() ) ) - { - return false; - } - if ( WILDCARD.equals( exclusion.getGroupId() ) - && exclusion.getArtifactId().equals( artifact.getArtifactId() ) ) - { - return false; - } - if ( WILDCARD.equals( exclusion.getArtifactId() ) - && exclusion.getGroupId().equals( artifact.getGroupId() ) ) - { - return false; - } - if ( exclusion.getGroupId().equals( artifact.getGroupId() ) - && exclusion.getArtifactId().equals( artifact.getArtifactId() ) ) - { - return false; - } - } - return true; + return !exclusions.stream().anyMatch( exclude( artifact ) ); } } diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java index 5b56df36d003..98c5573c9736 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java @@ -84,15 +84,9 @@ public void setProjects( List projects ) if ( !projects.isEmpty() ) { this.currentProject = projects.get( 0 ); - this.topLevelProject = currentProject; - for ( MavenProject project : projects ) - { - if ( project.isExecutionRoot() ) - { - topLevelProject = project; - break; - } - } + this.topLevelProject = + projects.stream().filter( project -> project.isExecutionRoot() ).findFirst() + .orElse( currentProject ); } else { diff --git a/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java b/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java index 331617cfa232..b769c386788c 100644 --- a/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java +++ b/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java @@ -20,14 +20,16 @@ */ import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import org.codehaus.plexus.classworlds.realm.ClassRealm; +import static java.util.function.Function.identity; +import static java.util.stream.Collectors.collectingAndThen; +import static java.util.stream.Collectors.toMap; + /** * Provides information about artifacts (identified by groupId:artifactId string key) and classpath elements exported by * Maven core itself and loaded Maven core extensions. @@ -47,13 +49,9 @@ public CoreExports( CoreExtensionEntry entry ) public CoreExports( ClassRealm realm, Set exportedArtifacts, Set exportedPackages ) { - Map packages = new LinkedHashMap<>(); - for ( String pkg : exportedPackages ) - { - packages.put( pkg, realm ); - } this.artifacts = Collections.unmodifiableSet( new HashSet<>( exportedArtifacts ) ); - this.packages = Collections.unmodifiableMap( new HashMap<>( packages ) ); + this.packages = exportedPackages.stream().collect( + collectingAndThen( toMap( identity(), v -> realm ), Collections::unmodifiableMap ) ); } /** diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java index e12debef5fce..283a179d2530 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java @@ -19,10 +19,14 @@ * under the License. */ +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import static java.util.function.Function.identity; +import static java.util.stream.Collectors.toMap; + /** * DefaultLifecycleMapping */ @@ -38,7 +42,28 @@ public class DefaultLifecycleMapping private Map phases; /** - * Populates the lifecycle map from the injected list of lifecycle mappings (if not already done). + * Default ctor for plexus compatibility: lifecycles are most commonly defined in Plexus XML, that does field + * injection. Still, for Plexus to be able to instantiate this class, default ctor is needed. + * + * @deprecated Should not be used in Java code. + */ + @Deprecated + public DefaultLifecycleMapping() + { + } + + /** + * Ctor to be used in Java code/providers. + */ + public DefaultLifecycleMapping( final List lifecycles ) + { + this.lifecycleMap = Collections.unmodifiableMap( + lifecycles.stream().collect( toMap( Lifecycle::getId, identity() ) ) + ); + } + + /** + * Plexus: Populates the lifecycle map from the injected list of lifecycle mappings (if not already done). */ private void initLifecycleMap() { @@ -79,6 +104,7 @@ private void initLifecycleMap() } } + @Override public Map getLifecycles() { initLifecycleMap(); @@ -86,6 +112,8 @@ public Map getLifecycles() return lifecycleMap; } + @Deprecated + @Override public List getOptionalMojos( String lifecycle ) { return null; @@ -110,7 +138,7 @@ else if ( "default".equals( lifecycle ) ) return null; } } - + @Deprecated public Map getPhases( String lifecycle ) { diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java index 77d92a377c40..4fb1b265e3ec 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java @@ -21,12 +21,13 @@ import java.io.File; import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; +import static java.util.stream.Collectors.collectingAndThen; +import static java.util.stream.Collectors.toMap; + /** * Describes the environmental context used to determine the activation status of profiles. * @@ -230,8 +231,11 @@ public DefaultProfileActivationContext setProjectProperties( Properties projectP { if ( projectProperties != null ) { - - this.projectProperties = Collections.unmodifiableMap( toMap( projectProperties ) ); + this.projectProperties = projectProperties.entrySet().stream() + .collect( + collectingAndThen( + toMap( k -> String.valueOf( k.getKey() ), v -> String.valueOf( v ) ), + Collections::unmodifiableMap ) ); } else { @@ -241,19 +245,4 @@ public DefaultProfileActivationContext setProjectProperties( Properties projectP return this; } - private Map toMap( Properties properties ) - { - if ( properties == null ) - { - return Collections.emptyMap(); - } - Map map = new HashMap<>(); - Enumeration keys = properties.keys(); - while ( keys.hasMoreElements() ) - { - String key = (String) keys.nextElement(); - map.put( key, properties.getProperty( key ) ); - } - return map; - } } From a116f25002a0f5bb348a5416efd76e63ac54eb34 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Tue, 5 Apr 2022 21:57:14 +0200 Subject: [PATCH 151/183] [MNG-7452] - Remove JDK7 run on Maven 3.9.X Branch --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4d411dbbde7c..0978bee44d91 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,7 +23,7 @@ def buildOs = 'linux' def buildJdk = '8' def buildMvn = '3.6.0' def runITsOses = ['linux', 'windows'] -def runITsJdks = ['7', '8', '11','17'] +def runITsJdks = ['8', '11','17'] def runITsMvn = '3.6.0' def runITscommand = "mvn clean install -Prun-its,embedded -B -U -V" // -DmavenDistro=... -Dmaven.test.failure.ignore=true def tests From 083423fd50bd5aecc5e1ecf4350a99f30d9acfb3 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 8 Apr 2022 10:02:40 +0200 Subject: [PATCH 152/183] [MNG-7441] Update version of loback This issue is fluke, as logback is actually optional dependency, but still, to cut reports like these from root, let's do this update. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 391131599d67..e1c0acfef8e3 100644 --- a/pom.xml +++ b/pom.xml @@ -361,7 +361,7 @@ under the License. ch.qos.logback logback-classic - 1.2.1 + 1.2.11 true From 263cf9542b4f137c59ab19fb4fae9f0d61ce2afa Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 8 Apr 2022 10:32:15 +0200 Subject: [PATCH 153/183] [MNG-7432] Resolver session contains non-MavenWorkspaceReader (#695) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As Resolver session contains non-MavenWorkspaceReader, the reactor models (already resolved w/ profiles applied) are re-built when using Resolver within Mojo, instead to get them via ReactorReader as expected. The rebuilt models will lack explicit (-P on CLI) profiles applied, as resolver itself is not maven aware, hence there is no way to "tell" resolver to apply them. Building reactor models w/ profiles applied is NOT done using resolver, but by Maven when loading up reactor, as profiles are NOT applied for downstream transitive dependencies (see discussion on MNG-1388 why). Signed-off-by: Christoph Läubrich Co-authored-by: Christoph Läubrich Co-authored-by: Tamas Cservenak --- .../java/org/apache/maven/DefaultMaven.java | 6 +- .../aether/MavenChainedWorkspaceReader.java | 106 ++++++++++++++++++ .../org/apache/maven/DefaultMavenTest.java | 29 +++++ .../projects/default-maven/simple/pom.xml | 10 ++ 4 files changed, 147 insertions(+), 4 deletions(-) create mode 100644 maven-core/src/main/java/org/apache/maven/internal/aether/MavenChainedWorkspaceReader.java create mode 100644 maven-core/src/test/projects/default-maven/simple/pom.xml diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index 7447b8ca5640..0fc818e7489b 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -40,6 +40,7 @@ import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.graph.GraphBuilder; import org.apache.maven.internal.aether.DefaultRepositorySystemSessionFactory; +import org.apache.maven.internal.aether.MavenChainedWorkspaceReader; import org.apache.maven.lifecycle.internal.ExecutionEventCatapult; import org.apache.maven.lifecycle.internal.LifecycleStarter; import org.apache.maven.model.Prerequisites; @@ -58,7 +59,6 @@ import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.WorkspaceReader; -import org.eclipse.aether.util.repository.ChainedWorkspaceReader; /** * @author Jason van Zyl @@ -340,9 +340,7 @@ private void setupWorkspaceReader( MavenSession session, DefaultRepositorySystem } workspaceReaders.add( workspaceReader ); } - WorkspaceReader[] readers = workspaceReaders.toArray( new WorkspaceReader[0] ); - repoSession.setWorkspaceReader( new ChainedWorkspaceReader( readers ) ); - + repoSession.setWorkspaceReader( MavenChainedWorkspaceReader.of( workspaceReaders ) ); } private void afterSessionEnd( Collection projects, MavenSession session ) diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/MavenChainedWorkspaceReader.java b/maven-core/src/main/java/org/apache/maven/internal/aether/MavenChainedWorkspaceReader.java new file mode 100644 index 000000000000..4bc16a9271c8 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/internal/aether/MavenChainedWorkspaceReader.java @@ -0,0 +1,106 @@ +package org.apache.maven.internal.aether; + +/* + * 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 java.io.File; +import java.util.Collection; +import java.util.List; + +import org.apache.maven.model.Model; +import org.apache.maven.repository.internal.MavenWorkspaceReader; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.repository.WorkspaceReader; +import org.eclipse.aether.repository.WorkspaceRepository; +import org.eclipse.aether.util.repository.ChainedWorkspaceReader; + +/** + * A maven workspace reader that delegates to a chain of other readers, effectively aggregating their contents. + */ +public final class MavenChainedWorkspaceReader + implements MavenWorkspaceReader +{ + + private ChainedWorkspaceReader delegate; + + private WorkspaceReader[] readers; + + /** + * Creates a new workspace reader by chaining the specified readers. + * + * @param readers The readers to chain must not be {@code null}. + */ + private MavenChainedWorkspaceReader( WorkspaceReader... readers ) + { + this.delegate = new ChainedWorkspaceReader( readers ); + this.readers = readers; + } + + @Override + public Model findModel( Artifact artifact ) + { + for ( WorkspaceReader workspaceReader : readers ) + { + if ( workspaceReader instanceof MavenWorkspaceReader ) + { + Model model = ( (MavenWorkspaceReader) workspaceReader ).findModel( artifact ); + if ( model != null ) + { + return model; + } + } + } + return null; + } + + @Override + public WorkspaceRepository getRepository() + { + return delegate.getRepository(); + } + + @Override + public File findArtifact( Artifact artifact ) + { + return delegate.findArtifact( artifact ); + } + + @Override + public List findVersions( Artifact artifact ) + { + return delegate.findVersions( artifact ); + } + + /** + * chains a collection of {@link WorkspaceReader}s + * @param workspaceReaderCollection the collection of readers, might be empty but never null + * @return if the collection contains only one item returns the single item, otherwise creates a new + * {@link MavenChainedWorkspaceReader} chaining all readers in the order of the given collection. + */ + public static WorkspaceReader of( Collection workspaceReaderCollection ) + { + WorkspaceReader[] readers = workspaceReaderCollection.toArray( new WorkspaceReader[0] ); + if ( readers.length == 1 ) + { + return readers[0]; + } + return new MavenChainedWorkspaceReader( readers ); + } + +} diff --git a/maven-core/src/test/java/org/apache/maven/DefaultMavenTest.java b/maven-core/src/test/java/org/apache/maven/DefaultMavenTest.java index 1360d8e62316..a0a0b92b4495 100644 --- a/maven-core/src/test/java/org/apache/maven/DefaultMavenTest.java +++ b/maven-core/src/test/java/org/apache/maven/DefaultMavenTest.java @@ -4,11 +4,15 @@ import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionResult; +import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectHelper; +import org.apache.maven.repository.internal.MavenWorkspaceReader; +import org.codehaus.plexus.component.annotations.Component; import java.io.File; import java.nio.file.Files; +import java.util.concurrent.atomic.AtomicReference; import static java.util.Arrays.asList; @@ -33,6 +37,31 @@ public class DefaultMavenTest extends AbstractCoreMavenComponentTestCase { + @Component( role = AbstractMavenLifecycleParticipant.class, hint = "WsrClassCatcher" ) + private static final class WsrClassCatcher extends AbstractMavenLifecycleParticipant + { + private final AtomicReference> wsrClassRef = new AtomicReference<>( null ); + + @Override + public void afterProjectsRead( MavenSession session ) throws MavenExecutionException + { + wsrClassRef.set( session.getRepositorySession().getWorkspaceReader().getClass() ); + } + } + + public void testEnsureResolverSessionHasMavenWorkspaceReader() throws Exception + { + WsrClassCatcher wsrClassCatcher = ( WsrClassCatcher ) getContainer() + .lookup( AbstractMavenLifecycleParticipant.class, "WsrClassCatcher" ); + Maven maven = getContainer().lookup( Maven.class ); + MavenExecutionRequest request = createMavenExecutionRequest( getProject( "simple" ) ).setGoals( asList("validate") ); + + MavenExecutionResult result = maven.execute( request ); + + Class wsrClass = wsrClassCatcher.wsrClassRef.get(); + assertTrue( "is null", wsrClass != null ); + assertTrue( String.valueOf( wsrClass ), MavenWorkspaceReader.class.isAssignableFrom( wsrClass ) ); + } public void testThatErrorDuringProjectDependencyGraphCreationAreStored() throws Exception diff --git a/maven-core/src/test/projects/default-maven/simple/pom.xml b/maven-core/src/test/projects/default-maven/simple/pom.xml new file mode 100644 index 000000000000..0221f8208f28 --- /dev/null +++ b/maven-core/src/test/projects/default-maven/simple/pom.xml @@ -0,0 +1,10 @@ + + 4.0.0 + + simple + simple + 1.0-SNAPSHOT + pom + + From 08dff22a41e79c0da5fdda3f61699c788001b608 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 8 Apr 2022 18:24:03 +0200 Subject: [PATCH 154/183] [MNG-7447] Fix ReactorReader unintended change (#709) The commit c604db3c3a103e2212f4628d8e2a997017fe579e changed ReactorReader to use MavenSession#getAllProjects() instead of deprecated MavenSession#getProjectMap() that is equivalent of MavenSession#getProjects(). This undoes this unintended change. --- maven-core/src/main/java/org/apache/maven/ReactorReader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java index d5cc3d7a2ff1..66f9f3a8d4a3 100644 --- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java +++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java @@ -80,7 +80,7 @@ class ReactorReader { this.session = session; this.projectsByGAV = - session.getAllProjects().stream() + session.getProjects().stream() .collect( toMap( projectIntoKey, identity() ) ); this.projectsByGA = projectsByGAV.values().stream() From ff0300b7cfdb983fd4c54c60d956cbee79412849 Mon Sep 17 00:00:00 2001 From: Gabriel Belingueres Date: Mon, 9 Sep 2019 00:36:13 -0300 Subject: [PATCH 155/183] [MNG-5222] Maven 3 no longer logs warnings about deprecated plugin parameters - Added warning when setting deprecated parameter with value different than the default. - Changed Logger to SLF4J. (cherry picked from commit c99028b9fb67158edc9f202ff8a178c9465430ba) --- .../internal/DefaultMavenPluginManager.java | 2 +- .../ValidatingConfigurationListener.java | 115 +++++++++++++++++- 2 files changed, 115 insertions(+), 2 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java index 546f00435a36..9fdc1f624ec5 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java @@ -642,7 +642,7 @@ private void populatePluginFields( Object mojo, MojoDescriptor mojoDescriptor, C ConfigurationListener listener = new DebugConfigurationListener( logger ); ValidatingConfigurationListener validator = - new ValidatingConfigurationListener( mojo, mojoDescriptor, listener ); + new ValidatingConfigurationListener( mojo, mojoDescriptor, listener, expressionEvaluator ); logger.debug( "Configuring mojo '" + mojoDescriptor.getId() + "' with " + configuratorId + " configurator -->" ); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/ValidatingConfigurationListener.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/ValidatingConfigurationListener.java index 99b18af7c7a9..75b5cb4f73a4 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/ValidatingConfigurationListener.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/ValidatingConfigurationListener.java @@ -19,13 +19,22 @@ * under the License. */ +import java.lang.reflect.Array; import java.util.Collection; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; +import java.util.Objects; +import java.util.StringJoiner; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; +import org.apache.maven.shared.utils.logging.MessageUtils; import org.codehaus.plexus.component.configurator.ConfigurationListener; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A configuration listener to help validate the plugin configuration. For instance, check for required but missing @@ -36,17 +45,25 @@ class ValidatingConfigurationListener implements ConfigurationListener { + private static final Logger LOGGER = LoggerFactory.getLogger( ValidatingConfigurationListener.class ); private final Object mojo; private final ConfigurationListener delegate; + private final MojoDescriptor mojoDescriptor; + private final ExpressionEvaluator expressionEvaluator; + + private final Map missingParameters; - ValidatingConfigurationListener( Object mojo, MojoDescriptor mojoDescriptor, ConfigurationListener delegate ) + ValidatingConfigurationListener( Object mojo, MojoDescriptor mojoDescriptor, ConfigurationListener delegate, + ExpressionEvaluator expressionEvaluator ) { this.mojo = mojo; this.delegate = delegate; + this.mojoDescriptor = mojoDescriptor; + this.expressionEvaluator = expressionEvaluator; this.missingParameters = new HashMap<>(); if ( mojoDescriptor.getParameters() != null ) @@ -92,6 +109,102 @@ private void notify( String fieldName, Object value ) { missingParameters.remove( fieldName ); } + + if ( LOGGER.isWarnEnabled() ) + { + warnDeprecated( fieldName, value ); + } + } + + private void warnDeprecated( String fieldName, Object value ) + { + Parameter parameter = mojoDescriptor.getParameterMap().get( fieldName ); + String deprecated = parameter.getDeprecated(); + if ( deprecated != null ) + { + Object defaultValue = evaluateValue( parameter.getDefaultValue() ); + if ( !Objects.equals( toString( value ), defaultValue ) ) + { + StringBuilder sb = new StringBuilder(); + sb.append( " Parameter '" ); + sb.append( fieldName ); + sb.append( '\'' ); + if ( parameter.getExpression() != null ) + { + String userProperty = parameter.getExpression().replace( "${", "'" ).replace( '}', '\'' ); + sb.append( " (user property " ); + sb.append( userProperty ); + sb.append( ")" ); + } + sb.append( " is deprecated: " ); + sb.append( deprecated ); + + LOGGER.warn( MessageUtils.buffer().warning( sb.toString() ).toString() ); + } + } + } + + private Object evaluateValue( String value ) + { + try + { + return expressionEvaluator.evaluate( value ); + } + catch ( ExpressionEvaluationException e ) + { + // should not happen here + } + return value; } + /** + * Creates a string representation of the specified object for comparing with default values. + * + * @param obj The object to create a string representation for, may be null. + * @return The string representation, null for empty arrays / collections. + */ + private static String toString( Object obj ) + { + String str; + if ( obj != null && obj.getClass().isArray() ) + { + int n = Array.getLength( obj ); + if ( n == 0 ) + { + str = null; + } + else + { + StringJoiner sj = new StringJoiner( "," ); + for ( int i = 0; i < n; i++ ) + { + sj.add( String.valueOf( Array.get( obj, i ) ) ); + } + str = sj.toString(); + } + } + else if ( obj instanceof Collection ) + { + Collection collection = (Collection) obj; + if ( collection.isEmpty() ) + { + str = null; + } + else + { + Iterator it = collection.iterator(); + StringJoiner sj = new StringJoiner( "," ); + while ( it.hasNext() ) + { + sj.add( String.valueOf( it.next() ) ); + } + str = sj.toString(); + } + } + else + { + str = String.valueOf( obj ); + } + return str; + } } From 1ad5a1b1e9bb0a17fc12bbe0314564a616078602 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Wed, 13 Apr 2022 12:51:19 +0200 Subject: [PATCH 156/183] [MNG-7454] Include resolver-transport-http in Maven 3.9.x (#710) But keep Wagon as default transport. This PR merely includes resolver http and file transport and switches wagon-http to non-shaded one. Changes: * switch to non-shaded wagon-http (as httpClient is now shared) * include resolver http and file transport * override resolver default behaviour (native transport preferred over wagon, when both on classpath) * provide simplistic means to choose transport The chosen transport can be seen in debug (-X) output on line `[DEBUG] Using transporter XXX...` The `-Dmaven.transport` simplistic switch can be used to choose transport: * not set: default, that is Wagon * `wagon`: explicitly sets Wagon * `resolver`: explicitly sets resolver native transports (file and http) * `auto`: relies on resolver "auto discovery" (priorities, etc). This is MUST to keep transport pluggable with 3rd party transports. In fact, this was the default so far in Maven, along with the fact that native resolver transports were not included (as resolver prefers native ones over Wagon). --- apache-maven/pom.xml | 29 ++++++--------- ...DefaultRepositorySystemSessionFactory.java | 36 +++++++++++++++++++ maven-resolver-provider/pom.xml | 6 ++-- pom.xml | 19 +++++----- 4 files changed, 61 insertions(+), 29 deletions(-) diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index 07add7ef1d3e..bf5f377a0971 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -63,21 +63,10 @@ under the License. org.apache.maven.wagon wagon-http - shaded - - - org.apache.httpcomponents - httpclient - - - org.apache.httpcomponents - httpcore - - - org.apache.maven.wagon - wagon-http-shared - - + + + org.apache.maven.wagon + wagon-file org.slf4j @@ -86,12 +75,16 @@ under the License. runtime - org.apache.maven.wagon - wagon-file + org.apache.maven.resolver + maven-resolver-connector-basic org.apache.maven.resolver - maven-resolver-connector-basic + maven-resolver-transport-file + + + org.apache.maven.resolver + maven-resolver-transport-http org.apache.maven.resolver diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java index 60c6cf17a050..5616743d1327 100644 --- a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java +++ b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java @@ -63,6 +63,22 @@ @Named public class DefaultRepositorySystemSessionFactory { + private static final String MAVEN_TRANSPORT_KEY = "maven.transport"; + + private static final String MAVEN_TRANSPORT_WAGON = "wagon"; + + private static final String MAVEN_TRANSPORT_RESOLVER = "resolver"; + + private static final String MAVEN_TRANSPORT_AUTO = "auto"; + + private static final String WAGON_TRANSPORTER_KEY_PRIORITY_KEY = "aether.priority.WagonTransporterFactory"; + + private static final String RESOLVER_HTTP_TRANSPORTER_PRIORITY_KEY = "aether.priority.HttpTransporterFactory"; + + private static final String RESOLVER_FILE_TRANSPORTER_PRIORITY_KEY = "aether.priority.FileTransporterFactory"; + + private static final String RESOLVER_MAX_PRIORITY = String.valueOf( Float.MAX_VALUE ); + @Inject private Logger logger; @@ -94,6 +110,7 @@ public class DefaultRepositorySystemSessionFactory @Inject private RuntimeInformation runtimeInformation; + @SuppressWarnings( "checkstyle:methodlength" ) public DefaultRepositorySystemSession newRepositorySession( MavenExecutionRequest request ) { DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); @@ -224,6 +241,25 @@ else if ( request.isUpdateSnapshots() ) } session.setAuthenticationSelector( authSelector ); + String transport = request.getUserProperties().getProperty( MAVEN_TRANSPORT_KEY, MAVEN_TRANSPORT_WAGON ); + if ( MAVEN_TRANSPORT_RESOLVER.equals( transport ) ) + { + // Make sure (whatever extra priority is set) that resolver native is selected + configProps.put( RESOLVER_FILE_TRANSPORTER_PRIORITY_KEY, RESOLVER_MAX_PRIORITY ); + configProps.put( RESOLVER_HTTP_TRANSPORTER_PRIORITY_KEY, RESOLVER_MAX_PRIORITY ); + } + else if ( MAVEN_TRANSPORT_WAGON.equals( transport ) ) + { + // Make sure (whatever extra priority is set) that wagon is selected + configProps.put( WAGON_TRANSPORTER_KEY_PRIORITY_KEY, RESOLVER_MAX_PRIORITY ); + } + else if ( !MAVEN_TRANSPORT_AUTO.equals( transport ) ) + { + throw new IllegalArgumentException( "Unknown maven.transport=" + transport + + ". Supported ones are: " + MAVEN_TRANSPORT_WAGON + ", " + + MAVEN_TRANSPORT_RESOLVER + " and " + MAVEN_TRANSPORT_AUTO ); + } + session.setTransferListener( request.getTransferListener() ); session.setRepositoryListener( eventSpyDispatcher.chainListener( new LoggingRepositoryListener( logger ) ) ); diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml index 2b9422ca3e4e..d273a738ff8e 100644 --- a/maven-resolver-provider/pom.xml +++ b/maven-resolver-provider/pom.xml @@ -104,12 +104,12 @@ under the License. org.apache.maven.resolver - maven-resolver-transport-wagon + maven-resolver-transport-file test - org.apache.maven.wagon - wagon-file + org.apache.maven.resolver + maven-resolver-transport-http test diff --git a/pom.xml b/pom.xml index e1c0acfef8e3..85ee11ed69ab 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,7 @@ under the License. 2.0 2.0.0 1.3 - 1.7.2 + 1.7.3 1.7.32 2.2.1 1.7.4 @@ -379,13 +379,6 @@ under the License. org.apache.maven.wagon wagon-http ${wagonVersion} - shaded - - - commons-logging - commons-logging - - @@ -413,6 +406,16 @@ under the License. maven-resolver-connector-basic ${resolverVersion} + + org.apache.maven.resolver + maven-resolver-transport-file + ${resolverVersion} + + + org.apache.maven.resolver + maven-resolver-transport-http + ${resolverVersion} + org.apache.maven.resolver maven-resolver-transport-wagon From 3c6009cbf48f78bc8f657c1eb18fa8f522a994a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Tue, 22 Mar 2022 08:12:56 +0100 Subject: [PATCH 157/183] [MNG-7438] add execution id to "configuring mojo" debug message [DEBUG] Configuring mojo execution 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test:default-test' with basic configurator rephrase "Configuring" to "Loading" mojo "from plugin realm" to differentiate from "configuring mojo" = apply configuration rename populatePluginFields(..) private method to populateMojoExecutionFields(..) to better match the intent --- .../plugin/internal/DefaultMavenPluginManager.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java index 9fdc1f624ec5..6d85b887d330 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java @@ -515,7 +515,7 @@ public T getConfiguredMojo( Class mojoInterface, MavenSession session, Mo if ( logger.isDebugEnabled() ) { - logger.debug( "Configuring mojo " + mojoDescriptor.getId() + " from plugin realm " + pluginRealm ); + logger.debug( "Loading mojo " + mojoDescriptor.getId() + " from plugin realm " + pluginRealm ); } // We are forcing the use of the plugin realm for all lookups that might occur during @@ -609,7 +609,8 @@ else if ( cause instanceof LinkageError ) ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution ); - populatePluginFields( mojo, mojoDescriptor, pluginRealm, pomConfiguration, expressionEvaluator ); + populateMojoExecutionFields( mojo, mojoExecution.getExecutionId(), mojoDescriptor, pluginRealm, + pomConfiguration, expressionEvaluator ); return mojo; } @@ -620,8 +621,9 @@ else if ( cause instanceof LinkageError ) } } - private void populatePluginFields( Object mojo, MojoDescriptor mojoDescriptor, ClassRealm pluginRealm, - PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator ) + private void populateMojoExecutionFields( Object mojo, String executionId, MojoDescriptor mojoDescriptor, + ClassRealm pluginRealm, PlexusConfiguration configuration, + ExpressionEvaluator expressionEvaluator ) throws PluginConfigurationException { ComponentConfigurator configurator = null; @@ -644,8 +646,8 @@ private void populatePluginFields( Object mojo, MojoDescriptor mojoDescriptor, C ValidatingConfigurationListener validator = new ValidatingConfigurationListener( mojo, mojoDescriptor, listener, expressionEvaluator ); - logger.debug( - "Configuring mojo '" + mojoDescriptor.getId() + "' with " + configuratorId + " configurator -->" ); + logger.debug( "Configuring mojo execution '" + mojoDescriptor.getId() + ':' + executionId + "' with " + + configuratorId + " configurator -->" ); configurator.configureComponent( mojo, configuration, expressionEvaluator, pluginRealm, validator ); From 85caf98029e43066579fc671f3138ea17e473224 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Sat, 16 Apr 2022 18:21:48 +0200 Subject: [PATCH 158/183] [MNG-7454] Include resolver-transport-http in Maven (#720) Addendum to 1ad5a1b1e9bb0a17fc12bbe0314564a616078602: * fix property name to align with existing ones * fix logging configuration as no more shaded httpClient * fix constant names --- .../src/conf/logging/simplelogger.properties | 6 ++-- ...DefaultRepositorySystemSessionFactory.java | 35 ++++++++++--------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/apache-maven/src/conf/logging/simplelogger.properties b/apache-maven/src/conf/logging/simplelogger.properties index 64b331b4592c..8c4a5d1e4b0d 100644 --- a/apache-maven/src/conf/logging/simplelogger.properties +++ b/apache-maven/src/conf/logging/simplelogger.properties @@ -26,7 +26,5 @@ org.slf4j.simpleLogger.log.Sisu=info org.slf4j.simpleLogger.warnLevelString=WARNING # MNG-6181: mvn -X also prints all debug logging from HttpClient -# Be aware that the shaded packages are used -# org.apache.http -> org.apache.maven.wagon.providers.http.httpclient -org.slf4j.simpleLogger.log.org.apache.maven.wagon.providers.http.httpclient=off -org.slf4j.simpleLogger.log.org.apache.maven.wagon.providers.http.httpclient.wire=off +org.slf4j.simpleLogger.log.org.apache.http=off +org.slf4j.simpleLogger.log.org.apache.http.wire=off diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java index 5616743d1327..e0db581db7e0 100644 --- a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java +++ b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java @@ -63,19 +63,19 @@ @Named public class DefaultRepositorySystemSessionFactory { - private static final String MAVEN_TRANSPORT_KEY = "maven.transport"; + private static final String MAVEN_RESOLVER_TRANSPORT_KEY = "maven.resolver.transport"; - private static final String MAVEN_TRANSPORT_WAGON = "wagon"; + private static final String MAVEN_RESOLVER_TRANSPORT_WAGON = "wagon"; - private static final String MAVEN_TRANSPORT_RESOLVER = "resolver"; + private static final String MAVEN_RESOLVER_TRANSPORT_NATIVE = "native"; - private static final String MAVEN_TRANSPORT_AUTO = "auto"; + private static final String MAVEN_RESOLVER_TRANSPORT_AUTO = "auto"; - private static final String WAGON_TRANSPORTER_KEY_PRIORITY_KEY = "aether.priority.WagonTransporterFactory"; + private static final String WAGON_TRANSPORTER_PRIORITY_KEY = "aether.priority.WagonTransporterFactory"; - private static final String RESOLVER_HTTP_TRANSPORTER_PRIORITY_KEY = "aether.priority.HttpTransporterFactory"; + private static final String NATIVE_HTTP_TRANSPORTER_PRIORITY_KEY = "aether.priority.HttpTransporterFactory"; - private static final String RESOLVER_FILE_TRANSPORTER_PRIORITY_KEY = "aether.priority.FileTransporterFactory"; + private static final String NATIVE_FILE_TRANSPORTER_PRIORITY_KEY = "aether.priority.FileTransporterFactory"; private static final String RESOLVER_MAX_PRIORITY = String.valueOf( Float.MAX_VALUE ); @@ -241,23 +241,24 @@ else if ( request.isUpdateSnapshots() ) } session.setAuthenticationSelector( authSelector ); - String transport = request.getUserProperties().getProperty( MAVEN_TRANSPORT_KEY, MAVEN_TRANSPORT_WAGON ); - if ( MAVEN_TRANSPORT_RESOLVER.equals( transport ) ) + String transport = request.getUserProperties() + .getProperty( MAVEN_RESOLVER_TRANSPORT_KEY, MAVEN_RESOLVER_TRANSPORT_WAGON ); + if ( MAVEN_RESOLVER_TRANSPORT_NATIVE.equals( transport ) ) { // Make sure (whatever extra priority is set) that resolver native is selected - configProps.put( RESOLVER_FILE_TRANSPORTER_PRIORITY_KEY, RESOLVER_MAX_PRIORITY ); - configProps.put( RESOLVER_HTTP_TRANSPORTER_PRIORITY_KEY, RESOLVER_MAX_PRIORITY ); + configProps.put( NATIVE_FILE_TRANSPORTER_PRIORITY_KEY, RESOLVER_MAX_PRIORITY ); + configProps.put( NATIVE_HTTP_TRANSPORTER_PRIORITY_KEY, RESOLVER_MAX_PRIORITY ); } - else if ( MAVEN_TRANSPORT_WAGON.equals( transport ) ) + else if ( MAVEN_RESOLVER_TRANSPORT_WAGON.equals( transport ) ) { // Make sure (whatever extra priority is set) that wagon is selected - configProps.put( WAGON_TRANSPORTER_KEY_PRIORITY_KEY, RESOLVER_MAX_PRIORITY ); + configProps.put( WAGON_TRANSPORTER_PRIORITY_KEY, RESOLVER_MAX_PRIORITY ); } - else if ( !MAVEN_TRANSPORT_AUTO.equals( transport ) ) + else if ( !MAVEN_RESOLVER_TRANSPORT_AUTO.equals( transport ) ) { - throw new IllegalArgumentException( "Unknown maven.transport=" + transport - + ". Supported ones are: " + MAVEN_TRANSPORT_WAGON + ", " - + MAVEN_TRANSPORT_RESOLVER + " and " + MAVEN_TRANSPORT_AUTO ); + throw new IllegalArgumentException( "Unknown resolver transport '" + transport + + "'. Supported transports are: " + MAVEN_RESOLVER_TRANSPORT_WAGON + ", " + + MAVEN_RESOLVER_TRANSPORT_NATIVE + ", " + MAVEN_RESOLVER_TRANSPORT_AUTO ); } session.setTransferListener( request.getTransferListener() ); From aa0607301f2f61e7d26b23656913fa00d963a691 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 22 Apr 2022 16:50:57 +0200 Subject: [PATCH 159/183] [MNG-7453] Update Resolver to 1.8.0 (#724) Updates Maven Resolver to 1.8.0. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 85ee11ed69ab..7058f1daa05b 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,7 @@ under the License. 2.0 2.0.0 1.3 - 1.7.3 + 1.8.0 1.7.32 2.2.1 1.7.4 From 4c9dc5abb20a5af134f507bcce05929dd3fca2a8 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 22 Apr 2022 17:51:07 +0200 Subject: [PATCH 160/183] [MNG-7055] Fix G level metadata handling in 3.9.x (#691) Maven Artifact Transfer silently prevents group level metadata to reach Resolver and causes metadata loss on install/deploy. Fix is to "bridge" this from maven-resolver-provider (and core) by reusing the actual metadata that m-plugin-p:addPluginArtifactMetadata mojo adds, but m-a-t filters out. This is backport of commit d141957ff5a3c08ae53c68e4ba19b49055f717c4 from master to maven-3.9.x branch. --- maven-compat/pom.xml | 5 + .../deployer/ArtifactDeployerTest.java | 36 +++-- .../installer/ArtifactInstallerTest.java | 28 +++- .../DefaultPluginsMetadataInfoProvider.java | 137 ++++++++++++++++++ .../META-INF/plexus/default-bindings.xml | 28 ++-- .../repository/internal/PluginsMetadata.java | 117 +++++++++++++++ .../internal/PluginsMetadataGenerator.java | 130 +++++++++++++++++ .../PluginsMetadataGeneratorFactory.java | 67 +++++++++ .../internal/PluginsMetadataInfoProvider.java | 47 ++++++ 9 files changed, 567 insertions(+), 28 deletions(-) create mode 100644 maven-core/src/main/java/org/apache/maven/execution/infoproviders/DefaultPluginsMetadataInfoProvider.java create mode 100644 maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadata.java create mode 100644 maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataGenerator.java create mode 100644 maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataGeneratorFactory.java create mode 100644 maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataInfoProvider.java diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml index 4f79ac828cda..ed7bce84d794 100644 --- a/maven-compat/pom.xml +++ b/maven-compat/pom.xml @@ -99,6 +99,11 @@ under the License. wagon-provider-api + + org.mockito + mockito-core + test + org.apache.maven.wagon wagon-file diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java index f929f4801b8a..ed0a43cf78f6 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java @@ -24,8 +24,12 @@ import org.apache.maven.artifact.AbstractArtifactComponentTestCase; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.session.scope.internal.SessionScope; import org.codehaus.plexus.util.FileUtils; +import static org.mockito.Mockito.mock; + /** * @author Jason van Zyl */ @@ -34,12 +38,16 @@ public class ArtifactDeployerTest { private ArtifactDeployer artifactDeployer; + private SessionScope sessionScope; + protected void setUp() throws Exception { super.setUp(); artifactDeployer = (ArtifactDeployer) lookup( ArtifactDeployer.ROLE ); + + sessionScope = lookup( SessionScope.class ); } protected String component() @@ -50,18 +58,28 @@ protected String component() public void testArtifactInstallation() throws Exception { - String artifactBasedir = new File( getBasedir(), "src/test/resources/artifact-install" ).getAbsolutePath(); + sessionScope.enter(); + try + { + sessionScope.seed(MavenSession.class, mock(MavenSession.class)); + + String artifactBasedir = new File( getBasedir(), "src/test/resources/artifact-install" ).getAbsolutePath(); - Artifact artifact = createArtifact( "artifact", "1.0" ); + Artifact artifact = createArtifact( "artifact", "1.0" ); - File file = new File( artifactBasedir, "artifact-1.0.jar" ); - assertEquals( "dummy", FileUtils.fileRead( file, "UTF-8" ).trim() ); + File file = new File( artifactBasedir, "artifact-1.0.jar" ); + assertEquals( "dummy", FileUtils.fileRead( file, "UTF-8" ).trim() ); - artifactDeployer.deploy( file, artifact, remoteRepository(), localRepository() ); + artifactDeployer.deploy( file, artifact, remoteRepository(), localRepository() ); - ArtifactRepository remoteRepository = remoteRepository(); - File deployedFile = new File( remoteRepository.getBasedir(), remoteRepository.pathOf( artifact ) ); - assertTrue( deployedFile.exists() ); - assertEquals( "dummy", FileUtils.fileRead( deployedFile, "UTF-8" ).trim() ); + ArtifactRepository remoteRepository = remoteRepository(); + File deployedFile = new File( remoteRepository.getBasedir(), remoteRepository.pathOf( artifact ) ); + assertTrue( deployedFile.exists() ); + assertEquals( "dummy", FileUtils.fileRead( deployedFile, "UTF-8" ).trim() ); + } + finally + { + sessionScope.exit(); + } } } \ No newline at end of file diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java index 21bfb2b70b81..66ba9e968f97 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java @@ -23,6 +23,10 @@ import org.apache.maven.artifact.AbstractArtifactComponentTestCase; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.session.scope.internal.SessionScope; + +import static org.mockito.Mockito.mock; /** * @author Jason van Zyl @@ -32,12 +36,16 @@ public class ArtifactInstallerTest { private ArtifactInstaller artifactInstaller; + private SessionScope sessionScope; + protected void setUp() throws Exception { super.setUp(); artifactInstaller = (ArtifactInstaller) lookup( ArtifactInstaller.ROLE ); + + sessionScope = lookup( SessionScope.class ); } protected String component() @@ -48,14 +56,24 @@ protected String component() public void testArtifactInstallation() throws Exception { - String artifactBasedir = new File( getBasedir(), "src/test/resources/artifact-install" ).getAbsolutePath(); + sessionScope.enter(); + try + { + sessionScope.seed(MavenSession.class, mock(MavenSession.class)); + + String artifactBasedir = new File( getBasedir(), "src/test/resources/artifact-install" ).getAbsolutePath(); - Artifact artifact = createArtifact( "artifact", "1.0" ); + Artifact artifact = createArtifact( "artifact", "1.0" ); - File source = new File( artifactBasedir, "artifact-1.0.jar" ); + File source = new File( artifactBasedir, "artifact-1.0.jar" ); - artifactInstaller.install( source, artifact, localRepository() ); + artifactInstaller.install( source, artifact, localRepository() ); - assertLocalArtifactPresent( artifact ); + assertLocalArtifactPresent( artifact ); + } + finally + { + sessionScope.exit(); + } } } \ No newline at end of file diff --git a/maven-core/src/main/java/org/apache/maven/execution/infoproviders/DefaultPluginsMetadataInfoProvider.java b/maven-core/src/main/java/org/apache/maven/execution/infoproviders/DefaultPluginsMetadataInfoProvider.java new file mode 100644 index 000000000000..616a3a88a4bf --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/execution/infoproviders/DefaultPluginsMetadataInfoProvider.java @@ -0,0 +1,137 @@ +package org.apache.maven.execution.infoproviders; + +/* + * 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 java.util.Objects; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Provider; +import javax.inject.Singleton; + +import org.apache.maven.artifact.repository.metadata.Metadata; +import org.apache.maven.artifact.repository.metadata.Plugin; +import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.project.MavenProject; +import org.apache.maven.repository.internal.PluginsMetadataInfoProvider; +import org.apache.maven.repository.legacy.metadata.ArtifactMetadata; +import org.eclipse.aether.artifact.Artifact; + +import static java.util.Objects.requireNonNull; + +/** + * Default implementation of {@link PluginsMetadataInfoProvider}. + */ +@Named +@Singleton +public class DefaultPluginsMetadataInfoProvider + implements PluginsMetadataInfoProvider +{ + private final Provider mavenSessionProvider; + + @Inject + public DefaultPluginsMetadataInfoProvider( final Provider mavenSessionProvider ) + { + this.mavenSessionProvider = requireNonNull( mavenSessionProvider ); + } + + @Override + public PluginInfo getPluginInfo( final Artifact artifact ) + { + MavenSession mavenSession = mavenSessionProvider.get(); + if ( mavenSession != null ) + { + MavenProject mavenProject = searchForProject( mavenSession, artifact ); + if ( mavenProject != null && "maven-plugin".equals( mavenProject.getPackaging() ) ) + { + Plugin plugin = searchForPluginGroupLevelRepositoryMetadata( mavenProject ); + + if ( plugin != null ) + { + return new PluginInfo() + { + @Override + public String getPluginGroupId() + { + return artifact.getGroupId(); + } + + @Override + public String getPluginArtifactId() + { + return artifact.getArtifactId(); + } + + @Override + public String getPluginPrefix() + { + return plugin.getPrefix(); + } + + @Override + public String getPluginName() + { + return plugin.getName(); + } + }; + } + } + } + + return null; + } + + private MavenProject searchForProject( MavenSession mavenSession, Artifact artifact ) + { + for ( MavenProject mavenProject : mavenSession.getProjects() ) + { + if ( mavenProject.getArtifact() != null + && Objects.equals( mavenProject.getGroupId(), artifact.getGroupId() ) + && Objects.equals( mavenProject.getArtifactId(), artifact.getArtifactId() ) ) + { + return mavenProject; + } + } + return null; + } + + private Plugin searchForPluginGroupLevelRepositoryMetadata( MavenProject mavenProject ) + { + org.apache.maven.artifact.Artifact projectArtifact = mavenProject.getArtifact(); + for ( ArtifactMetadata artifactMetadata : projectArtifact.getMetadataList() ) + { + if ( artifactMetadata instanceof RepositoryMetadata ) + { + RepositoryMetadata repositoryMetadata = (RepositoryMetadata) artifactMetadata; + Metadata metadata = repositoryMetadata.getMetadata(); + + for ( Plugin plugin : metadata.getPlugins() ) + { + if ( Objects.equals( plugin.getArtifactId(), mavenProject.getArtifactId() ) ) + { + return plugin; + } + } + } + } + return null; + } +} diff --git a/maven-core/src/main/resources/META-INF/plexus/default-bindings.xml b/maven-core/src/main/resources/META-INF/plexus/default-bindings.xml index 4a303db572bc..e35f931596dd 100644 --- a/maven-core/src/main/resources/META-INF/plexus/default-bindings.xml +++ b/maven-core/src/main/resources/META-INF/plexus/default-bindings.xml @@ -41,10 +41,10 @@ Mappings to default lifecycle, specific for each packaging. - org.apache.maven.plugins:maven-install-plugin:2.4:install + org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install - org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy + org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M2:deploy @@ -85,10 +85,10 @@ Mappings to default lifecycle, specific for each packaging. org.apache.maven.plugins:maven-jar-plugin:2.4:jar - org.apache.maven.plugins:maven-install-plugin:2.4:install + org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install - org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy + org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M2:deploy @@ -129,10 +129,10 @@ Mappings to default lifecycle, specific for each packaging. org.apache.maven.plugins:maven-ejb-plugin:2.3:ejb - org.apache.maven.plugins:maven-install-plugin:2.4:install + org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install - org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy + org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M2:deploy @@ -177,10 +177,10 @@ Mappings to default lifecycle, specific for each packaging. org.apache.maven.plugins:maven-plugin-plugin:3.2:addPluginArtifactMetadata - org.apache.maven.plugins:maven-install-plugin:2.4:install + org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install - org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy + org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M2:deploy @@ -221,10 +221,10 @@ Mappings to default lifecycle, specific for each packaging. org.apache.maven.plugins:maven-war-plugin:2.2:war - org.apache.maven.plugins:maven-install-plugin:2.4:install + org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install - org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy + org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M2:deploy @@ -256,10 +256,10 @@ Mappings to default lifecycle, specific for each packaging. org.apache.maven.plugins:maven-ear-plugin:2.8:ear - org.apache.maven.plugins:maven-install-plugin:2.4:install + org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install - org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy + org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M2:deploy @@ -300,10 +300,10 @@ Mappings to default lifecycle, specific for each packaging. org.apache.maven.plugins:maven-rar-plugin:2.2:rar - org.apache.maven.plugins:maven-install-plugin:2.4:install + org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install - org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy + org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M2:deploy diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadata.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadata.java new file mode 100644 index 000000000000..7a6c45abfe79 --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadata.java @@ -0,0 +1,117 @@ +package org.apache.maven.repository.internal; + +/* + * 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 java.io.File; +import java.util.ArrayList; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; + +import org.apache.maven.artifact.repository.metadata.Metadata; +import org.apache.maven.artifact.repository.metadata.Plugin; +import org.apache.maven.repository.internal.PluginsMetadataInfoProvider.PluginInfo; +import org.eclipse.aether.artifact.Artifact; + +/** + * Plugin G level metadata. + */ +final class PluginsMetadata + extends MavenMetadata +{ + private final PluginInfo pluginInfo; + + PluginsMetadata( PluginInfo pluginInfo, Date timestamp ) + { + super( createRepositoryMetadata( pluginInfo ), null, timestamp ); + this.pluginInfo = pluginInfo; + } + + PluginsMetadata( PluginInfo pluginInfo, File file, Date timestamp ) + { + super( createRepositoryMetadata( pluginInfo ), file, timestamp ); + this.pluginInfo = pluginInfo; + } + + private static Metadata createRepositoryMetadata( PluginInfo pluginInfo ) + { + Metadata result = new Metadata(); + Plugin plugin = new Plugin(); + plugin.setPrefix( pluginInfo.getPluginPrefix() ); + plugin.setArtifactId( pluginInfo.getPluginArtifactId() ); + plugin.setName( pluginInfo.getPluginName() ); + result.getPlugins().add( plugin ); + return result; + } + + @Override + protected void merge( Metadata recessive ) + { + List recessivePlugins = recessive.getPlugins(); + List plugins = metadata.getPlugins(); + if ( !plugins.isEmpty() ) + { + LinkedHashMap mergedPlugins = new LinkedHashMap<>(); + recessivePlugins.forEach( p -> mergedPlugins.put( p.getPrefix(), p ) ); + plugins.forEach( p -> mergedPlugins.put( p.getPrefix(), p ) ); + metadata.setPlugins( new ArrayList<>( mergedPlugins.values() ) ); + } + } + + public Object getKey() + { + return getGroupId(); + } + + public static Object getKey( Artifact artifact ) + { + return artifact.getGroupId(); + } + + @Override + public MavenMetadata setFile( File file ) + { + return new PluginsMetadata( pluginInfo, file, timestamp ); + } + + @Override + public String getGroupId() + { + return pluginInfo.getPluginGroupId(); + } + + @Override + public String getArtifactId() + { + return ""; + } + + @Override + public String getVersion() + { + return ""; + } + + @Override + public Nature getNature() + { + return Nature.RELEASE_OR_SNAPSHOT; + } +} diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataGenerator.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataGenerator.java new file mode 100644 index 000000000000..4f355686517c --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataGenerator.java @@ -0,0 +1,130 @@ +package org.apache.maven.repository.internal; + +/* + * 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 java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.apache.maven.repository.internal.PluginsMetadataInfoProvider.PluginInfo; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.deployment.DeployRequest; +import org.eclipse.aether.impl.MetadataGenerator; +import org.eclipse.aether.installation.InstallRequest; +import org.eclipse.aether.metadata.Metadata; +import org.eclipse.aether.util.ConfigUtils; + +import static java.util.Objects.requireNonNull; + +/** + * Plugin G level metadata. + */ +class PluginsMetadataGenerator + implements MetadataGenerator +{ + private final PluginsMetadataInfoProvider pluginsMetadataInfoProvider; + + private final Map plugins; + + private final Map processedPlugins; + + private final Date timestamp; + + PluginsMetadataGenerator( PluginsMetadataInfoProvider pluginsMetadataInfoProvider, + RepositorySystemSession session, + InstallRequest request ) + { + this( pluginsMetadataInfoProvider, session, request.getMetadata() ); + } + + PluginsMetadataGenerator( PluginsMetadataInfoProvider pluginsMetadataInfoProvider, + RepositorySystemSession session, + DeployRequest request ) + { + this( pluginsMetadataInfoProvider, session, request.getMetadata() ); + } + + private PluginsMetadataGenerator( PluginsMetadataInfoProvider pluginsMetadataInfoProvider, + RepositorySystemSession session, + Collection metadatas ) + { + this.pluginsMetadataInfoProvider = requireNonNull( pluginsMetadataInfoProvider ); + this.plugins = new LinkedHashMap<>(); + this.processedPlugins = new LinkedHashMap<>(); + this.timestamp = (Date) ConfigUtils.getObject( session, new Date(), "maven.startTime" ); + + /* + * NOTE: This should be considered a quirk to support interop with Maven's legacy ArtifactDeployer which + * processes one artifact at a time and hence cannot associate the artifacts from the same project to use the + * same version index. Allowing the caller to pass in metadata from a previous deployment allows to re-establish + * the association between the artifacts of the same project. + */ + for ( Iterator it = metadatas.iterator(); it.hasNext(); ) + { + Metadata metadata = it.next(); + if ( metadata instanceof PluginsMetadata ) + { + it.remove(); + PluginsMetadata pluginMetadata = ( PluginsMetadata ) metadata; + processedPlugins.put( pluginMetadata.getKey(), pluginMetadata ); + } + } + } + + @Override + public Collection prepare( Collection artifacts ) + { + return Collections.emptyList(); + } + + @Override + public Artifact transformArtifact( Artifact artifact ) + { + return artifact; + } + + @Override + public Collection finish( Collection artifacts ) + { + for ( Artifact artifact : artifacts ) + { + PluginInfo pluginInfo = pluginsMetadataInfoProvider.getPluginInfo( artifact ); + if ( pluginInfo != null ) + { + Object key = PluginsMetadata.getKey( artifact ); + if ( processedPlugins.get( key ) == null ) + { + PluginsMetadata pluginMetadata = plugins.get( key ); + if ( pluginMetadata == null ) + { + pluginMetadata = new PluginsMetadata( pluginInfo, timestamp ); + plugins.put( key, pluginMetadata ); + } + } + } + } + + return plugins.values(); + } +} diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataGeneratorFactory.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataGeneratorFactory.java new file mode 100644 index 000000000000..19d499b25772 --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataGeneratorFactory.java @@ -0,0 +1,67 @@ +package org.apache.maven.repository.internal; + +/* + * 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 javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.deployment.DeployRequest; +import org.eclipse.aether.impl.MetadataGenerator; +import org.eclipse.aether.impl.MetadataGeneratorFactory; +import org.eclipse.aether.installation.InstallRequest; + +import static java.util.Objects.requireNonNull; + +/** + * Plugin G level metadata. + */ +@Named( "plugins" ) +@Singleton +public class PluginsMetadataGeneratorFactory + implements MetadataGeneratorFactory +{ + private final PluginsMetadataInfoProvider pluginsMetadataInfoProvider; + + @Inject + public PluginsMetadataGeneratorFactory( PluginsMetadataInfoProvider pluginsMetadataInfoProvider ) + { + this.pluginsMetadataInfoProvider = requireNonNull( pluginsMetadataInfoProvider ); + } + + @Override + public MetadataGenerator newInstance( RepositorySystemSession session, InstallRequest request ) + { + return new PluginsMetadataGenerator( pluginsMetadataInfoProvider, session, request ); + } + + @Override + public MetadataGenerator newInstance( RepositorySystemSession session, DeployRequest request ) + { + return new PluginsMetadataGenerator( pluginsMetadataInfoProvider, session, request ); + } + + @Override + public float getPriority() + { + return 5; + } +} diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataInfoProvider.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataInfoProvider.java new file mode 100644 index 000000000000..806fa46348be --- /dev/null +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataInfoProvider.java @@ -0,0 +1,47 @@ +package org.apache.maven.repository.internal; + +/* + * 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.eclipse.aether.artifact.Artifact; + +/** + * Plugin G level metadata provider. + */ +public interface PluginsMetadataInfoProvider +{ + /** + * The required data for G level metadata. + */ + interface PluginInfo + { + String getPluginGroupId(); + + String getPluginArtifactId(); + + String getPluginPrefix(); + + String getPluginName(); + } + + /** + * Returns {@link PluginInfo} corresponding for passed in {@link Artifact}, or {@code null}. + */ + PluginInfo getPluginInfo( Artifact artifact ); +} From 28c763c72cf94ad13e235f985244764f7fd0c988 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 23 Apr 2022 11:09:43 +0200 Subject: [PATCH 161/183] [MNG-5222] Improvement in deprecated params detection This is backport of commit 9ac2d08dc7dec66acc2c835710065b677190e700 from master to maven-3.9.x branch. --- .../internal/DefaultMavenPluginManager.java | 7 +- .../internal/DeprecatedPluginValidator.java | 131 ++++++++++++++++++ .../MavenPluginConfigurationValidator.java | 39 ++++++ .../ValidatingConfigurationListener.java | 117 +--------------- 4 files changed, 177 insertions(+), 117 deletions(-) create mode 100644 maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java create mode 100644 maven-core/src/main/java/org/apache/maven/plugin/internal/MavenPluginConfigurationValidator.java diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java index 6d85b887d330..8f00f165948d 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java @@ -164,6 +164,9 @@ public class DefaultMavenPluginManager @Requirement private PluginArtifactsCache pluginArtifactsCache; + @Requirement + private MavenPluginConfigurationValidator configurationValidator; + private ExtensionDescriptorBuilder extensionDescriptorBuilder = new ExtensionDescriptorBuilder(); private PluginDescriptorBuilder builder = new PluginDescriptorBuilder(); @@ -609,6 +612,8 @@ else if ( cause instanceof LinkageError ) ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution ); + configurationValidator.validate( mojoDescriptor, pomConfiguration, expressionEvaluator ); + populateMojoExecutionFields( mojo, mojoExecution.getExecutionId(), mojoDescriptor, pluginRealm, pomConfiguration, expressionEvaluator ); @@ -644,7 +649,7 @@ private void populateMojoExecutionFields( Object mojo, String executionId, MojoD ConfigurationListener listener = new DebugConfigurationListener( logger ); ValidatingConfigurationListener validator = - new ValidatingConfigurationListener( mojo, mojoDescriptor, listener, expressionEvaluator ); + new ValidatingConfigurationListener( mojo, mojoDescriptor, listener ); logger.debug( "Configuring mojo execution '" + mojoDescriptor.getId() + ':' + executionId + "' with " + configuratorId + " configurator -->" ); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java new file mode 100644 index 000000000000..48e16c60cdd4 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java @@ -0,0 +1,131 @@ +package org.apache.maven.plugin.internal; + +/* + * 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.plugin.descriptor.MojoDescriptor; +import org.apache.maven.plugin.descriptor.Parameter; +import org.apache.maven.shared.utils.logging.MessageUtils; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; +import org.codehaus.plexus.configuration.PlexusConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Print warnings if deprecated params of plugin are used in configuration. + * + * @author Slawomir Jaranowski + */ + +@Component( role = MavenPluginConfigurationValidator.class ) +class DeprecatedPluginValidator implements MavenPluginConfigurationValidator +{ + private static final Logger LOGGER = LoggerFactory.getLogger( DeprecatedPluginValidator.class ); + + @Override + public void validate( MojoDescriptor mojoDescriptor, + PlexusConfiguration pomConfiguration, + ExpressionEvaluator expressionEvaluator ) + { + if ( !LOGGER.isWarnEnabled() ) + { + return; + } + + if ( mojoDescriptor.getParameters() == null ) + { + return; + } + + mojoDescriptor.getParameters().stream() + .filter( parameter -> parameter.getDeprecated() != null ) + .filter( Parameter::isEditable ) + .forEach( parameter -> checkParameter( parameter, pomConfiguration, expressionEvaluator ) ); + } + + private static void checkParameter( Parameter parameter, + PlexusConfiguration pomConfiguration, + ExpressionEvaluator expressionEvaluator ) + { + PlexusConfiguration config = pomConfiguration.getChild( parameter.getName(), false ); + + if ( isValueSet( config, expressionEvaluator ) ) + { + logDeprecateWarn( parameter ); + } + } + + private static boolean isValueSet( PlexusConfiguration config, + ExpressionEvaluator expressionEvaluator ) + { + if ( config == null ) + { + return false; + } + + // there are sub items ... so configuration is declared + if ( config.getChildCount() > 0 ) + { + return true; + } + + String strValue = config.getValue(); + + if ( strValue == null || strValue.isEmpty() ) + { + return false; + } + + // for declaration like @Parameter( property = "config.property" ) + // the value will contains ${config.property} + try + { + return expressionEvaluator.evaluate( strValue ) != null; + } + catch ( ExpressionEvaluationException e ) + { + // not important + // will be reported during Mojo fields populate + } + + // fallback - in case of error in expressionEvaluator + return false; + } + + private static void logDeprecateWarn( Parameter parameter ) + { + StringBuilder sb = new StringBuilder(); + sb.append( "Parameter '" ); + sb.append( parameter.getName() ); + sb.append( '\'' ); + if ( parameter.getExpression() != null ) + { + String userProperty = parameter.getExpression().replace( "${", "'" ).replace( '}', '\'' ); + sb.append( " (user property " ); + sb.append( userProperty ); + sb.append( ")" ); + } + sb.append( " is deprecated: " ); + sb.append( parameter.getDeprecated() ); + + LOGGER.warn( MessageUtils.buffer().warning( sb.toString() ).toString() ); + } +} diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/MavenPluginConfigurationValidator.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/MavenPluginConfigurationValidator.java new file mode 100644 index 000000000000..8252782d38a0 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/MavenPluginConfigurationValidator.java @@ -0,0 +1,39 @@ +package org.apache.maven.plugin.internal; + +/* + * 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.plugin.descriptor.MojoDescriptor; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; +import org.codehaus.plexus.configuration.PlexusConfiguration; + +/** + * Service responsible for validating plugin configuration. + * + * @author Slawomir Jaranowski + */ +interface MavenPluginConfigurationValidator +{ + /** + * Check mojo configuration. + */ + void validate( MojoDescriptor mojoDescriptor, + PlexusConfiguration pomConfiguration, + ExpressionEvaluator expressionEvaluator ); +} diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/ValidatingConfigurationListener.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/ValidatingConfigurationListener.java index 75b5cb4f73a4..c04f44821e96 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/ValidatingConfigurationListener.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/ValidatingConfigurationListener.java @@ -19,22 +19,13 @@ * under the License. */ -import java.lang.reflect.Array; import java.util.Collection; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; -import java.util.Objects; -import java.util.StringJoiner; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; -import org.apache.maven.shared.utils.logging.MessageUtils; import org.codehaus.plexus.component.configurator.ConfigurationListener; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * A configuration listener to help validate the plugin configuration. For instance, check for required but missing @@ -45,25 +36,16 @@ class ValidatingConfigurationListener implements ConfigurationListener { - private static final Logger LOGGER = LoggerFactory.getLogger( ValidatingConfigurationListener.class ); - private final Object mojo; private final ConfigurationListener delegate; - private final MojoDescriptor mojoDescriptor; - private final ExpressionEvaluator expressionEvaluator; - - private final Map missingParameters; - ValidatingConfigurationListener( Object mojo, MojoDescriptor mojoDescriptor, ConfigurationListener delegate, - ExpressionEvaluator expressionEvaluator ) + ValidatingConfigurationListener( Object mojo, MojoDescriptor mojoDescriptor, ConfigurationListener delegate ) { this.mojo = mojo; this.delegate = delegate; - this.mojoDescriptor = mojoDescriptor; - this.expressionEvaluator = expressionEvaluator; this.missingParameters = new HashMap<>(); if ( mojoDescriptor.getParameters() != null ) @@ -109,102 +91,5 @@ private void notify( String fieldName, Object value ) { missingParameters.remove( fieldName ); } - - if ( LOGGER.isWarnEnabled() ) - { - warnDeprecated( fieldName, value ); - } - } - - private void warnDeprecated( String fieldName, Object value ) - { - Parameter parameter = mojoDescriptor.getParameterMap().get( fieldName ); - String deprecated = parameter.getDeprecated(); - if ( deprecated != null ) - { - Object defaultValue = evaluateValue( parameter.getDefaultValue() ); - if ( !Objects.equals( toString( value ), defaultValue ) ) - { - StringBuilder sb = new StringBuilder(); - sb.append( " Parameter '" ); - sb.append( fieldName ); - sb.append( '\'' ); - if ( parameter.getExpression() != null ) - { - String userProperty = parameter.getExpression().replace( "${", "'" ).replace( '}', '\'' ); - sb.append( " (user property " ); - sb.append( userProperty ); - sb.append( ")" ); - } - sb.append( " is deprecated: " ); - sb.append( deprecated ); - - LOGGER.warn( MessageUtils.buffer().warning( sb.toString() ).toString() ); - } - } - } - - private Object evaluateValue( String value ) - { - try - { - return expressionEvaluator.evaluate( value ); - } - catch ( ExpressionEvaluationException e ) - { - // should not happen here - } - return value; - } - - /** - * Creates a string representation of the specified object for comparing with default values. - * - * @param obj The object to create a string representation for, may be null. - * @return The string representation, null for empty arrays / collections. - */ - private static String toString( Object obj ) - { - String str; - if ( obj != null && obj.getClass().isArray() ) - { - int n = Array.getLength( obj ); - if ( n == 0 ) - { - str = null; - } - else - { - StringJoiner sj = new StringJoiner( "," ); - for ( int i = 0; i < n; i++ ) - { - sj.add( String.valueOf( Array.get( obj, i ) ) ); - } - str = sj.toString(); - } - } - else if ( obj instanceof Collection ) - { - Collection collection = (Collection) obj; - if ( collection.isEmpty() ) - { - str = null; - } - else - { - Iterator it = collection.iterator(); - StringJoiner sj = new StringJoiner( "," ); - while ( it.hasNext() ) - { - sj.add( String.valueOf( it.next() ) ); - } - str = sj.toString(); - } - } - else - { - str = String.valueOf( obj ); - } - return str; } } From dd0ddef8f6d4c998472dff91d2a2153959a6049f Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 23 Apr 2022 21:55:29 +0200 Subject: [PATCH 162/183] [MNG-7457] Warn about deprecated plugin Mojo (cherry picked from commit 702f52d0ea7c5e90b495bc05f079ca3e952766a8) --- .../internal/DeprecatedPluginValidator.java | 48 ++++++++++++++----- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java index 48e16c60cdd4..4c21f80e3ea0 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java @@ -21,6 +21,7 @@ import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; +import org.apache.maven.shared.utils.logging.MessageBuilder; import org.apache.maven.shared.utils.logging.MessageUtils; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; @@ -30,7 +31,7 @@ import org.slf4j.LoggerFactory; /** - * Print warnings if deprecated params of plugin are used in configuration. + * Print warnings if deprecated mojo or parameters of plugin are used in configuration. * * @author Slawomir Jaranowski */ @@ -50,6 +51,11 @@ public void validate( MojoDescriptor mojoDescriptor, return; } + if ( mojoDescriptor.getDeprecated() != null ) + { + logDeprecatedMojo( mojoDescriptor ); + } + if ( mojoDescriptor.getParameters() == null ) { return; @@ -69,7 +75,7 @@ private static void checkParameter( Parameter parameter, if ( isValueSet( config, expressionEvaluator ) ) { - logDeprecateWarn( parameter ); + logDeprecatedParameter( parameter ); } } @@ -110,22 +116,38 @@ private static boolean isValueSet( PlexusConfiguration config, return false; } - private static void logDeprecateWarn( Parameter parameter ) + private void logDeprecatedMojo( MojoDescriptor mojoDescriptor ) + { + String message = MessageUtils.buffer() + .warning( "Goal '" ) + .warning( mojoDescriptor.getGoal() ) + .warning( "' is deprecated: " ) + .warning( mojoDescriptor.getDeprecated() ) + .toString(); + + LOGGER.warn( message ); + } + + private static void logDeprecatedParameter( Parameter parameter ) { - StringBuilder sb = new StringBuilder(); - sb.append( "Parameter '" ); - sb.append( parameter.getName() ); - sb.append( '\'' ); + MessageBuilder messageBuilder = MessageUtils.buffer() + .warning( "Parameter '" ) + .warning( parameter.getName() ) + .warning( '\'' ); + if ( parameter.getExpression() != null ) { String userProperty = parameter.getExpression().replace( "${", "'" ).replace( '}', '\'' ); - sb.append( " (user property " ); - sb.append( userProperty ); - sb.append( ")" ); + messageBuilder + .warning( " (user property " ) + .warning( userProperty ) + .warning( ")" ); } - sb.append( " is deprecated: " ); - sb.append( parameter.getDeprecated() ); - LOGGER.warn( MessageUtils.buffer().warning( sb.toString() ).toString() ); + messageBuilder + .warning( " is deprecated: " ) + .warning( parameter.getDeprecated() ); + + LOGGER.warn( messageBuilder.toString() ); } } From 7b86ce8534010301f806faa631f02c18a5036030 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Wed, 27 Apr 2022 15:17:03 +0200 Subject: [PATCH 163/183] [MNG-7466] Align assembly XSD version with plugin used (#728) As title says, XSD is ancient old 2.0.0, while all latest assembly plugins uses 2.1.0. Not that this matters or changes anything at all, this is more about correctness. --- apache-maven/src/main/assembly/bin.xml | 4 ++-- apache-maven/src/main/assembly/dir.xml | 4 ++-- apache-maven/src/main/assembly/src.xml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apache-maven/src/main/assembly/bin.xml b/apache-maven/src/main/assembly/bin.xml index a04557d506d0..ec0b7c3eab39 100644 --- a/apache-maven/src/main/assembly/bin.xml +++ b/apache-maven/src/main/assembly/bin.xml @@ -17,8 +17,8 @@ specific language governing permissions and limitations under the License. --> - + bin zip diff --git a/apache-maven/src/main/assembly/dir.xml b/apache-maven/src/main/assembly/dir.xml index 580b2098d632..86737b586b9f 100644 --- a/apache-maven/src/main/assembly/dir.xml +++ b/apache-maven/src/main/assembly/dir.xml @@ -17,8 +17,8 @@ specific language governing permissions and limitations under the License. --> - + dir dir diff --git a/apache-maven/src/main/assembly/src.xml b/apache-maven/src/main/assembly/src.xml index 9f43a0a7984e..940467421a87 100644 --- a/apache-maven/src/main/assembly/src.xml +++ b/apache-maven/src/main/assembly/src.xml @@ -17,8 +17,8 @@ specific language governing permissions and limitations under the License. --> - + src zip From 229cfc8bf600cb4dcd28a2303ad656df35feb391 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Wed, 27 Apr 2022 15:18:50 +0200 Subject: [PATCH 164/183] [MNG-7466] Align assembly XSD version with plugin used (#728) The component.xml was missed from original change. --- apache-maven/src/main/assembly/component.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apache-maven/src/main/assembly/component.xml b/apache-maven/src/main/assembly/component.xml index c3014bd06859..3413c4f0405a 100644 --- a/apache-maven/src/main/assembly/component.xml +++ b/apache-maven/src/main/assembly/component.xml @@ -16,8 +16,8 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - + false From 74eba2968b020d8da2360a45c3406a5132eb6aee Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 28 Apr 2022 21:44:34 +0200 Subject: [PATCH 165/183] [MNG-7464] Warn about using read-only parameters for Mojo in configuration (cherry picked from commit 3dd0afd89772929fa89db974d5bc432846f170de) --- ...bstractMavenPluginParametersValidator.java | 153 ++++++++++++++++++ .../internal/DefaultMavenPluginManager.java | 9 +- .../internal/DeprecatedPluginValidator.java | 84 ++-------- .../ReadOnlyPluginParametersValidator.java | 85 ++++++++++ 4 files changed, 261 insertions(+), 70 deletions(-) create mode 100644 maven-core/src/main/java/org/apache/maven/plugin/internal/AbstractMavenPluginParametersValidator.java create mode 100644 maven-core/src/main/java/org/apache/maven/plugin/internal/ReadOnlyPluginParametersValidator.java diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/AbstractMavenPluginParametersValidator.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/AbstractMavenPluginParametersValidator.java new file mode 100644 index 000000000000..3fe62a894f9c --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/AbstractMavenPluginParametersValidator.java @@ -0,0 +1,153 @@ +package org.apache.maven.plugin.internal; + +/* + * 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 java.util.Arrays; +import java.util.List; + +import org.apache.maven.plugin.descriptor.Parameter; +import org.apache.maven.shared.utils.logging.MessageBuilder; +import org.apache.maven.shared.utils.logging.MessageUtils; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; +import org.codehaus.plexus.configuration.PlexusConfiguration; +import org.slf4j.Logger; + +/** + * Common implementations for plugin parameters configuration validation. + * + * @author Slawomir Jaranowski + */ +abstract class AbstractMavenPluginParametersValidator implements MavenPluginConfigurationValidator +{ + + // plugin author can provide @Parameter( property = "session" ) in this case property will always evaluate + // so, we need ignore those + + // source org.apache.maven.plugin.PluginParameterExpressionEvaluator + private static final List IGNORED_PROPERTY_VALUES = Arrays.asList( + "basedir", + "executedProject", + "localRepository", + "mojo", + "mojoExecution", + "plugin", + "project", + "reactorProjects", + "session", + "settings" + ); + + private static final List IGNORED_PROPERTY_PREFIX = Arrays.asList( + "mojo.", + "pom.", + "plugin.", + "project.", + "session.", + "settings." + ); + + protected abstract Logger getLogger(); + + protected static boolean isValueSet( PlexusConfiguration config, + ExpressionEvaluator expressionEvaluator ) + { + if ( config == null ) + { + return false; + } + + // there are sub items ... so configuration is declared + if ( config.getChildCount() > 0 ) + { + return true; + } + + String strValue = config.getValue(); + + if ( strValue == null || strValue.isEmpty() ) + { + return false; + } + + if ( isIgnoredProperty( strValue ) ) + { + return false; + } + + // for declaration like @Parameter( property = "config.property" ) + // the value will contain ${config.property} + + try + { + return expressionEvaluator.evaluate( strValue ) != null; + } + catch ( ExpressionEvaluationException e ) + { + // not important + // will be reported during Mojo fields populate + } + + // fallback - in case of error in expressionEvaluator + return false; + } + + private static boolean isIgnoredProperty( String strValue ) + { + if ( !strValue.startsWith( "${" ) ) + { + return false; + } + + String propertyName = strValue.replace( "${", "" ).replace( "}", "" ); + + if ( IGNORED_PROPERTY_VALUES.contains( propertyName ) ) + { + return true; + } + + return IGNORED_PROPERTY_PREFIX.stream().anyMatch( propertyName::startsWith ); + } + + protected abstract String getParameterLogReason( Parameter parameter ); + + protected void logParameter( Parameter parameter ) + { + MessageBuilder messageBuilder = MessageUtils.buffer() + .warning( "Parameter '" ) + .warning( parameter.getName() ) + .warning( '\'' ); + + if ( parameter.getExpression() != null ) + { + String userProperty = parameter.getExpression().replace( "${", "'" ).replace( '}', '\'' ); + messageBuilder + .warning( " (user property " ) + .warning( userProperty ) + .warning( ")" ); + } + + messageBuilder + .warning( " " ) + .warning( getParameterLogReason( parameter ) ); + + getLogger().warn( messageBuilder.toString() ); + } +} diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java index 8f00f165948d..a69c88eac614 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java @@ -126,7 +126,7 @@ public class DefaultMavenPluginManager * same class realm is used to load build extensions and load mojos for extensions=true plugins. *

    * Note: This is part of internal implementation and may be changed or removed without notice - * + * * @since 3.3.0 */ public static final String KEY_EXTENSIONS_REALMS = DefaultMavenPluginManager.class.getName() + "/extensionsRealms"; @@ -165,7 +165,7 @@ public class DefaultMavenPluginManager private PluginArtifactsCache pluginArtifactsCache; @Requirement - private MavenPluginConfigurationValidator configurationValidator; + private List configurationValidators; private ExtensionDescriptorBuilder extensionDescriptorBuilder = new ExtensionDescriptorBuilder(); @@ -612,7 +612,10 @@ else if ( cause instanceof LinkageError ) ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution ); - configurationValidator.validate( mojoDescriptor, pomConfiguration, expressionEvaluator ); + for ( MavenPluginConfigurationValidator validator: configurationValidators ) + { + validator.validate( mojoDescriptor, pomConfiguration, expressionEvaluator ); + } populateMojoExecutionFields( mojo, mojoExecution.getExecutionId(), mojoDescriptor, pluginRealm, pomConfiguration, expressionEvaluator ); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java index 4c21f80e3ea0..5f4af1a9c7e3 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DeprecatedPluginValidator.java @@ -21,10 +21,8 @@ import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; -import org.apache.maven.shared.utils.logging.MessageBuilder; import org.apache.maven.shared.utils.logging.MessageUtils; import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.slf4j.Logger; @@ -37,10 +35,22 @@ */ @Component( role = MavenPluginConfigurationValidator.class ) -class DeprecatedPluginValidator implements MavenPluginConfigurationValidator +class DeprecatedPluginValidator extends AbstractMavenPluginParametersValidator { private static final Logger LOGGER = LoggerFactory.getLogger( DeprecatedPluginValidator.class ); + @Override + protected Logger getLogger() + { + return LOGGER; + } + + @Override + protected String getParameterLogReason( Parameter parameter ) + { + return "is deprecated: " + parameter.getDeprecated(); + } + @Override public void validate( MojoDescriptor mojoDescriptor, PlexusConfiguration pomConfiguration, @@ -67,53 +77,16 @@ public void validate( MojoDescriptor mojoDescriptor, .forEach( parameter -> checkParameter( parameter, pomConfiguration, expressionEvaluator ) ); } - private static void checkParameter( Parameter parameter, - PlexusConfiguration pomConfiguration, - ExpressionEvaluator expressionEvaluator ) + private void checkParameter( Parameter parameter, + PlexusConfiguration pomConfiguration, + ExpressionEvaluator expressionEvaluator ) { PlexusConfiguration config = pomConfiguration.getChild( parameter.getName(), false ); if ( isValueSet( config, expressionEvaluator ) ) { - logDeprecatedParameter( parameter ); - } - } - - private static boolean isValueSet( PlexusConfiguration config, - ExpressionEvaluator expressionEvaluator ) - { - if ( config == null ) - { - return false; - } - - // there are sub items ... so configuration is declared - if ( config.getChildCount() > 0 ) - { - return true; - } - - String strValue = config.getValue(); - - if ( strValue == null || strValue.isEmpty() ) - { - return false; + logParameter( parameter ); } - - // for declaration like @Parameter( property = "config.property" ) - // the value will contains ${config.property} - try - { - return expressionEvaluator.evaluate( strValue ) != null; - } - catch ( ExpressionEvaluationException e ) - { - // not important - // will be reported during Mojo fields populate - } - - // fallback - in case of error in expressionEvaluator - return false; } private void logDeprecatedMojo( MojoDescriptor mojoDescriptor ) @@ -127,27 +100,4 @@ private void logDeprecatedMojo( MojoDescriptor mojoDescriptor ) LOGGER.warn( message ); } - - private static void logDeprecatedParameter( Parameter parameter ) - { - MessageBuilder messageBuilder = MessageUtils.buffer() - .warning( "Parameter '" ) - .warning( parameter.getName() ) - .warning( '\'' ); - - if ( parameter.getExpression() != null ) - { - String userProperty = parameter.getExpression().replace( "${", "'" ).replace( '}', '\'' ); - messageBuilder - .warning( " (user property " ) - .warning( userProperty ) - .warning( ")" ); - } - - messageBuilder - .warning( " is deprecated: " ) - .warning( parameter.getDeprecated() ); - - LOGGER.warn( messageBuilder.toString() ); - } } diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/ReadOnlyPluginParametersValidator.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/ReadOnlyPluginParametersValidator.java new file mode 100644 index 000000000000..3165b426e80b --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/ReadOnlyPluginParametersValidator.java @@ -0,0 +1,85 @@ +package org.apache.maven.plugin.internal; + +/* + * 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 javax.inject.Named; +import javax.inject.Singleton; + +import org.apache.maven.plugin.descriptor.MojoDescriptor; +import org.apache.maven.plugin.descriptor.Parameter; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; +import org.codehaus.plexus.configuration.PlexusConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Print warnings if read-only parameters of a plugin are used in configuration. + * + * @author Slawomir Jaranowski + */ +@Named +@Singleton +public class ReadOnlyPluginParametersValidator extends AbstractMavenPluginParametersValidator +{ + private static final Logger LOGGER = LoggerFactory.getLogger( ReadOnlyPluginParametersValidator.class ); + + @Override + protected Logger getLogger() + { + return LOGGER; + } + + @Override + protected String getParameterLogReason( Parameter parameter ) + { + return "is read-only, must not be used in configuration"; + } + + @Override + public void validate( MojoDescriptor mojoDescriptor, PlexusConfiguration pomConfiguration, + ExpressionEvaluator expressionEvaluator ) + { + if ( !LOGGER.isWarnEnabled() ) + { + return; + } + + if ( mojoDescriptor.getParameters() == null ) + { + return; + } + + mojoDescriptor.getParameters().stream() + .filter( parameter -> !parameter.isEditable() ) + .forEach( parameter -> checkParameter( parameter, pomConfiguration, expressionEvaluator ) ); + } + + protected void checkParameter( Parameter parameter, + PlexusConfiguration pomConfiguration, + ExpressionEvaluator expressionEvaluator ) + { + PlexusConfiguration config = pomConfiguration.getChild( parameter.getName(), false ); + + if ( isValueSet( config, expressionEvaluator ) ) + { + logParameter( parameter ); + } + } +} From 89237dd74dfef4f2ece8549662e93454f9c7e19e Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 9 May 2022 09:53:33 +0200 Subject: [PATCH 166/183] Revert "[MNG-7347] SessionScoped beans should be singletons for a given session (#653)" (#715) This reverts commit b4518b5fe416a552a59e5201b4569a9bc0af3153. --- .../internal/LifecycleModuleBuilder.java | 13 +- .../lifecycle/internal/LifecycleStarter.java | 3 +- .../lifecycle/internal/ReactorContext.java | 14 +- .../session/scope/internal/SessionScope.java | 159 +++++++++--------- .../scope/internal/SessionScopeTest.java | 132 --------------- 5 files changed, 95 insertions(+), 226 deletions(-) delete mode 100644 maven-core/src/test/java/org/apache/maven/session/scope/internal/SessionScopeTest.java diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java index 1cbaf5334606..548fe6c8ffd6 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java @@ -90,12 +90,8 @@ public void buildProject( MavenSession session, MavenSession rootSession, Reacto // session may be different from rootSession seeded in DefaultMaven // explicitly seed the right session here to make sure it is used by Guice - final boolean scoped = session != rootSession; - if ( scoped ) - { - sessionScope.enter(); - sessionScope.seed( MavenSession.class, session ); - } + sessionScope.enter( reactorContext.getSessionScopeMemento() ); + sessionScope.seed( MavenSession.class, session ); try { @@ -149,10 +145,7 @@ public void buildProject( MavenSession session, MavenSession rootSession, Reacto } finally { - if ( scoped ) - { - sessionScope.exit(); - } + sessionScope.exit(); session.setCurrentProject( null ); diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java index 834498126080..cee80739234d 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java @@ -107,7 +107,8 @@ public void execute( MavenSession session ) ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader(); ReactorBuildStatus reactorBuildStatus = new ReactorBuildStatus( session.getProjectDependencyGraph() ); reactorContext = - new ReactorContext( result, projectIndex, oldContextClassLoader, reactorBuildStatus ); + new ReactorContext( result, projectIndex, oldContextClassLoader, reactorBuildStatus, + sessionScope.memento() ); String builderId = session.getRequest().getBuilderId(); Builder builder = builders.get( builderId ); diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ReactorContext.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ReactorContext.java index 076c6229f8ef..7df531404520 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ReactorContext.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ReactorContext.java @@ -20,6 +20,7 @@ */ import org.apache.maven.execution.MavenExecutionResult; +import org.apache.maven.session.scope.internal.SessionScope; /** * Context that is fixed for the entire reactor build. @@ -39,13 +40,17 @@ public class ReactorContext private final ReactorBuildStatus reactorBuildStatus; + private final SessionScope.Memento sessionScope; + public ReactorContext( MavenExecutionResult result, ProjectIndex projectIndex, - ClassLoader originalContextClassLoader, ReactorBuildStatus reactorBuildStatus ) + ClassLoader originalContextClassLoader, ReactorBuildStatus reactorBuildStatus, + SessionScope.Memento sessionScope ) { this.result = result; this.projectIndex = projectIndex; this.originalContextClassLoader = originalContextClassLoader; this.reactorBuildStatus = reactorBuildStatus; + this.sessionScope = sessionScope; } public ReactorBuildStatus getReactorBuildStatus() @@ -68,4 +73,11 @@ public ClassLoader getOriginalContextClassLoader() return originalContextClassLoader; } + /** + * @since 3.3.0 + */ + public SessionScope.Memento getSessionScopeMemento() + { + return sessionScope; + } } diff --git a/maven-core/src/main/java/org/apache/maven/session/scope/internal/SessionScope.java b/maven-core/src/main/java/org/apache/maven/session/scope/internal/SessionScope.java index 41187fd80cbb..ac423bc6c92c 100644 --- a/maven-core/src/main/java/org/apache/maven/session/scope/internal/SessionScope.java +++ b/maven-core/src/main/java/org/apache/maven/session/scope/internal/SessionScope.java @@ -19,16 +19,16 @@ * under the License. */ -import java.util.Collection; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.CopyOnWriteArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; import com.google.inject.Key; import com.google.inject.OutOfScopeException; import com.google.inject.Provider; import com.google.inject.Scope; +import com.google.inject.util.Providers; /** * SessionScope @@ -36,6 +36,18 @@ public class SessionScope implements Scope { + /** + * @since 3.3.0 + */ + public static class Memento + { + final Map, Provider> seeded; + + Memento( final Map, Provider> seeded ) + { + this.seeded = Collections.unmodifiableMap( new HashMap<>( seeded ) ); + } + } private static final Provider SEEDED_KEY_PROVIDER = new Provider() { @@ -48,127 +60,110 @@ public Object get() /** * ScopeState */ - protected static final class ScopeState + private static final class ScopeState { - private final ConcurrentMap, CachingProvider> provided = new ConcurrentHashMap<>(); + private final Map, Provider> seeded = new HashMap<>(); - public void seed( Class clazz, Provider value ) - { - provided.put( Key.get( clazz ), new CachingProvider<>( value ) ); - } + private final Map, Object> provided = new HashMap<>(); + } - @SuppressWarnings( "unchecked" ) - public Provider scope( Key key, final Provider unscoped ) - { - Provider provider = provided.get( key ); - if ( provider == null ) - { - CachingProvider newValue = new CachingProvider<>( unscoped ); - provider = provided.putIfAbsent( key, newValue ); - if ( provider == null ) - { - provider = newValue; - } - } - return ( Provider ) provider; - } + private final ThreadLocal> values = new ThreadLocal<>(); - public Collection> providers() + public void enter() + { + LinkedList stack = values.get(); + if ( stack == null ) { - return provided.values(); + stack = new LinkedList<>(); + values.set( stack ); } - + stack.addFirst( new ScopeState() ); } - private final List values = new CopyOnWriteArrayList<>(); - - public void enter() + /** + * @since 3.3.0 + */ + public void enter( Memento memento ) { - values.add( 0, new ScopeState() ); + enter(); + getScopeState().seeded.putAll( memento.seeded ); } - protected ScopeState getScopeState() + private ScopeState getScopeState() { - if ( values.isEmpty() ) + LinkedList stack = values.get(); + if ( stack == null || stack.isEmpty() ) { - throw new OutOfScopeException( "Cannot access session scope outside of a scoping block" ); + throw new IllegalStateException(); } - return values.get( 0 ); + return stack.getFirst(); } public void exit() { - if ( values.isEmpty() ) + final LinkedList stack = values.get(); + if ( stack == null || stack.isEmpty() ) { throw new IllegalStateException(); } - values.remove( 0 ); + stack.removeFirst(); + if ( stack.isEmpty() ) + { + values.remove(); + } + } + + /** + * @since 3.3.0 + */ + public Memento memento() + { + LinkedList stack = values.get(); + return new Memento( stack != null ? stack.getFirst().seeded : Collections., Provider>emptyMap() ); } public void seed( Class clazz, Provider value ) { - getScopeState().seed( clazz, value ); + getScopeState().seeded.put( Key.get( clazz ), value ); } public void seed( Class clazz, final T value ) { - seed( clazz, new Provider() - { - @Override - public T get() - { - return value; - } - } ); + getScopeState().seeded.put( Key.get( clazz ), Providers.of( value ) ); } public Provider scope( final Key key, final Provider unscoped ) { - // Lazy evaluating provider return new Provider() { - @Override + @SuppressWarnings( "unchecked" ) public T get() { - return getScopeState().scope( key, unscoped ).get(); - } - }; - } + LinkedList stack = values.get(); + if ( stack == null || stack.isEmpty() ) + { + throw new OutOfScopeException( "Cannot access " + key + " outside of a scoping block" ); + } - /** - * CachingProvider - * @param - */ - protected static class CachingProvider implements Provider - { - private final Provider provider; - private volatile T value; + ScopeState state = stack.getFirst(); - CachingProvider( Provider provider ) - { - this.provider = provider; - } + Provider seeded = state.seeded.get( key ); - public T value() - { - return value; - } + if ( seeded != null ) + { + return (T) seeded.get(); + } - @Override - public T get() - { - if ( value == null ) - { - synchronized ( this ) + T provided = (T) state.provided.get( key ); + if ( provided == null && unscoped != null ) { - if ( value == null ) - { - value = provider.get(); - } + provided = unscoped.get(); + state.provided.put( key, provided ); } + + return provided; } - return value; - } + }; } @SuppressWarnings( { "unchecked" } ) diff --git a/maven-core/src/test/java/org/apache/maven/session/scope/internal/SessionScopeTest.java b/maven-core/src/test/java/org/apache/maven/session/scope/internal/SessionScopeTest.java deleted file mode 100644 index 099e4dddb8f5..000000000000 --- a/maven-core/src/test/java/org/apache/maven/session/scope/internal/SessionScopeTest.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.apache.maven.session.scope.internal; - -/* - * 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 javax.inject.Provider; - -import com.google.inject.Key; -import com.google.inject.OutOfScopeException; -import org.apache.maven.model.locator.DefaultModelLocator; -import org.apache.maven.model.locator.ModelLocator; -import org.apache.maven.plugin.DefaultPluginRealmCache; -import org.apache.maven.plugin.PluginRealmCache; -import org.junit.Test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.fail; - -public class SessionScopeTest { - - @Test - public void testScope() throws Exception - { - SessionScope scope = new SessionScope(); - - try - { - scope.seed( ModelLocator.class, new DefaultModelLocator() ); - fail( "Expected a " + OutOfScopeException.class.getName() + " exception to be thrown" ); - } - catch ( OutOfScopeException e ) - { - // expected - } - - Provider pml = scope.scope( Key.get( ModelLocator.class), new DefaultModelLocatorProvider() ); - assertNotNull( pml ); - try - { - pml.get(); - fail( "Expected a " + OutOfScopeException.class.getName() + " exception to be thrown" ); - } - catch ( OutOfScopeException e ) - { - // expected - } - - Provider pmst = scope.scope( Key.get( PluginRealmCache.class ), new DefaultPluginRealmCacheProvider() ); - assertNotNull( pmst ); - - scope.enter(); - - final DefaultModelLocator dml1 = new DefaultModelLocator(); - scope.seed( ModelLocator.class, dml1 ); - - assertSame( dml1, pml.get() ); - - PluginRealmCache mst1 = pmst.get(); - assertSame( mst1, pmst.get() ); - Provider pmst1 = scope.scope( Key.get( PluginRealmCache.class ), new DefaultPluginRealmCacheProvider() ); - assertNotNull( pmst1 ); - assertSame( mst1, pmst1.get() ); - - scope.enter(); - - pmst1 = scope.scope( Key.get( PluginRealmCache.class ), new DefaultPluginRealmCacheProvider() ); - assertNotNull( pmst1 ); - assertNotSame( mst1, pmst1.get() ); - - scope.exit(); - - assertSame( mst1, pmst.get() ); - - scope.exit(); - - try - { - pmst.get(); - fail( "Expected a " + OutOfScopeException.class.getName() + " exception to be thrown" ); - } - catch ( OutOfScopeException e ) - { - // expected - } - try - { - scope.seed( ModelLocator.class, new DefaultModelLocator() ); - fail( "Expected a " + OutOfScopeException.class.getName() + " exception to be thrown" ); - } - catch ( OutOfScopeException e ) - { - // expected - } - } - - private static class DefaultPluginRealmCacheProvider implements com.google.inject.Provider - { - @Override - public PluginRealmCache get() - { - return new DefaultPluginRealmCache(); - } - } - - private static class DefaultModelLocatorProvider implements com.google.inject.Provider - { - @Override - public ModelLocator get() - { - return new DefaultModelLocator(); - } - } - -} From 4de39476ff690774ece57637e91653d2ef234fd3 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Wed, 11 May 2022 16:06:37 +0200 Subject: [PATCH 167/183] [MNG-7471] Make Resolver util and connector-basic provided (#732) Problem: resolver spi, impl and connector-basic has changes in 1.8.0 (SPI interface RepositoryLayout got new method, that is implemented in connector-basic, and code from impl is using it). But, Maven core exports only resolver api, spi and impl packages, while the rest is at mercy of a plugin. This means ,that these artifacts (api, spi and impl) will always come from Maven core, whatever version plugin declares, while the "rest" (connector-basic and util) will be of version that plugin declares. The current state hence prevented ANY KIND of changes on SPI interfaces that would be implemented in connector-basic (which is the case in Resolver 1.8.0). Solution: make all these resolver artifacts "provided" (to behave like maven-core or maven-plugin-api is behaving): simply put, whatever resolver artifact plugin depends on, it should NOT use it's own version, but the version from Maven. This ensures that api-spi-impl-connector-basic as "aligned" and are same version. Details: The change is to make util is exportedArtifact AND exportedPackage, while connector-basic is only exportedArtifact. Reasoning: * exportedArtifact -- prevents "own" artifact to be added to realm * exportedPackage -- makes it "visible" in realm So, this basically prevents bad versions of util and connector-basic enter the plugin realm (as they will be not added to it), while util remains "visible" to plugins, as the intent was, most common due GenericVersions etc. This change also results in simpler expectations to plugin developers: resolver libraries should really behave like maven-core or maven-compat: when plugin declares dependency on these (w/ scope provided as best practice), they really get version of these that are of version that maven runs in, not version they declare. So same thing happens now with resolver: you will get same version of resolver that maven uses your plugin runs in. Before this change, it was a mixed bag: api, spi and impl was from maven, while util and connector-basic was version you pulled in as dep. --- maven-core/src/main/resources/META-INF/maven/extension.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/maven-core/src/main/resources/META-INF/maven/extension.xml b/maven-core/src/main/resources/META-INF/maven/extension.xml index 905e132bdd2d..a419b3e835df 100644 --- a/maven-core/src/main/resources/META-INF/maven/extension.xml +++ b/maven-core/src/main/resources/META-INF/maven/extension.xml @@ -70,6 +70,7 @@ under the License. org.eclipse.aether.spi org.eclipse.aether.transfer org.eclipse.aether.version + org.eclipse.aether.util org.codehaus.plexus.classworlds @@ -167,6 +168,8 @@ under the License. org.apache.maven.resolver:maven-resolver-api org.apache.maven.resolver:maven-resolver-spi org.apache.maven.resolver:maven-resolver-impl + org.apache.maven.resolver:maven-resolver-util + org.apache.maven.resolver:maven-resolver-connector-basic javax.inject:javax.inject javax.annotation:javax.annotation-api @@ -182,6 +185,8 @@ under the License. org.eclipse.aether:aether-api org.eclipse.aether:aether-spi org.eclipse.aether:aether-impl + org.eclipse.aether:aether-util + org.eclipse.aether:aether-connector-basic