diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index c6feb8bb6..000000000 Binary files a/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index be4fea707..d58dfb70b 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1 +1,19 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip +# 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. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/README.md b/README.md index c481a156e..f3f708ea2 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,9 @@ The project primarily focuses on supporting Maven-based repository structures, e - **Maven**: Version 3.3.9 or newer. - **Gradle**: Version 3 or newer. +## Maven 4 Feature: +- Add the following to your ~/.m2/maven.properties in order to run tests from +within your project's submodules: `maven.consumer.pom=true` or add `-Dmaven.consumer.pom=true` to your Maven package command line. ## Adding ShrinkWrap Resolvers to Your Project diff --git a/api/pom.xml b/api/pom.xml index 94458c8db..1e6d702a8 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -5,7 +5,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../pom.xml diff --git a/bom/pom.xml b/bom/pom.xml index d0aad2ebc..73ba24b7e 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -10,7 +10,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-bom - 3.3.3 + 3.3.4 pom ShrinkWrap Resolver Bill of Materials Centralized dependencyManagement for the ShrinkWrap Resolver Project @@ -29,7 +29,7 @@ scm:git:git://github.com/shrinkwrap/resolver.git scm:git:git@github.com:shrinkwrap/resolver.git https://github.com/shrinkwrap/resolver - 3.3.3 + 3.3.4 diff --git a/build-resources/pom.xml b/build-resources/pom.xml index 8195cf417..353ea9121 100644 --- a/build-resources/pom.xml +++ b/build-resources/pom.xml @@ -4,7 +4,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../pom.xml diff --git a/depchain/pom.xml b/depchain/pom.xml index 8ebb24506..640addf10 100644 --- a/depchain/pom.xml +++ b/depchain/pom.xml @@ -6,7 +6,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../pom.xml diff --git a/gradle/api-gradle-embedded-archive/pom.xml b/gradle/api-gradle-embedded-archive/pom.xml index 557c41d89..2e0dba649 100644 --- a/gradle/api-gradle-embedded-archive/pom.xml +++ b/gradle/api-gradle-embedded-archive/pom.xml @@ -5,7 +5,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../../pom.xml diff --git a/gradle/depchain-gradle/pom.xml b/gradle/depchain-gradle/pom.xml index 22b7d1394..93a4f3110 100644 --- a/gradle/depchain-gradle/pom.xml +++ b/gradle/depchain-gradle/pom.xml @@ -4,7 +4,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../../pom.xml diff --git a/gradle/impl-gradle-embedded-archive/pom.xml b/gradle/impl-gradle-embedded-archive/pom.xml index cbc3199ba..2d5a57752 100644 --- a/gradle/impl-gradle-embedded-archive/pom.xml +++ b/gradle/impl-gradle-embedded-archive/pom.xml @@ -5,7 +5,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../../pom.xml diff --git a/gradle/impl-gradle/pom.xml b/gradle/impl-gradle/pom.xml index fbb0e0e3b..8d8b5404c 100644 --- a/gradle/impl-gradle/pom.xml +++ b/gradle/impl-gradle/pom.xml @@ -5,7 +5,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../../pom.xml diff --git a/maven/api-maven-archive/pom.xml b/maven/api-maven-archive/pom.xml index 1cc34eea5..49e71c3e9 100644 --- a/maven/api-maven-archive/pom.xml +++ b/maven/api-maven-archive/pom.xml @@ -5,7 +5,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../../pom.xml diff --git a/maven/api-maven-embedded/pom.xml b/maven/api-maven-embedded/pom.xml index 27750f7dd..b1ddf1d17 100644 --- a/maven/api-maven-embedded/pom.xml +++ b/maven/api-maven-embedded/pom.xml @@ -5,7 +5,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../../pom.xml diff --git a/maven/api-maven/pom.xml b/maven/api-maven/pom.xml index efc8d1f35..5b48bd583 100644 --- a/maven/api-maven/pom.xml +++ b/maven/api-maven/pom.xml @@ -5,7 +5,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../../pom.xml diff --git a/maven/impl-maven-archive/pom.xml b/maven/impl-maven-archive/pom.xml index 983025bd1..40dbd4d99 100644 --- a/maven/impl-maven-archive/pom.xml +++ b/maven/impl-maven-archive/pom.xml @@ -5,7 +5,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../../pom.xml diff --git a/maven/impl-maven-archive/src/it/jar-sample/pom-b.xml b/maven/impl-maven-archive/src/it/jar-sample/pom-b.xml index 1e4c0e73e..1ab9c9612 100644 --- a/maven/impl-maven-archive/src/it/jar-sample/pom-b.xml +++ b/maven/impl-maven-archive/src/it/jar-sample/pom-b.xml @@ -13,8 +13,8 @@ ShrinkWrap Resolver Maven Importer Implementation Tests: Jar Sample B - 1.17.1 - 5.11.3 + 1.18.0 + 5.12.0 3.4.2 3.0.3.Final diff --git a/maven/impl-maven-archive/src/it/jar-sample/pom-c.xml b/maven/impl-maven-archive/src/it/jar-sample/pom-c.xml index 77c025329..259dae523 100644 --- a/maven/impl-maven-archive/src/it/jar-sample/pom-c.xml +++ b/maven/impl-maven-archive/src/it/jar-sample/pom-c.xml @@ -12,8 +12,8 @@ ShrinkWrap Resolver Maven Importer Implementation Tests: Jar Sample B - 1.17.1 - 5.11.3 + 1.18.0 + 5.12.0 3.4.2 3.0.3.Final diff --git a/maven/impl-maven-archive/src/it/jar-sample/pom.xml b/maven/impl-maven-archive/src/it/jar-sample/pom.xml index e90f9cf4c..a9e07755a 100644 --- a/maven/impl-maven-archive/src/it/jar-sample/pom.xml +++ b/maven/impl-maven-archive/src/it/jar-sample/pom.xml @@ -13,8 +13,8 @@ ShrinkWrap Resolver Maven Importer Implementation Tests: Jar Sample - 1.17.1 - 5.11.3 + 1.18.0 + 5.12.0 3.4.2 3.0.3.Final diff --git a/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-b.xml b/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-b.xml index 198c2bd9e..d21754e61 100644 --- a/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-b.xml +++ b/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-b.xml @@ -13,8 +13,8 @@ ShrinkWrap Resolver Maven Importer Implementation Tests: Jar Sample with Manifest B - 1.17.1 - 5.11.3 + 1.18.0 + 5.12.0 3.4.2 3.0.3.Final diff --git a/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-c.xml b/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-c.xml index 3356d2707..ead6615bb 100644 --- a/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-c.xml +++ b/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-c.xml @@ -13,8 +13,8 @@ ShrinkWrap Resolver Maven Importer Implementation Tests: Jar Sample with Manifest C - 1.17.1 - 5.11.3 + 1.18.0 + 5.12.0 3.4.2 3.0.3.Final diff --git a/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-d.xml b/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-d.xml index 7abe61b95..4b57d5d8f 100644 --- a/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-d.xml +++ b/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-d.xml @@ -13,8 +13,8 @@ ShrinkWrap Resolver Maven Importer Implementation Tests: Jar Sample with Manifest D - 1.17.1 - 5.11.3 + 1.18.0 + 5.12.0 3.4.2 3.0.3.Final diff --git a/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-e.xml b/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-e.xml index 2127cf82c..9bbc247d7 100644 --- a/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-e.xml +++ b/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom-e.xml @@ -13,8 +13,8 @@ ShrinkWrap Resolver Maven Importer Implementation Tests: Jar Sample with Manifest E - 1.17.1 - 5.11.3 + 1.18.0 + 5.12.0 3.4.2 3.0.3.Final diff --git a/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom.xml b/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom.xml index fba90e55f..deb453c26 100644 --- a/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom.xml +++ b/maven/impl-maven-archive/src/it/jar-with-mf-sample/pom.xml @@ -13,8 +13,8 @@ ShrinkWrap Resolver Maven Importer Implementation Tests: Jar Sample with Manifest - 1.17.1 - 5.11.3 + 1.18.0 + 5.12.0 3.4.2 3.0.3.Final diff --git a/maven/impl-maven-archive/src/it/jar-without-resources/pom.xml b/maven/impl-maven-archive/src/it/jar-without-resources/pom.xml index 356e139c9..d32f05222 100644 --- a/maven/impl-maven-archive/src/it/jar-without-resources/pom.xml +++ b/maven/impl-maven-archive/src/it/jar-without-resources/pom.xml @@ -13,8 +13,8 @@ ShrinkWrap Resolver Maven Importer Implementation Tests: Jar Without Resources - 1.17.1 - 5.11.3 + 1.18.0 + 5.12.0 3.4.2 3.0.3.Final diff --git a/maven/impl-maven-archive/src/it/war-sample/pom-b.xml b/maven/impl-maven-archive/src/it/war-sample/pom-b.xml index 8bb667de9..d0b2b132d 100644 --- a/maven/impl-maven-archive/src/it/war-sample/pom-b.xml +++ b/maven/impl-maven-archive/src/it/war-sample/pom-b.xml @@ -13,8 +13,8 @@ ShrinkWrap Resolver Maven Importer Implementation Tests: War Sample B - 1.17.1 - 5.11.3 + 1.18.0 + 5.12.0 3.13.0 3.4.0 3.0.3.Final diff --git a/maven/impl-maven-archive/src/it/war-sample/pom-c.xml b/maven/impl-maven-archive/src/it/war-sample/pom-c.xml index b62b519df..fcdb988f7 100644 --- a/maven/impl-maven-archive/src/it/war-sample/pom-c.xml +++ b/maven/impl-maven-archive/src/it/war-sample/pom-c.xml @@ -13,8 +13,8 @@ ShrinkWrap Resolver Maven Importer Implementation Tests: War Sample C - 1.17.1 - 5.11.3 + 1.18.0 + 5.12.0 3.13.0 3.4.0 3.0.3.Final diff --git a/maven/impl-maven-archive/src/it/war-sample/pom.xml b/maven/impl-maven-archive/src/it/war-sample/pom.xml index 0da4e6405..a3a666254 100644 --- a/maven/impl-maven-archive/src/it/war-sample/pom.xml +++ b/maven/impl-maven-archive/src/it/war-sample/pom.xml @@ -13,8 +13,8 @@ ShrinkWrap Resolver Maven Importer Implementation Tests: War Sample - 1.17.1 - 5.11.3 + 1.18.0 + 5.12.0 3.13.0 3.4.0 3.0.3.Final diff --git a/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/ConfiguredMavenImporterTestCase.java b/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/ConfiguredMavenImporterTestCase.java index f080037e2..71192133a 100644 --- a/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/ConfiguredMavenImporterTestCase.java +++ b/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/ConfiguredMavenImporterTestCase.java @@ -80,7 +80,7 @@ void importJar() { assertThat(archive.getContent(), not(contains("file.toExclude"))); assertThat(archive.getContent(), size(4)); - File commonsCodec = new File(LOCAL_REPOSITORY + "/commons-codec/commons-codec/1.17.1/commons-codec-1.17.1.pom"); + File commonsCodec = new File(LOCAL_REPOSITORY + "/commons-codec/commons-codec/1.18.0/commons-codec-1.18.0.pom"); assertThat(commonsCodec.exists(), is(true)); } @@ -101,7 +101,7 @@ void importJarWithName() { assertThat(archive.getContent(), not(contains("file.toExclude"))); assertThat(archive.getContent(), size(4)); - File commonsCodec = new File(LOCAL_REPOSITORY + "/commons-codec/commons-codec/1.17.1/commons-codec-1.17.1.pom"); + File commonsCodec = new File(LOCAL_REPOSITORY + "/commons-codec/commons-codec/1.18.0/commons-codec-1.18.0.pom"); assertThat(commonsCodec.exists(), is(true)); } diff --git a/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/WarMavenImporterTestCase.java b/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/WarMavenImporterTestCase.java index da6046c42..26ebfc577 100644 --- a/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/WarMavenImporterTestCase.java +++ b/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/WarMavenImporterTestCase.java @@ -116,7 +116,7 @@ private WebArchive doImport(String pomFile) { assertThat(archive.getContent(), not(contains(".svn"))); assertThat(archive.getContent(), not(contains("WEB-INF/.svn"))); - assertThat(archive.getContent(), contains("WEB-INF/lib/commons-codec-1.17.1.jar")); + assertThat(archive.getContent(), contains("WEB-INF/lib/commons-codec-1.18.0.jar")); return archive; } diff --git a/maven/impl-maven-embedded/pom.xml b/maven/impl-maven-embedded/pom.xml index 020c2cec0..c42134fc6 100644 --- a/maven/impl-maven-embedded/pom.xml +++ b/maven/impl-maven-embedded/pom.xml @@ -5,7 +5,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../../pom.xml diff --git a/maven/impl-maven-embedded/src/it/cube-gradle-sample/pom.xml b/maven/impl-maven-embedded/src/it/cube-gradle-sample/pom.xml index edb621b56..a165c4fc5 100644 --- a/maven/impl-maven-embedded/src/it/cube-gradle-sample/pom.xml +++ b/maven/impl-maven-embedded/src/it/cube-gradle-sample/pom.xml @@ -13,7 +13,7 @@ - 5.11.3 + 5.12.0 1.0.0.Alpha15 1.9.1.Final 3.2.2-SNAPSHOT diff --git a/maven/impl-maven-embedded/src/it/jar-sample/pom.xml b/maven/impl-maven-embedded/src/it/jar-sample/pom.xml index 82ef104ac..0199ee727 100644 --- a/maven/impl-maven-embedded/src/it/jar-sample/pom.xml +++ b/maven/impl-maven-embedded/src/it/jar-sample/pom.xml @@ -16,8 +16,8 @@ 1.8 1.8 - 1.17.1 - 5.11.3 + 1.18.0 + 5.12.0 3.4.2 1.0.3.Final diff --git a/maven/impl-maven-embedded/src/it/multi-module-sample/module-one/pom.xml b/maven/impl-maven-embedded/src/it/multi-module-sample/module-one/pom.xml index 93afb1aee..b628fa827 100644 --- a/maven/impl-maven-embedded/src/it/multi-module-sample/module-one/pom.xml +++ b/maven/impl-maven-embedded/src/it/multi-module-sample/module-one/pom.xml @@ -18,8 +18,8 @@ - 1.17.1 - 5.11.3 + 1.18.0 + 5.12.0 1.0.3.Final diff --git a/maven/impl-maven-embedded/src/it/war-sample/pom.xml b/maven/impl-maven-embedded/src/it/war-sample/pom.xml index d99eef6e7..89cf1f665 100644 --- a/maven/impl-maven-embedded/src/it/war-sample/pom.xml +++ b/maven/impl-maven-embedded/src/it/war-sample/pom.xml @@ -17,8 +17,8 @@ 1.8 1.8 - 1.17.1 - 5.11.3 + 1.18.0 + 5.12.0 1.0.3.Final 2.0.16 diff --git a/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/Utils.java b/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/Utils.java index 9096dc63b..c319a08a7 100644 --- a/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/Utils.java +++ b/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/Utils.java @@ -189,7 +189,7 @@ public static void verifyModuleTwo(BuiltProject builtProject) { Assertions.assertEquals(archiveNameModuleTwoParamValue + ".ear", defaultBuiltArchive.getName()); verifyThatArchiveContains(defaultBuiltArchive, "/org.jboss.shrinkwrap.resolver-" + baseArchiveNameModuleOne + ".jar"); - verifyThatArchiveContains(defaultBuiltArchive, "/commons-codec-commons-codec-1.17.1.jar"); + verifyThatArchiveContains(defaultBuiltArchive, "/commons-codec-commons-codec-1.18.0.jar"); // there are no modules Assertions.assertTrue(builtProject.getModules().isEmpty(), "set of modules should be empty"); diff --git a/maven/impl-maven/pom.xml b/maven/impl-maven/pom.xml index 3c45e5a95..54c95a26e 100644 --- a/maven/impl-maven/pom.xml +++ b/maven/impl-maven/pom.xml @@ -6,7 +6,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../../pom.xml diff --git a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenWorkingSessionImpl.java b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenWorkingSessionImpl.java index e4f5444be..e8770ce78 100644 --- a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenWorkingSessionImpl.java +++ b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenWorkingSessionImpl.java @@ -32,6 +32,7 @@ import java.util.Optional; import java.util.Properties; import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; @@ -44,6 +45,7 @@ import org.apache.maven.model.building.DefaultModelBuildingRequest; import org.apache.maven.model.building.ModelBuilder; 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.ModelProblem; import org.eclipse.aether.artifact.Artifact; @@ -159,7 +161,9 @@ public MavenWorkingSession loadPomFromFile(File pomFile, Properties userProperti final DefaultModelBuildingRequest request = new DefaultModelBuildingRequest() .setSystemProperties(SecurityActions.getProperties()).setProfiles(this.getSettingsDefinedProfiles()) .setPomFile(pomFile).setActiveProfileIds(SettingsXmlProfileSelector.explicitlyActivatedProfiles(profiles)) - .setInactiveProfileIds(SettingsXmlProfileSelector.explicitlyDisabledProfiles(profiles)); + .setInactiveProfileIds(SettingsXmlProfileSelector.explicitlyDisabledProfiles(profiles)) + .setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL) + .setProcessPlugins(false); if (userProperties != null){ request.setUserProperties(userProperties); @@ -200,10 +204,12 @@ public MavenWorkingSession loadPomFromFile(File pomFile, Properties userProperti private Collection resolveProjectLocal(final List depsForResolution, Set additionalDependencies) { Collection projectLocalDependencies = new ArrayList<>(depsForResolution.size()); + AtomicBoolean consumerPomFound = new AtomicBoolean(); for (MavenDependency dependency : depsForResolution) { Path resolved = resolveProjectLocal(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), Optional.ofNullable(dependency.getClassifier()), - Optional.ofNullable(dependency.getPackaging().getExtension()), additionalDependencies); + Optional.ofNullable(dependency.getPackaging().getExtension()), + additionalDependencies, consumerPomFound); if (resolved != null && resolved.toFile().exists()) { Artifact artifact = new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), dependency.getPackaging().getExtension(), dependency.getVersion(), @@ -215,12 +221,12 @@ private Collection resolveProjectLocal(final List classifier, Optional extension, - Set additionalDependencies) { + Set additionalDependencies, AtomicBoolean consumerPomFound) { Path projectLocalRepository = findProjectLocalRepository(); if (projectLocalRepository == null) { return null; @@ -228,7 +234,7 @@ private Path resolveProjectLocal(String groupId, String artifactId, String versi Predicate isNotEmpty = s -> !s.isEmpty(); processAdditionalDependencies(projectLocalRepository, groupId, artifactId, version, - additionalDependencies); + additionalDependencies, consumerPomFound); return projectLocalRepository.resolve(groupId).resolve(artifactId).resolve(version) .resolve(toVersionedArtifact(artifactId, version) @@ -242,19 +248,26 @@ private static String toVersionedArtifact(String artifactId, String version) { private void processAdditionalDependencies(Path projectLocalRepository, String groupId, String artifactId, String version, - Set additionalDependencies) { + Set additionalDependencies, + AtomicBoolean consumerPomFound) { Path directory = projectLocalRepository.resolve(groupId).resolve(artifactId).resolve(version); - File pom = directory.resolve(toVersionedArtifact(artifactId, version) + "-consumer.pom").toFile(); - if (!pom.exists()) { - pom = directory.resolve(toVersionedArtifact(artifactId, version) + ".pom").toFile(); + File consumerPom = directory.resolve(toVersionedArtifact(artifactId, version) + "-consumer.pom").toFile(); + File buildPom = directory.resolve(toVersionedArtifact(artifactId, version) + "-build.pom").toFile(); + if (!consumerPom.exists() && buildPom.exists()) { + // in some versions of maven, consumer pom is just generated with ".pom" extension + // in that case, build pom will also exist + consumerPom = directory.resolve(toVersionedArtifact(artifactId, version) + ".pom").toFile(); } - if (pom.exists()) { - Set transitiveDependencies = loadPomFromFile(pom).getParsedPomFile().getDependencies(); + + if (consumerPom.exists()) { + consumerPomFound.set(true); + Set transitiveDependencies = loadPomFromFile(consumerPom).getParsedPomFile().getDependencies(); transitiveDependencies.removeAll(additionalDependencies); if (!transitiveDependencies.isEmpty()) { additionalDependencies.addAll(transitiveDependencies); transitiveDependencies.forEach(dependency -> processAdditionalDependencies(projectLocalRepository, - dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), additionalDependencies)); + dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), + additionalDependencies, consumerPomFound)); } } } @@ -303,8 +316,12 @@ public Collection resolveDependencies(final MavenResoluti } else { Set allDependencies = new LinkedHashSet<>(depsForResolution); projectLocalDependencies = resolveProjectLocal(depsForResolution, allDependencies); - resolveFromRepository = filterFromLocal( - allDependencies.stream().collect(Collectors.toList()), projectLocalDependencies); + if (projectLocalDependencies.isEmpty()) { + resolveFromRepository = depsForResolution; + } else { + resolveFromRepository = filterFromLocal( + allDependencies.stream().collect(Collectors.toList()), projectLocalDependencies); + } } final CollectRequest request = new CollectRequest(MavenConverter.asDependencies(resolveFromRepository, diff --git a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenRepositorySystem.java b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenRepositorySystem.java index 70c2069c7..9b981d1aa 100644 --- a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenRepositorySystem.java +++ b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenRepositorySystem.java @@ -76,7 +76,7 @@ public MavenRepositorySystem() { * @return A working session spawned from the repository system. */ public DefaultRepositorySystemSession getSession(final Settings settings, boolean legacyLocalRepository) { - DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); + DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(context.repositorySystemSession()); MavenManagerBuilder builder = new MavenManagerBuilder(context.repositorySystem(), settings); diff --git a/maven/maven-plugin/pom.xml b/maven/maven-plugin/pom.xml index 5b4cfce88..2bc7c9020 100644 --- a/maven/maven-plugin/pom.xml +++ b/maven/maven-plugin/pom.xml @@ -4,7 +4,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../../pom.xml diff --git a/maven/maven-plugin/src/it/context-propagation/pom.xml b/maven/maven-plugin/src/it/context-propagation/pom.xml index f1f36a771..4c3cad414 100644 --- a/maven/maven-plugin/src/it/context-propagation/pom.xml +++ b/maven/maven-plugin/src/it/context-propagation/pom.xml @@ -12,7 +12,7 @@ 1.8 1.8 - 5.11.3 + 5.12.0 3.1.2 3.3.1 diff --git a/maven/maven-plugin/src/it/dependency-tree-scope/pom.xml b/maven/maven-plugin/src/it/dependency-tree-scope/pom.xml index 3a8e017b7..c4c6bb74b 100644 --- a/maven/maven-plugin/src/it/dependency-tree-scope/pom.xml +++ b/maven/maven-plugin/src/it/dependency-tree-scope/pom.xml @@ -9,7 +9,7 @@ Tests for ShrinkWrap Maven Resolver Plugin: Dependency Tree with Scope - 5.11.3 + 5.12.0 3.1.2 2.4.21 diff --git a/maven/maven-plugin/src/it/dependency-tree/pom.xml b/maven/maven-plugin/src/it/dependency-tree/pom.xml index 5cf488399..c1010395e 100644 --- a/maven/maven-plugin/src/it/dependency-tree/pom.xml +++ b/maven/maven-plugin/src/it/dependency-tree/pom.xml @@ -9,7 +9,7 @@ Tests for ShrinkWrap Maven Resolver Plugin: Dependency Tree - 5.11.3 + 5.12.0 3.1.2 2.4.21 diff --git a/maven/spi-maven-archive/pom.xml b/maven/spi-maven-archive/pom.xml index 51291f83a..dd1356f94 100644 --- a/maven/spi-maven-archive/pom.xml +++ b/maven/spi-maven-archive/pom.xml @@ -5,7 +5,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../../pom.xml diff --git a/maven/spi-maven/pom.xml b/maven/spi-maven/pom.xml index 2559f6169..b8edf7d1c 100644 --- a/maven/spi-maven/pom.xml +++ b/maven/spi-maven/pom.xml @@ -5,7 +5,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../../pom.xml diff --git a/mvnw b/mvnw index 6ecc150ae..19529ddf8 100755 --- a/mvnw +++ b/mvnw @@ -19,218 +19,241 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir +# Apache Maven Wrapper startup batch script, version 3.3.2 # # Optional ENV vars # ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output # ---------------------------------------------------------------------------- -if [ -z "$MAVEN_SKIP_RC" ] ; then +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac + +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 + fi + fi + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi fi +} -fi +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" + done + printf %x\\n $h +} -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # - # Look for the Apple JDKs first to preserve the existing behaviour, and then look - # for the new JDKs provided by Oracle. - # - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then - # - # Oracle JDKs - # - export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then - # - # Apple JDKs - # - export JAVA_HOME=`/usr/libexec/java_home` - fi - ;; -esac +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi +die() { + printf %s\\n "$1" >&2 + exit 1 +} -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" - saveddir=`pwd` +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac - M2_HOME=`dirname "$PRG"`/.. +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} - cd "$saveddir" - # echo Using m2 at $M2_HOME +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" fi -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac -# For Migwn, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" fi -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi +mkdir -p -- "${MAVEN_HOME%/*}" -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" fi -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v + +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac + +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - local basedir=$(pwd) - local wdir=$(pwd) - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true fi - wdir=$(cd "$wdir/.."; pwd) - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 fi -} - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` fi -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" +else + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" +fi +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" -# avoid using MAVEN_CMD_LINE_ARGS below since that would loose parameter escaping in $@ -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" +clean || : +exec_maven "$@" diff --git a/mvnw.cmd b/mvnw.cmd index 8e2b7459f..b150b91ed 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -1,3 +1,4 @@ +<# : batch portion @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @@ -18,129 +19,131 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output @REM ---------------------------------------------------------------------------- -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@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 "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -set MAVEN_CMD_LINE_ARGS=%MAVEN_CONFIG% %* - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR=""%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -# avoid using MAVEN_CMD_LINE_ARGS below since that would loose parameter escaping in %* -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) +) +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/pom.xml b/pom.xml index 23b633fe1..b7710978d 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 pom ShrinkWrap Resolver Aggregator ShrinkWrap Resolver Aggregator @@ -31,10 +31,10 @@ 6.0.0 - 1.17.1 + 1.18.0 1.27.1 2.18.0 - 2.4.20 + 2.4.22 3.9.9 3.15.1 3.3.0 @@ -42,7 +42,7 @@ 2.15.0 2.0 0.9.0.M3 - 8.11.1 + 8.13 1.2.6 @@ -56,9 +56,9 @@ 1.0.8.Final - 5.11.3 - 3.26.3 - 4.2.2 + 5.12.0 + 3.27.3 + 4.3.0 9.4.56.v20240826 4.11.0 @@ -68,7 +68,7 @@ scm:git:git://github.com/shrinkwrap/resolver.git scm:git:git@github.com:shrinkwrap/resolver.git https://github.com/shrinkwrap/resolver - 3.3.3 + 3.3.4 diff --git a/spi/pom.xml b/spi/pom.xml index 7c9e1e3d7..0c2a2b6b2 100644 --- a/spi/pom.xml +++ b/spi/pom.xml @@ -5,7 +5,7 @@ org.jboss.shrinkwrap.resolver shrinkwrap-resolver-parent - 3.3.3 + 3.3.4 ../pom.xml