(maven-artifact-plugin) 01/01: [MNG-8077] tolerate injected timestamp value
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MNG-8077 in repository https://gitbox.apache.org/repos/asf/maven-artifact-plugin.git commit 7f4ba17e0cd16699500ca0da7802df2903d9cfab Author: Romain Manni-Bucau AuthorDate: Sat Mar 16 19:44:32 2024 +0100 [MNG-8077] tolerate injected timestamp value --- pgp-keys-map.list | 8 +++ pom.xml| 6 +++ .../artifact/buildinfo/AbstractBuildinfoMojo.java | 15 -- .../buildinfo/AbstractBuildinfoMojoTest.java | 63 ++ 4 files changed, 89 insertions(+), 3 deletions(-) diff --git a/pgp-keys-map.list b/pgp-keys-map.list index 5e0a25e..845c71a 100644 --- a/pgp-keys-map.list +++ b/pgp-keys-map.list @@ -21,9 +21,17 @@ javax.inject:javax.inject = noSig org.apache.maven.* = 0xB920D295BF0E61CB4CF0896C33CD6733AF5EC452 org.apache.maven:maven-archiver = 0x29BEA2A645F2D6CED7FB12E02B172E3E156466E8 org.apache.maven.shared:maven-shared-utils = 0x84789D24DF77A32433CE1F079EB80E92EB2135B1 +org.apiguardian:apiguardian-api:1.1.2 = 0xFF6E2C001948C5F2F38B0CC385911F425EC61B51 org.codehaus.plexus:plexus-archiver = 0x29BEA2A645F2D6CED7FB12E02B172E3E156466E8 org.codehaus.plexus:plexus-interpolation = 0x47063E8BA7A6450E4A52E7AE466CAED6E0747D50 org.codehaus.plexus:plexus-io = 0xF254B35617DC255D9344BCFA873A8E86B4372146 org.codehaus.plexus:plexus-utils = 0xEA23DB1360D9029481E7F2EFECDFEA3CB4493B94 org.codehaus.plexus:plexus-xml = 0xFA77DCFEF2EE6EB2DEBEDD2C012579464D01C06A +org.junit.jupiter:junit-jupiter:5.10.2 = 0xFF6E2C001948C5F2F38B0CC385911F425EC61B51 +org.junit.jupiter:junit-jupiter-api:5.10.2 = 0xFF6E2C001948C5F2F38B0CC385911F425EC61B51 +org.junit.jupiter:junit-jupiter-engine:5.10.2 = 0xFF6E2C001948C5F2F38B0CC385911F425EC61B51 +org.junit.jupiter:junit-jupiter-params:5.10.2 = 0xFF6E2C001948C5F2F38B0CC385911F425EC61B51 +org.junit.platform:junit-platform-commons:1.10.2 = 0xFF6E2C001948C5F2F38B0CC385911F425EC61B51 +org.junit.platform:junit-platform-engine:1.10.2 = 0xFF6E2C001948C5F2F38B0CC385911F425EC61B51 +org.opentest4j:opentest4j:1.3.0 = 0xFF6E2C001948C5F2F38B0CC385911F425EC61B51 org.slf4j:slf4j-api = 0x475F3B8E59E6E63AA78067482C7B12F2A511E325 diff --git a/pom.xml b/pom.xml index 1637163..6c69006 100644 --- a/pom.xml +++ b/pom.xml @@ -135,6 +135,12 @@ maven-plugin-annotations provided + + org.junit.jupiter + junit-jupiter + 5.10.2 + test + diff --git a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java index 2c0b632..69fa250 100644 --- a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java +++ b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java @@ -166,9 +166,18 @@ public abstract class AbstractBuildinfoMojo extends AbstractMojo { MavenArchiver archiver = new MavenArchiver(); Date timestamp = archiver.parseOutputTimestamp(outputTimestamp); if (timestamp == null) { -log.error("Reproducible Build not activated by project.build.outputTimestamp property: " -+ "see https://maven.apache.org/guides/mini/guide-reproducible-builds.html;); -return true; +// try to resolve it at runtime - injected from a property +String injected = project.getProperties().getProperty("project.build.outputTimestamp"); +if (injected != null) { +log.info("project.build.outputTimestamp is injected by the build"); +} else { +log.error("Reproducible Build not activated by project.build.outputTimestamp property: " ++ "see https://maven.apache.org/guides/mini/guide-reproducible-builds.html, " ++ "ex: " ++ new SimpleDateFormat("-MM-dd'T'HH:mm:ssXXX").format(new Date()) ++ ""); +return true; +} } if (log.isDebugEnabled()) { diff --git a/src/test/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojoTest.java b/src/test/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojoTest.java new file mode 100644 index 000..349e12e --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojoTest.java @@ -0,0 +1,63 @@ +/* + * 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"
(maven-artifact-plugin) branch MNG-8077 created (now 7f4ba17)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MNG-8077 in repository https://gitbox.apache.org/repos/asf/maven-artifact-plugin.git at 7f4ba17 [MNG-8077] tolerate injected timestamp value This branch includes the following new commits: new 7f4ba17 [MNG-8077] tolerate injected timestamp value The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
(maven-scripting-plugin) branch MSCRIPTING-7 created (now 0066393)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSCRIPTING-7 in repository https://gitbox.apache.org/repos/asf/maven-scripting-plugin.git at 0066393 move binding doc to the right doc file No new revisions were added by this update.
(maven-shade-plugin) 02/03: [MSHADE-467] Fix concurrency problem with dependency-reduced POM
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git commit ae907a870b8f585952a62eeaaa5a13fe6d7768ef Author: Alexander Kriegisch AuthorDate: Sat Jan 20 12:09:42 2024 +0700 [MSHADE-467] Fix concurrency problem with dependency-reduced POM It looks as if running MShade concurrently somehow bleeds MavenSession state into other mojo executions. Therefore, in the lower critical section of ShadeMojo::rewriteDependencyReducedPomIfWeHaveReduction, we use a final static ReentrantLock instance to block concurrent entry to the section. --- .../apache/maven/plugins/shade/mojo/ShadeMojo.java | 24 +++--- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java index 396bed1..3a7eaaa 100644 --- a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java +++ b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java @@ -35,6 +35,8 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; @@ -1048,6 +1050,8 @@ public class ShadeMojo extends AbstractMojo { rewriteDependencyReducedPomIfWeHaveReduction(dependencies, modified, transitiveDeps, model); } +private static final Lock LOCK = new ReentrantLock(); + private void rewriteDependencyReducedPomIfWeHaveReduction( List dependencies, boolean modified, List transitiveDeps, Model model) throws IOException, ProjectBuildingException, DependencyGraphBuilderException { @@ -1112,15 +1116,21 @@ public class ShadeMojo extends AbstractMojo { w.close(); } -ProjectBuildingRequest projectBuildingRequest = -new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); - projectBuildingRequest.setLocalRepository(session.getLocalRepository()); - projectBuildingRequest.setRemoteRepositories(project.getRemoteArtifactRepositories()); +// Lock critical section to fix MSHADE-467 +try { +LOCK.lock(); +ProjectBuildingRequest projectBuildingRequest = +new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); + projectBuildingRequest.setLocalRepository(session.getLocalRepository()); + projectBuildingRequest.setRemoteRepositories(project.getRemoteArtifactRepositories()); -ProjectBuildingResult result = projectBuilder.build(f, projectBuildingRequest); +ProjectBuildingResult result = projectBuilder.build(f, projectBuildingRequest); -getLog().debug("updateExcludesInDeps()"); -modified = updateExcludesInDeps(result.getProject(), dependencies, transitiveDeps); +getLog().debug("updateExcludesInDeps()"); +modified = updateExcludesInDeps(result.getProject(), dependencies, transitiveDeps); +} finally { +LOCK.unlock(); +} } project.setFile(dependencyReducedPomLocation);
(maven-shade-plugin) 01/03: [MSHADE-467] Reproduce concurrency problem in an IT
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git commit 87a4f14ef7e5ff898ec9dcb7ef47c71e31c448fd Author: Alexander Kriegisch AuthorDate: Sat Jan 20 13:03:50 2024 +0700 [MSHADE-467] Reproduce concurrency problem in an IT --- .../invoker.properties | 18 ++ .../pom.xml| 184 + .../shadeMT1/pom.xml | 38 + .../shadeMT2/pom.xml | 38 + .../shadeMT3/pom.xml | 38 + .../shadeMT4/pom.xml | 38 + .../verify.groovy | 25 +++ 7 files changed, 379 insertions(+) diff --git a/src/it/projects/MSHADE-467_parallel-dependency-reduced-pom/invoker.properties b/src/it/projects/MSHADE-467_parallel-dependency-reduced-pom/invoker.properties new file mode 100644 index 000..af49e5c --- /dev/null +++ b/src/it/projects/MSHADE-467_parallel-dependency-reduced-pom/invoker.properties @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = package -T 4 diff --git a/src/it/projects/MSHADE-467_parallel-dependency-reduced-pom/pom.xml b/src/it/projects/MSHADE-467_parallel-dependency-reduced-pom/pom.xml new file mode 100644 index 000..99be908 --- /dev/null +++ b/src/it/projects/MSHADE-467_parallel-dependency-reduced-pom/pom.xml @@ -0,0 +1,184 @@ + + +http://maven.apache.org/POM/4.0.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd;> +4.0.0 + +org.apache.maven.its.shade.parallel +MSHADE-467 +1.0.0-SNAPSHOT + +pom + + +shadeMT1 +shadeMT2 +shadeMT3 +shadeMT4 + + + + +org.apache.commons +commons-vfs2 +2.9.0 + + +commons-logging +commons-logging + + +org.apache.hadoop +* + + + + +com.vividsolutions +jts +1.13 + + +xercesImpl +xerces + + + + +com.itextpdf +itextpdf +5.5.13.3 + + +* +* + + + + +org.apache.xmlgraphics +batik-swing +1.17 + + +xml-apis +xml-apis + + +org.apache.xmlgraphics +batik-ext + + + + +org.apache.xmlgraphics +batik-dom +1.17 + + +xerces +xercesImpl + + + + +org.apache.xmlgraphics +batik-transcoder +1.17 + + +* +org.apache.avalon + + +org.apache.xmlgraphics +fop + + + + +org.springframework.boot +spring-boot-starter-test +2.7.18 +test + + +org.junit.jupiter +junit-jupiter + + + + +io.grpc +grpc-core +1.58.0 + + +io.micrometer +micrometer-registry-stackdriver +1.9.16 + + +javax.annotation +
(maven-shade-plugin) 03/03: [MSHADE-467] Improved concurrency problem fix
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git commit e7077c628c2cbb059c829ffb124690f211ba36b0 Author: Alexander Kriegisch AuthorDate: Sun Jan 21 03:44:15 2024 +0700 [MSHADE-467] Improved concurrency problem fix Code review: Synchronising on session.getProjectBuildingRequest() is less invasive than a global reentrant lock and therefore preferable to the reviewer. Co-authored-by: Romain Manni-Bucau --- .../java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java| 10 +- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java index 3a7eaaa..a8475d9 100644 --- a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java +++ b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java @@ -35,8 +35,6 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; @@ -1050,8 +1048,6 @@ public class ShadeMojo extends AbstractMojo { rewriteDependencyReducedPomIfWeHaveReduction(dependencies, modified, transitiveDeps, model); } -private static final Lock LOCK = new ReentrantLock(); - private void rewriteDependencyReducedPomIfWeHaveReduction( List dependencies, boolean modified, List transitiveDeps, Model model) throws IOException, ProjectBuildingException, DependencyGraphBuilderException { @@ -1116,9 +1112,7 @@ public class ShadeMojo extends AbstractMojo { w.close(); } -// Lock critical section to fix MSHADE-467 -try { -LOCK.lock(); +synchronized (session.getProjectBuildingRequest()) { // Lock critical section to fix MSHADE-467 ProjectBuildingRequest projectBuildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); projectBuildingRequest.setLocalRepository(session.getLocalRepository()); @@ -1128,8 +1122,6 @@ public class ShadeMojo extends AbstractMojo { getLog().debug("updateExcludesInDeps()"); modified = updateExcludesInDeps(result.getProject(), dependencies, transitiveDeps); -} finally { -LOCK.unlock(); } }
(maven-shade-plugin) branch master updated (4753d8e -> e7077c6)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git from 4753d8e Bump org.codehaus.plexus:plexus-utils from 3.5.1 to 4.0.0 new 87a4f14 [MSHADE-467] Reproduce concurrency problem in an IT new ae907a8 [MSHADE-467] Fix concurrency problem with dependency-reduced POM new e7077c6 [MSHADE-467] Improved concurrency problem fix The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../invoker.properties | 2 +- .../pom.xml| 184 + .../shadeMT1}/pom.xml | 31 ++-- .../shadeMT2}/pom.xml | 31 ++-- .../shadeMT3}/pom.xml | 31 ++-- .../shadeMT4}/pom.xml | 31 ++-- .../verify.groovy | 9 +- .../apache/maven/plugins/shade/mojo/ShadeMojo.java | 16 +- 8 files changed, 261 insertions(+), 74 deletions(-) copy src/it/projects/{MSHADE-382_skip_execution => MSHADE-467_parallel-dependency-reduced-pom}/invoker.properties (96%) create mode 100644 src/it/projects/MSHADE-467_parallel-dependency-reduced-pom/pom.xml copy src/it/projects/{MSHADE-413-parallel => MSHADE-467_parallel-dependency-reduced-pom/shadeMT1}/pom.xml (64%) copy src/it/projects/{MSHADE-413-parallel => MSHADE-467_parallel-dependency-reduced-pom/shadeMT2}/pom.xml (64%) copy src/it/projects/{MSHADE-413-parallel => MSHADE-467_parallel-dependency-reduced-pom/shadeMT3}/pom.xml (64%) copy src/it/projects/{MSHADE-413-parallel => MSHADE-467_parallel-dependency-reduced-pom/shadeMT4}/pom.xml (64%) copy src/it/projects/{MSHADE-382_skip_execution => MSHADE-467_parallel-dependency-reduced-pom}/verify.groovy (78%)
[maven] branch MNG-7831 deleted (was 981f64d3c)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MNG-7831 in repository https://gitbox.apache.org/repos/asf/maven.git was 981f64d3c [MNG-7831] Ensure XmlUtils does not fail when xmlpullparser detects an entityref and parser.name is null This change permanently discards the following revisions: discard 981f64d3c [MNG-7831] Ensure XmlUtils does not fail when xmlpullparser detects an entityref and parser.name is null
[maven] 01/01: [MNG-7831] Ensure XmlUtils does not fail when xmlpullparser detects an entityref and parser.name is null
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MNG-7831 in repository https://gitbox.apache.org/repos/asf/maven.git commit 981f64d3cd1a7a61da9f6a223b79f1d9038092ee Author: Romain Manni-Bucau AuthorDate: Sun Jul 2 19:29:15 2023 +0200 [MNG-7831] Ensure XmlUtils does not fail when xmlpullparser detects an entityref and parser.name is null --- .../ConsumerPomArtifactTransformerTest.java| 26 ++ .../test/resources/projects/transform/before2.pom | 11 + .../maven/model/transform/pull/XmlUtils.java | 20 - 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/maven-core/src/test/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformerTest.java b/maven-core/src/test/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformerTest.java index 27c4d15e6..68ab7097c 100644 --- a/maven-core/src/test/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformerTest.java +++ b/maven-core/src/test/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformerTest.java @@ -18,8 +18,11 @@ */ package org.apache.maven.internal.transformation; +import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -33,7 +36,9 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.xmlunit.assertj.XmlAssert; +import static java.util.stream.Collectors.joining; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; @@ -52,6 +57,27 @@ class ConsumerPomArtifactTransformerTest { } } +@Test +void transform2() throws Exception { +Path beforePomFile = + Paths.get("src/test/resources/projects/transform/before2.pom").toAbsolutePath(); +try (BufferedReader result = new BufferedReader(new InputStreamReader( +ConsumerPomArtifactTransformer.transform(beforePomFile, new NoTransformerContext()), +StandardCharsets.UTF_8))) { +assertEquals( +"\n" ++ "http://maven.apache.org/POM/4.0.0\; xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\; xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\;>\n" ++ " 4.0.0\n" ++ "\n" ++ " com.apache.maven\n" ++ " transform-me\n" ++ " 1.0.0-SNAPSHOT\n" ++ " 1 2\n" ++ "", +result.lines().collect(joining("\n"))); +} +} + @Test void injectTransformedArtifactsWithoutPomShouldNotInjectAnyArtifacts() throws IOException { MavenProject emptyProject = new MavenProject(); diff --git a/maven-core/src/test/resources/projects/transform/before2.pom b/maven-core/src/test/resources/projects/transform/before2.pom new file mode 100644 index 0..e32b2b6ae --- /dev/null +++ b/maven-core/src/test/resources/projects/transform/before2.pom @@ -0,0 +1,11 @@ + +http://maven.apache.org/POM/4.0.0; + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd;> + 4.0.0 + + com.apache.maven + transform-me + 1.0.0-SNAPSHOT + 1 2 + diff --git a/maven-model-transform/src/main/java/org/apache/maven/model/transform/pull/XmlUtils.java b/maven-model-transform/src/main/java/org/apache/maven/model/transform/pull/XmlUtils.java index a2f71aa55..80d2c62b7 100644 --- a/maven-model-transform/src/main/java/org/apache/maven/model/transform/pull/XmlUtils.java +++ b/maven-model-transform/src/main/java/org/apache/maven/model/transform/pull/XmlUtils.java @@ -78,7 +78,25 @@ public class XmlUtils { serializer.cdsect(parser.getText()); break; case XmlPullParser.ENTITY_REF: -serializer.entityRef(parser.getName()); +final String name = parser.getName(); +if (name != null) { +serializer.entityRef(name); +} else { // mxparser is pseudo-bugy so handle this case (escaped xml char) in a tag without cdata +final String text = parser.getText(); +switch (text) { +
[maven] branch MNG-7831 created (now 981f64d3c)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MNG-7831 in repository https://gitbox.apache.org/repos/asf/maven.git at 981f64d3c [MNG-7831] Ensure XmlUtils does not fail when xmlpullparser detects an entityref and parser.name is null This branch includes the following new commits: new 981f64d3c [MNG-7831] Ensure XmlUtils does not fail when xmlpullparser detects an entityref and parser.name is null The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven] 01/01: [MNG-7827] Ensure maven 4 Log API is the primary and documented API for mojos
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MNG-7827 in repository https://gitbox.apache.org/repos/asf/maven.git commit 74be0f4143e22e098cd03013e731498418ac8542 Author: Romain Manni-Bucau AuthorDate: Mon Jun 26 19:35:00 2023 +0200 [MNG-7827] Ensure maven 4 Log API is the primary and documented API for mojos --- maven-plugin-api/pom.xml | 14 +++ .../java/org/apache/maven/plugin/AbstractMojo.java | 48 +++- .../maven/plugin/logging/SystemStreamLog.java | 56 -- .../org/apache/maven/internal/impl/DefaultLog.java | 118 .../org/apache/maven/plugin/AbstractMojoTest.java | 123 + 5 files changed, 348 insertions(+), 11 deletions(-) diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml index 274a62ef6..db3000e36 100644 --- a/maven-plugin-api/pom.xml +++ b/maven-plugin-api/pom.xml @@ -52,6 +52,20 @@ under the License. org.codehaus.plexus plexus-classworlds + + + ${project.groupId} + maven-api-core + ${project.version} + provided + + + + org.slf4j + slf4j-jdk14 + ${slf4jVersion} + test + diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojo.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojo.java index 5e76c40d9..dba25a40f 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojo.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojo.java @@ -18,11 +18,18 @@ */ package org.apache.maven.plugin; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; import java.util.Map; +import java.util.function.Supplier; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugin.logging.SystemStreamLog; +import static java.util.Optional.ofNullable; + /** * Abstract class to provide most of the infrastructure required to implement a Mojo except for * the execute method. @@ -147,7 +154,7 @@ public abstract class AbstractMojo implements Mojo, ContextEnabled { private Map pluginContext; /** - * @deprecated Use SLF4J directly + * @deprecated Use an injected {@link Log} instead in the mojo or component. */ @Deprecated @Override @@ -167,13 +174,48 @@ public abstract class AbstractMojo implements Mojo, ContextEnabled { * method directly whenever you need the logger, it is fast enough and needs no caching. * * @see org.apache.maven.plugin.Mojo#getLog() - * @deprecated Use SLF4J directly + * @deprecated Use an injected {@link org.apache.maven.api.plugin.Log} instead in the mojo or component. */ @Deprecated @Override public Log getLog() { if (log == null) { -log = new SystemStreamLog(); +// unlikely for a standard plugin, idea is to try to fallback on maven-core impl else use stdout/stderr +try { +// ensure we have slf4j +final ClassLoader loader = ofNullable(getClass().getClassLoader()) +.orElseGet(() -> Thread.currentThread().getContextClassLoader()); +final Class lf = loader.loadClass("org.slf4j.LoggerFactory"); +final Method getLogger = lf.getDeclaredMethod("getLogger", Class.class); +if (!getLogger.isAccessible()) { +getLogger.setAccessible(true); +} + +// ensure we have maven-core - else we don't care to align on it +final Constructor delegatingLogConstructor = loader.loadClass( +"org.apache.maven.internal.impl.DefaultLog") +.getDeclaredConstructor(getLogger.getReturnType()); +if (!delegatingLogConstructor.isAccessible()) { +delegatingLogConstructor.setAccessible(true); +} + +// load the slf4j logger and its log impl + create a facade to comply the deprecated API +final Object logger = getLogger.invoke(null, getClass()); +final Object delegate = delegatingLogConstructor.newInstance(logger); +log = (Log) Proxy.newProxyInstance( // Supplier is mainly an "unwrap" impl for advanced cases +loader, new Class[] {Log.class, Supplier.class}, (proxy, method, args) -> { +if (method.getDeclaringClass() == Supplier.class) { +return delegate; +} +try { +return method.invoke(delegate, args); +} catch (InvocationTargetException
[maven] branch MNG-7827 created (now 74be0f414)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MNG-7827 in repository https://gitbox.apache.org/repos/asf/maven.git at 74be0f414 [MNG-7827] Ensure maven 4 Log API is the primary and documented API for mojos This branch includes the following new commits: new 74be0f414 [MNG-7827] Ensure maven 4 Log API is the primary and documented API for mojos The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven] 01/01: [MNG-7532] Log shouldn't have been deprecated so ensure it is not
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MNG-7532 in repository https://gitbox.apache.org/repos/asf/maven.git commit 1f0ed60ba0d9e8c691588cd4c285966d28b614c9 Author: Romain Manni-Bucau AuthorDate: Wed Aug 24 08:53:23 2022 +0200 [MNG-7532] Log shouldn't have been deprecated so ensure it is not --- .../src/main/java/org/apache/maven/plugin/AbstractMojo.java | 6 -- maven-plugin-api/src/main/java/org/apache/maven/plugin/Mojo.java| 4 .../src/main/java/org/apache/maven/plugin/logging/Log.java | 2 -- .../main/java/org/apache/maven/plugin/logging/SystemStreamLog.java | 2 -- 4 files changed, 14 deletions(-) diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojo.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojo.java index 4042f84de..6a74a64eb 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojo.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojo.java @@ -149,10 +149,6 @@ public abstract class AbstractMojo /** Plugin container context */ private Map pluginContext; -/** - * @deprecated Use SLF4J directly - */ -@Deprecated @Override public void setLog( Log log ) { @@ -171,9 +167,7 @@ public abstract class AbstractMojo * method directly whenever you need the logger, it is fast enough and needs no caching. * * @see org.apache.maven.plugin.Mojo#getLog() - * @deprecated Use SLF4J directly */ -@Deprecated @Override public Log getLog() { diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/Mojo.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/Mojo.java index 041917605..aa277f933 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/Mojo.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/Mojo.java @@ -55,9 +55,7 @@ public interface Mojo * * @param log a new logger * - * @deprecated Use SLF4J directly */ -@Deprecated void setLog( Log log ); /** @@ -65,8 +63,6 @@ public interface Mojo * * @return a log4j-like logger object which allows plugins to create messages at levels of "debug", * "info", "warn", and "error". - * @deprecated Use SLF4J directly */ -@Deprecated Log getLog(); } diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/Log.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/Log.java index 04d85bd96..a2cf2a05b 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/Log.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/Log.java @@ -29,9 +29,7 @@ package org.apache.maven.plugin.logging; * * @author jdcasey * - * @deprecated Use SLF4J directly */ -@Deprecated public interface Log { /** diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/SystemStreamLog.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/SystemStreamLog.java index f0fc6189d..885eead00 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/SystemStreamLog.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/SystemStreamLog.java @@ -27,9 +27,7 @@ import java.io.StringWriter; * * @author jdcasey * - * @deprecated Use SLF4J directly */ -@Deprecated public class SystemStreamLog implements Log {
[maven] branch MNG-7532 updated (079bd7fca -> 1f0ed60ba)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MNG-7532 in repository https://gitbox.apache.org/repos/asf/maven.git discard 079bd7fca MNG-7532 Log shouldn't have been deprecated so ensure it is not new 1f0ed60ba [MNG-7532] Log shouldn't have been deprecated so ensure it is not This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (079bd7fca) \ N -- N -- N refs/heads/MNG-7532 (1f0ed60ba) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes:
[maven] branch MNG-7532 created (now 079bd7fca)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MNG-7532 in repository https://gitbox.apache.org/repos/asf/maven.git at 079bd7fca MNG-7532 Log shouldn't have been deprecated so ensure it is not This branch includes the following new commits: new 079bd7fca MNG-7532 Log shouldn't have been deprecated so ensure it is not The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven] 01/01: MNG-7532 Log shouldn't have been deprecated so ensure it is not
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MNG-7532 in repository https://gitbox.apache.org/repos/asf/maven.git commit 079bd7fca343478d5b2c7b61f5e971199e36c730 Author: Romain Manni-Bucau AuthorDate: Wed Aug 24 08:53:23 2022 +0200 MNG-7532 Log shouldn't have been deprecated so ensure it is not --- .../src/main/java/org/apache/maven/plugin/AbstractMojo.java | 6 -- maven-plugin-api/src/main/java/org/apache/maven/plugin/Mojo.java| 4 .../src/main/java/org/apache/maven/plugin/logging/Log.java | 2 -- .../main/java/org/apache/maven/plugin/logging/SystemStreamLog.java | 2 -- 4 files changed, 14 deletions(-) diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojo.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojo.java index 4042f84de..6a74a64eb 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojo.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojo.java @@ -149,10 +149,6 @@ public abstract class AbstractMojo /** Plugin container context */ private Map pluginContext; -/** - * @deprecated Use SLF4J directly - */ -@Deprecated @Override public void setLog( Log log ) { @@ -171,9 +167,7 @@ public abstract class AbstractMojo * method directly whenever you need the logger, it is fast enough and needs no caching. * * @see org.apache.maven.plugin.Mojo#getLog() - * @deprecated Use SLF4J directly */ -@Deprecated @Override public Log getLog() { diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/Mojo.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/Mojo.java index 041917605..aa277f933 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/Mojo.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/Mojo.java @@ -55,9 +55,7 @@ public interface Mojo * * @param log a new logger * - * @deprecated Use SLF4J directly */ -@Deprecated void setLog( Log log ); /** @@ -65,8 +63,6 @@ public interface Mojo * * @return a log4j-like logger object which allows plugins to create messages at levels of "debug", * "info", "warn", and "error". - * @deprecated Use SLF4J directly */ -@Deprecated Log getLog(); } diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/Log.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/Log.java index 04d85bd96..a2cf2a05b 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/Log.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/Log.java @@ -29,9 +29,7 @@ package org.apache.maven.plugin.logging; * * @author jdcasey * - * @deprecated Use SLF4J directly */ -@Deprecated public interface Log { /** diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/SystemStreamLog.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/SystemStreamLog.java index f0fc6189d..885eead00 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/SystemStreamLog.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/SystemStreamLog.java @@ -27,9 +27,7 @@ import java.io.StringWriter; * * @author jdcasey * - * @deprecated Use SLF4J directly */ -@Deprecated public class SystemStreamLog implements Log {
[maven-wrapper] branch enable-to-customize-classworlds.conf created (now 70289ea)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch enable-to-customize-classworlds.conf in repository https://gitbox.apache.org/repos/asf/maven-wrapper.git at 70289ea Enable to customize classworlds.conf This branch includes the following new commits: new 70289ea Enable to customize classworlds.conf The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven-wrapper] 01/01: Enable to customize classworlds.conf
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch enable-to-customize-classworlds.conf in repository https://gitbox.apache.org/repos/asf/maven-wrapper.git commit 70289ea81465aa5c4410127833fe906b5f71c3c9 Author: Romain Manni-Bucau AuthorDate: Thu Aug 4 11:15:36 2022 +0200 Enable to customize classworlds.conf --- .../apache/maven/wrapper/BootstrapMainStarter.java | 37 -- .../org/apache/maven/wrapper/WrapperExecutor.java | 2 +- .../apache/maven/wrapper/WrapperExecutorTest.java | 8 +++-- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/BootstrapMainStarter.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/BootstrapMainStarter.java index 71f4186..f64ca7f 100644 --- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/BootstrapMainStarter.java +++ b/maven-wrapper/src/main/java/org/apache/maven/wrapper/BootstrapMainStarter.java @@ -21,6 +21,7 @@ package org.apache.maven.wrapper; import java.io.FileNotFoundException; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; @@ -29,6 +30,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Iterator; import java.util.Locale; +import java.util.Properties; /** * Maven starter, from a provided Maven home directory. @@ -37,22 +39,51 @@ import java.util.Locale; */ public class BootstrapMainStarter { -public void start( String[] args, Path mavenHome ) +public void start( String[] args, Path mavenHome, Properties properties ) throws Exception { final Path mavenJar = findLauncherJar( mavenHome ); URLClassLoader contextClassLoader = new URLClassLoader( new URL[] { mavenJar.toUri().toURL() }, - ClassLoader.getSystemClassLoader().getParent() ); +ClassLoader.getSystemClassLoader().getParent() ); + +// can be useful to leak the classloader with some daemon mojo but generally a wrong idea so off by default +if ( Boolean.parseBoolean( properties.getProperty( getClass().getName() + ".leakClassloader" ) ) ) +{ +doStart( args, mavenHome, properties, contextClassLoader ); +return; +} + +try ( final URLClassLoader ref = contextClassLoader ) +{ +doStart( args, mavenHome, properties, contextClassLoader ); +} +} + +private void doStart( final String[] args, final Path mavenHome, + final Properties properties, + final URLClassLoader contextClassLoader ) +throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException +{ Thread.currentThread().setContextClassLoader( contextClassLoader ); Class mainClass = contextClassLoader.loadClass( "org.codehaus.plexus.classworlds.launcher.Launcher" ); System.setProperty( "maven.home", mavenHome.toAbsolutePath().toString() ); -System.setProperty( "classworlds.conf", mavenHome.resolve( "bin/m2.conf" ).toAbsolutePath().toString() ); +System.setProperty( "classworlds.conf", getClassworldsConf( properties, mavenHome ) ); Method mainMethod = mainClass.getMethod( "main", String[].class ); mainMethod.invoke( null, new Object[] { args } ); } +private String getClassworldsConf( Properties properties, Path mavenHome ) +{ +final String override = properties.getProperty( "classworlds.conf" ); +if ( override != null ) +{ +return override; +} +return mavenHome.resolve( "bin/m2.conf" ).toAbsolutePath().toString(); +} + private Path findLauncherJar( Path mavenHome ) throws IOException { diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/WrapperExecutor.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/WrapperExecutor.java index f69d7cc..f606fba 100644 --- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/WrapperExecutor.java +++ b/maven-wrapper/src/main/java/org/apache/maven/wrapper/WrapperExecutor.java @@ -177,7 +177,7 @@ public class WrapperExecutor throws Exception { Path mavenHome = install.createDist( config ); -bootstrapMainStarter.start( args, mavenHome ); +bootstrapMainStarter.start( args, mavenHome, properties ); } private String getProperty( String propertyName ) diff --git a/maven-wrapper/src/test/java/org/apache/maven/wrapper/WrapperExecutorTest.java b/maven-wrapper/src/test/java/org/apache/maven/wrapper/WrapperExecutorTest.java index fb91f2d..9e874d6 100644 --- a/maven-wrapper/src
[maven-shade-plugin] branch master updated: [MSHADE-412] avoid possible NPE since rawString was added in SimpleRelocator (#123)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git The following commit(s) were added to refs/heads/master by this push: new 17b87aa [MSHADE-412] avoid possible NPE since rawString was added in SimpleRelocator (#123) 17b87aa is described below commit 17b87aa368db6e0bcea4f6c2f1e07e46945f2f4b Author: Romain Manni-Bucau AuthorDate: Thu Mar 17 13:40:30 2022 +0100 [MSHADE-412] avoid possible NPE since rawString was added in SimpleRelocator (#123) --- .../org/apache/maven/plugins/shade/relocation/SimpleRelocator.java | 2 +- .../apache/maven/plugins/shade/relocation/SimpleRelocatorTest.java | 6 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java b/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java index 3837a67..df51ea2 100644 --- a/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java +++ b/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java @@ -242,7 +242,7 @@ public class SimpleRelocator public String relocateClass( String clazz ) { -return clazz.replaceFirst( pattern, shadedPattern ); +return rawString ? clazz : clazz.replaceFirst( pattern, shadedPattern ); } public String applyToSourceContent( String sourceContent ) diff --git a/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorTest.java b/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorTest.java index e85972a..699d1b3 100644 --- a/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorTest.java +++ b/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorTest.java @@ -39,6 +39,12 @@ public class SimpleRelocatorTest { @Test +public void testNoNpeRelocateClass() +{ +new SimpleRelocator( "foo", "bar", null, null, true ).relocateClass( "foo" ); +} + +@Test public void testCanRelocatePath() { SimpleRelocator relocator;
[maven-shade-plugin] branch MSHADE-412_avoid-npe updated (81a374b -> d76efb3)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-412_avoid-npe in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. discard 81a374b MSHADE-412 avoid possible NPE since rawString was added in SimpleRelocator add d76efb3 [MSHADE-412] avoid possible NPE since rawString was added in SimpleRelocator This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (81a374b) \ N -- N -- N refs/heads/MSHADE-412_avoid-npe (d76efb3) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes:
[maven-shade-plugin] branch MSHADE-412_avoid-npe updated (9fcbb47 -> 81a374b)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-412_avoid-npe in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. discard 9fcbb47 test for the fix discard 6019c9f MSHADE-412 avoid possible NPE since rawString was added in SimpleRelocator add 81a374b MSHADE-412 avoid possible NPE since rawString was added in SimpleRelocator This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (9fcbb47) \ N -- N -- N refs/heads/MSHADE-412_avoid-npe (81a374b) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes:
[maven-shade-plugin] branch MSHADE-412_avoid-npe updated (6019c9f -> 9fcbb47)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-412_avoid-npe in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. from 6019c9f MSHADE-412 avoid possible NPE since rawString was added in SimpleRelocator add 9fcbb47 test for the fix No new revisions were added by this update. Summary of changes: .../apache/maven/plugins/shade/relocation/SimpleRelocatorTest.java | 6 ++ 1 file changed, 6 insertions(+)
[maven-shade-plugin] branch MSHADE-412_avoid-npe created (now 6019c9f)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-412_avoid-npe in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. at 6019c9f MSHADE-412 avoid possible NPE since rawString was added in SimpleRelocator No new revisions were added by this update.
[maven-shade-plugin] branch master updated (c13c9bb -> c648ccf)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. from c13c9bb Bump slf4j.version from 1.7.31 to 1.7.32 (#113) new 1dca37c [MSHADE-396] Improve SourceContent Shading new c648ccf [MSHADE-396] Add explanation to shadeSourcesContent documentation The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../apache/maven/plugins/shade/mojo/ShadeMojo.java | 16 ++-- .../plugins/shade/relocation/SimpleRelocator.java | 41 ++- .../shade/relocation/SimpleRelocatorTest.java | 46 ++ 3 files changed, 83 insertions(+), 20 deletions(-)
[maven-shade-plugin] 02/02: [MSHADE-396] Add explanation to shadeSourcesContent documentation
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git commit c648ccfade767acd5a59893a1719b58ed02fad99 Author: Alexander Kriegisch AuthorDate: Mon Jul 12 16:01:33 2021 +0700 [MSHADE-396] Add explanation to shadeSourcesContent documentation Explain purpose and limitations of heuristic source code shading approach. --- .../org/apache/maven/plugins/shade/mojo/ShadeMojo.java | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java index 6cc019c..d717253 100644 --- a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java +++ b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java @@ -327,9 +327,19 @@ public class ShadeMojo private boolean createTestSourcesJar; /** - * When true, it will attempt to shade the contents of the java source files when creating the sources jar. When - * false, it will just relocate the java source files to the shaded paths, but will not modify the actual contents - * of the java source files. + * When true, it will attempt to shade the contents of Java source files when creating the sources JAR. When false, + * it will just relocate the Java source files to the shaded paths, but will not modify the actual source file + * contents. + * + * Please note: This feature uses a heuristic search & replace approach which covers many, but definitely not + * all possible cases of source code shading and its excludes. There is no full Java parser behind this + * functionality, which would be the only way to get this right for Java language elements. As for matching within + * Java string constants, this is next to impossible to get 100% right, trying to guess if they are used in + * reflection or not. + * + * Please understand that the source shading feature is not meant as a source code generator anyway, merely as a + * tool creating reasonably plausible source code when navigating to a relocated library class from an IDE, + * hopefully displaying source code which makes 95% sense - no more, no less. */ @Parameter( property = "shadeSourcesContent", defaultValue = "false" ) private boolean shadeSourcesContent;
[maven-shade-plugin] 01/02: [MSHADE-396] Improve SourceContent Shading
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git commit 1dca37c71649fa4f4aa110de3b78cc98d0e47eda Author: Alexander Kriegisch AuthorDate: Mon Jul 12 14:44:53 2021 +0700 [MSHADE-396] Improve SourceContent Shading Improve search & replace heuristics without destroying previously correct replacements in my test project (AspectJ). This solution is still bound to fail in some situations, simply because it is just a heuristic approach and not a full Java parser correctly recognising package names in all possible situations in Java source code. As for matching within Java string constants, this is next to impossible to get 100% right. But the source shading feature is not meant as a source code generator anyway, merely as a tool creating reasonably plausible source code when navigating to a relocated library class from an IDE, hopefully displaying source code which makes 95% sense - no more, no less. --- .../plugins/shade/relocation/SimpleRelocator.java | 41 ++- .../shade/relocation/SimpleRelocatorTest.java | 46 ++ 2 files changed, 70 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java b/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java index 083957f..3837a67 100644 --- a/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java +++ b/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java @@ -34,6 +34,23 @@ import java.util.regex.Pattern; public class SimpleRelocator implements Relocator { +/** + * Match dot, slash or space at end of string + */ +private static final Pattern RX_ENDS_WITH_DOT_SLASH_SPACE = Pattern.compile( "[./ ]$" ); + +/** + * Match + * certain Java keywords + space + * beginning of Javadoc link + optional line breaks and continuations with '*' + * + * at end of string + */ +private static final Pattern RX_ENDS_WITH_JAVA_KEYWORD = Pattern.compile( + "\\b(import|package|public|protected|private|static|final|synchronized|abstract|volatile) $" ++ "|" ++ "\\{@link( \\*)* $" +); private final String pattern; @@ -104,7 +121,7 @@ public class SimpleRelocator { this.includes.addAll( includes ); } - + if ( excludes != null && !excludes.isEmpty() ) { this.excludes.addAll( excludes ); @@ -121,7 +138,7 @@ public class SimpleRelocator sourcePackageExcludes.add( exclude.substring( pattern.length() ).replaceFirst( "[.][*]$", "" ) ); } // Excludes should be subpackages of the global pattern -else if ( exclude.startsWith( pathPattern ) ) +if ( exclude.startsWith( pathPattern ) ) { sourcePathExcludes.add( exclude.substring( pathPattern.length() ).replaceFirst( "[/][*]$", "" ) ); } @@ -234,11 +251,8 @@ public class SimpleRelocator { return sourceContent; } -else -{ -sourceContent = shadeSourceWithExcludes( sourceContent, pattern, shadedPattern, sourcePackageExcludes ); -return shadeSourceWithExcludes( sourceContent, pathPattern, shadedPathPattern, sourcePathExcludes ); -} +sourceContent = shadeSourceWithExcludes( sourceContent, pattern, shadedPattern, sourcePackageExcludes ); +return shadeSourceWithExcludes( sourceContent, pathPattern, shadedPathPattern, sourcePathExcludes ); } private String shadeSourceWithExcludes( String sourceContent, String patternFrom, String patternTo, @@ -248,8 +262,11 @@ public class SimpleRelocator StringBuilder shadedSourceContent = new StringBuilder( sourceContent.length() * 11 / 10 ); boolean isFirstSnippet = true; // Make sure that search pattern starts at word boundary and we look for literal ".", not regex jokers -for ( String snippet : sourceContent.split( "\\b" + patternFrom.replace( ".", "[.]" ) ) ) +String[] snippets = sourceContent.split( "\\b" + patternFrom.replace( ".", "[.]" ) + "\\b" ); +for ( int i = 0, snippetsLength = snippets.length; i < snippetsLength; i++ ) { +String snippet = snippets[i]; +String previousSnippet = isFirstSnippet ? "" : snippets[i - 1]; boolean doExclude = false; for ( String excludedPattern : excludedPa
[maven-scripting-plugin] branch MSCRIPTING-7 updated (c9e9ff9 -> 0066393)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSCRIPTING-7 in repository https://gitbox.apache.org/repos/asf/maven-scripting-plugin.git. from c9e9ff9 binding the session and servers helper in binding context add 0066393 move binding doc to the right doc file No new revisions were added by this update. Summary of changes: src/site/markdown/configure-the-script-engine.md.vm | 3 --- src/site/markdown/script-context.md | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-)
[maven-scripting-plugin] 01/01: binding the session and servers helper in binding context
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MSCRIPTING-7 in repository https://gitbox.apache.org/repos/asf/maven-scripting-plugin.git commit c9e9ff965ea1fc062cfb9893b860a5453855e33c Author: Romain Manni-Bucau AuthorDate: Fri Aug 6 10:11:02 2021 +0200 binding the session and servers helper in binding context --- .../apache/maven/plugins/scripting/EvalMojo.java | 13 ++ .../maven/plugins/scripting/binding/Servers.java | 63 .../markdown/configure-the-script-engine.md.vm | 6 +- .../plugins/scripting/binding/ServersTest.java | 170 + 4 files changed, 251 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugins/scripting/EvalMojo.java b/src/main/java/org/apache/maven/plugins/scripting/EvalMojo.java index 4a6dbbc..9356a10 100644 --- a/src/main/java/org/apache/maven/plugins/scripting/EvalMojo.java +++ b/src/main/java/org/apache/maven/plugins/scripting/EvalMojo.java @@ -25,12 +25,16 @@ import javax.script.Bindings; import javax.script.ScriptException; import javax.script.SimpleBindings; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.scripting.binding.Servers; import org.apache.maven.project.MavenProject; +import org.apache.maven.settings.crypto.SettingsDecrypter; /** * Evaluate the specified script or scriptFile @@ -60,10 +64,17 @@ public class EvalMojo @Parameter private File scriptFile; +@Component +private SettingsDecrypter settingsDecrypter; + // script variables @Parameter( defaultValue = "${project}", readonly = true ) private MavenProject project; +// script variables +@Parameter( defaultValue = "${session}", readonly = true ) +private MavenSession session; + @Override public void execute() throws MojoExecutionException, MojoFailureException @@ -73,8 +84,10 @@ public class EvalMojo AbstractScriptEvaluator execute = constructExecute(); Bindings bindings = new SimpleBindings(); + bindings.put( "session", session ); bindings.put( "project", project ); bindings.put( "log", getLog() ); + bindings.put( "servers", new Servers( session, settingsDecrypter ) ); Object result = execute.eval( bindings ); diff --git a/src/main/java/org/apache/maven/plugins/scripting/binding/Servers.java b/src/main/java/org/apache/maven/plugins/scripting/binding/Servers.java new file mode 100644 index 000..0b3f0e7 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/scripting/binding/Servers.java @@ -0,0 +1,63 @@ +package org.apache.maven.plugins.scripting.binding; + +/* + * 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.settings.Server; +import org.apache.maven.settings.building.SettingsProblem; +import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest; +import org.apache.maven.settings.crypto.SettingsDecrypter; +import org.apache.maven.settings.crypto.SettingsDecryptionResult; + +import static java.util.stream.Collectors.joining; + +/** + * Binding which enables to work with servers (from settings.xml) and in particular decipher them transparently. + */ +public class Servers +{ +private final MavenSession session; +private final SettingsDecrypter settingsDecrypter; + +public Servers( MavenSession session, SettingsDecrypter settingsDecrypter ) +{ +this.session = session; +this.settingsDecrypter = settingsDecrypter; +} + +public Server find( String id ) +{ +final Server server = session.getSettings().getServer( id ); +if ( server == null ) +{ +return null; +} +final S
[maven-scripting-plugin] branch MSCRIPTING-7 created (now c9e9ff9)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSCRIPTING-7 in repository https://gitbox.apache.org/repos/asf/maven-scripting-plugin.git. at c9e9ff9 binding the session and servers helper in binding context This branch includes the following new commits: new c9e9ff9 binding the session and servers helper in binding context The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven-surefire] branch SUREFIRE-1798 updated: fixing surefire-818-ignored-tests-on-npe IT
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch SUREFIRE-1798 in repository https://gitbox.apache.org/repos/asf/maven-surefire.git The following commit(s) were added to refs/heads/SUREFIRE-1798 by this push: new d7e81bd fixing surefire-818-ignored-tests-on-npe IT d7e81bd is described below commit d7e81bd9d2596c2c27452051d4176e3f0ff3c9fb Author: Romain Manni-Bucau AuthorDate: Mon May 17 19:59:34 2021 +0200 fixing surefire-818-ignored-tests-on-npe IT --- .../src/test/resources/surefire-818-ignored-tests-on-npe/pom.xml | 4 1 file changed, 4 insertions(+) diff --git a/surefire-its/src/test/resources/surefire-818-ignored-tests-on-npe/pom.xml b/surefire-its/src/test/resources/surefire-818-ignored-tests-on-npe/pom.xml index cef444e..abdd87d 100644 --- a/surefire-its/src/test/resources/surefire-818-ignored-tests-on-npe/pom.xml +++ b/surefire-its/src/test/resources/surefire-818-ignored-tests-on-npe/pom.xml @@ -31,6 +31,10 @@ maven-surefire-plugin ${surefire.version} + + +true +
[maven] branch MNG-7134 updated (abd2858 -> 3a65353)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MNG-7134 in repository https://gitbox.apache.org/repos/asf/maven.git. from abd2858 [MNG-7128] keep blocked attribute from mirrors in artifact repositories add 3a65353 adjusting @since No new revisions were added by this update. Summary of changes: .../java/org/apache/maven/artifact/repository/ArtifactRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
[maven] 05/05: [MNG-7128] keep blocked attribute from mirrors in artifact repositories
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MNG-7134 in repository https://gitbox.apache.org/repos/asf/maven.git commit abd28587994ac011754ca43657867bee18d04bf3 Author: Hervé Boutemy AuthorDate: Thu Mar 25 23:51:26 2021 +0100 [MNG-7128] keep blocked attribute from mirrors in artifact repositories --- .../maven/artifact/repository/ArtifactRepository.java | 6 ++ .../artifact/repository/DefaultArtifactRepository.java | 12 .../maven/repository/legacy/LegacyRepositorySystem.java| 5 + .../src/main/java/org/apache/maven/RepositoryUtils.java| 1 + .../artifact/repository/LegacyLocalRepositoryManager.java | 9 + .../maven/artifact/repository/MavenArtifactRepository.java | 14 ++ .../org/apache/maven/bridge/MavenRepositorySystem.java | 5 + 7 files changed, 52 insertions(+) diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java index 0b33345..47839ea 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java @@ -73,6 +73,12 @@ public interface ArtifactRepository @Deprecated void setBlacklisted( boolean blackListed ); +/** @since 3.8.1 **/ +boolean isBlocked(); + +/** @since 3.8.1 **/ +void setBlocked( boolean blocked ); + // // New interface methods for the repository system. // diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java index 16b82c5..ef487b8 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java @@ -54,6 +54,8 @@ public class DefaultArtifactRepository private List mirroredRepositories = Collections.emptyList(); +private boolean blocked; + /** * Create a local repository or a test repository. * @@ -264,4 +266,14 @@ public class DefaultArtifactRepository } } +public boolean isBlocked() +{ +return blocked; +} + +public void setBlocked( boolean blocked ) +{ +this.blocked = blocked; +} + } diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java index e3e7781..fd62e6c 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java @@ -446,6 +446,8 @@ public class LegacyRepositorySystem effectiveRepository.setMirroredRepositories( mirroredRepos ); +effectiveRepository.setBlocked( aliasedRepo.isBlocked() ); + effectiveRepositories.add( effectiveRepository ); } @@ -502,6 +504,7 @@ public class LegacyRepositorySystem mirror.setId( repo.getId() ); mirror.setUrl( repo.getUrl() ); mirror.setLayout( repo.getContentType() ); +mirror.setBlocked( repo.isBlocked() ); return mirror; } } @@ -538,6 +541,8 @@ public class LegacyRepositorySystem { repository.setLayout( getLayout( mirror.getLayout() ) ); } + +repository.setBlocked( mirror.isBlocked() ); } } 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 c1e21c4..80e5874 100644 --- a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java +++ b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java @@ -210,6 +210,7 @@ public class RepositoryUtils builder.setAuthentication( toAuthentication( repo.getAuthentication() ) ); builder.setProxy( toProxy( repo.getProxy() ) ); builder.setMirroredRepositories( toRepos( repo.getMirroredRepositories() ) ); +builder.setBlocked( repo.isBlocked() ); result = builder.build(); } return result; diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java index 634b63c..acd7d5f 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java +++ b/maven-core/src/main/java/org
[maven] 04/05: [MNG-7117] add support for blocked mirror
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MNG-7134 in repository https://gitbox.apache.org/repos/asf/maven.git commit 3e4565774efeb098e8cfbbd6ccb1838517474d4a Author: Hervé Boutemy AuthorDate: Sat Mar 13 18:00:59 2021 +0100 [MNG-7117] add support for blocked mirror --- .../aether/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 248a3b6..bda467c 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 @@ public class DefaultRepositorySystemSessionFactory 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 86a017c..ac21538 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 333d8bd..b0498df 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(); }
[maven] 01/05: [MNG-7119] Upgrade Maven Wagon to 3.4.3
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MNG-7134 in repository https://gitbox.apache.org/repos/asf/maven.git commit fa46195ab497263a7a12663274057b22b68d8281 Author: Michael Osipov AuthorDate: Tue Mar 16 18:22:04 2021 +0100 [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 a1a1ab8..15b3021 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
[maven] 02/05: use Maven Resolver 1.6.2
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MNG-7134 in repository https://gitbox.apache.org/repos/asf/maven.git commit 0bb649314f3d3ab58800c9a20d2ea2a43d50d5ae Author: Hervé Boutemy AuthorDate: Sun Mar 14 20:52:42 2021 +0100 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 15b3021..18d0ac9 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
[maven] branch MNG-7134 created (now abd2858)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MNG-7134 in repository https://gitbox.apache.org/repos/asf/maven.git. at abd2858 [MNG-7128] keep blocked attribute from mirrors in artifact repositories This branch includes the following new commits: new fa46195 [MNG-7119] Upgrade Maven Wagon to 3.4.3 new 0bb6493 use Maven Resolver 1.6.2 new ec02e31 [MNG-7116] add support for mirrorOf external:http:* new 3e45657 [MNG-7117] add support for blocked mirror new abd2858 [MNG-7128] keep blocked attribute from mirrors in artifact repositories The 5 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven] 03/05: [MNG-7116] add support for mirrorOf external:http:*
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MNG-7134 in repository https://gitbox.apache.org/repos/asf/maven.git commit ec02e31f5d457fcdb94731579fcd9554edd2 Author: Hervé Boutemy AuthorDate: Sat Mar 13 18:40:48 2021 +0100 [MNG-7116] add support for mirrorOf external:http:* --- .../maven/repository/DefaultMirrorSelector.java| 51 +++--- .../apache/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 6fa2c55..adb562a 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 class DefaultMirrorSelector } /** - * 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 @@ public class DefaultMirrorSelector 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 @@ public class DefaultMirrorSelector 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 @@ public class DefaultMirrorSelector } } -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 730b42
[maven-surefire] branch SUREFIRE-1892 updated (e3a1a7b -> 69aa817)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch SUREFIRE-1892 in repository https://gitbox.apache.org/repos/asf/maven-surefire.git. from e3a1a7b [SUREFIRE-1892] ensure systemPropertyVariables values are stringified add 69aa817 style + handle null in systemPropertyVariables values No new revisions were added by this update. Summary of changes: .../java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java | 5 +++-- .../org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-)
[maven-surefire] branch SUREFIRE-1892 created (now e3a1a7b)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch SUREFIRE-1892 in repository https://gitbox.apache.org/repos/asf/maven-surefire.git. at e3a1a7b [SUREFIRE-1892] ensure systemPropertyVariables values are stringified This branch includes the following new commits: new e3a1a7b [SUREFIRE-1892] ensure systemPropertyVariables values are stringified The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven-surefire] 01/01: [SUREFIRE-1892] ensure systemPropertyVariables values are stringified
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch SUREFIRE-1892 in repository https://gitbox.apache.org/repos/asf/maven-surefire.git commit e3a1a7bb642c1e69b6bd34c2a95820221da368c8 Author: Romain Manni-Bucau AuthorDate: Sun Mar 7 17:10:33 2021 +0100 [SUREFIRE-1892] ensure systemPropertyVariables values are stringified --- .../maven/plugin/surefire/AbstractSurefireMojo.java | 15 +-- .../maven/plugin/surefire/AbstractSurefireMojoTest.java | 10 ++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java index 4d1af3d..ec6ff73 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java @@ -3623,9 +3623,20 @@ public abstract class AbstractSurefireMojo } @SuppressWarnings( "UnusedDeclaration" ) -public void setSystemPropertyVariables( Map systemPropertyVariables ) +public void setSystemPropertyVariables( Map systemPropertyVariables ) { -this.systemPropertyVariables = systemPropertyVariables; +if (systemPropertyVariables != null) +{ +this.systemPropertyVariables = new HashMap<>(); +for ( final Map.Entry entry : systemPropertyVariables.entrySet() ) +{ +this.systemPropertyVariables.put( entry.getKey(), String.valueOf( entry.getValue() ) ); +} +} +else +{ +this.systemPropertyVariables = null; +} } /** diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java index 53e7fba..12a7b1b 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java @@ -94,6 +94,7 @@ import static java.util.Collections.emptyMap; import static java.util.Collections.emptySet; import static java.util.Collections.singleton; import static java.util.Collections.singletonList; +import static java.util.Collections.singletonMap; import static org.apache.maven.artifact.versioning.VersionRange.createFromVersion; import static org.apache.maven.artifact.versioning.VersionRange.createFromVersionSpec; import static org.apache.maven.surefire.shared.lang3.JavaVersion.JAVA_9; @@ -102,6 +103,7 @@ import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS; import static org.codehaus.plexus.languages.java.jpms.ModuleNameSource.MODULEDESCRIPTOR; import static org.fest.assertions.Assertions.assertThat; import static org.fest.assertions.MapAssert.entry; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; @@ -1999,6 +2001,14 @@ public class AbstractSurefireMojoTest mojo.verifyParameters(); } +@Test +public void shouldSupportBooleanSystemPropertiesValue() +{ +AbstractSurefireMojo mojo = new Mojo(); +mojo.setSystemPropertyVariables(singletonMap("offline", true)); +assertEquals(singletonMap("offline", "true"), mojo.getSystemPropertyVariables()); +} + private void setProjectDepedenciesToMojo( Artifact... deps ) { for ( Artifact dep : deps )
[maven-scripting-plugin] 01/01: basic java scripting engine support
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch rmannibucau/java-scripting-draft in repository https://gitbox.apache.org/repos/asf/maven-scripting-plugin.git commit 0346ed96d069c6a4edcd6bf980fea7409169e84d Author: Romain Manni-Bucau AuthorDate: Fri Feb 26 09:41:24 2021 +0100 basic java scripting engine support --- pom.xml| 38 ++ src/it/java/pom.xml| 68 src/it/java/verify.bsh | 44 +++ .../plugins/scripting/AbstractScriptEvaluator.java | 22 +- .../apache/maven/plugins/scripting/EvalMojo.java | 70 +++- .../plugins/scripting/FileScriptEvaluator.java | 5 +- .../plugins/scripting/StringScriptEvaluator.java | 4 +- .../plugins/scripting/engine/JavaScriptEngine.java | 422 + .../scripting/engine/JavaScriptEngineFactory.java | 133 +++ .../scripting/engine/JavaScriptEngineTest.java | 99 + 10 files changed, 897 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 13fb174..5b20d0d 100644 --- a/pom.xml +++ b/pom.xml @@ -69,6 +69,7 @@ under the License. 3.0 1.8 1.8 +2.8.8 2021-02-24T19:52:25Z @@ -96,6 +97,42 @@ under the License. provided + + + org.codehaus.plexus + plexus-compiler-api + ${plexus.compiler.version} + + + org.codehaus.plexus + plexus-component-api + + + + + org.codehaus.plexus + plexus-compiler-manager + ${plexus.compiler.version} + + + org.codehaus.plexus + plexus-component-api + + + + + org.codehaus.plexus + plexus-compiler-javac + ${plexus.compiler.version} + runtime + + + org.codehaus.plexus + plexus-component-api + + + + junit @@ -133,6 +170,7 @@ under the License. verify ${project.build.directory}/local-repo src/it/settings.xml +verify.bsh scripting:eval diff --git a/src/it/java/pom.xml b/src/it/java/pom.xml new file mode 100644 index 000..0db926d --- /dev/null +++ b/src/it/java/pom.xml @@ -0,0 +1,68 @@ + + + + +http://maven.apache.org/POM/4.0.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd;> + 4.0.0 + + org.apache.maven.plugins.scripting.its + java + 1.0.0-SNAPSHOT + pom + + + + +org.apache.maven.plugins +maven-scripting-plugin +@project.version@ + + java + +MyMain +1 +2 +3 +4 +5 +6 + + + <![CDATA[ +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; + +public class MyMain { + public static void main(String... args) throws Exception { +Path out = Paths.get("target/out"); +Files.createDirectories(out.getParent()); +Files.write(out, String.join(",", args).getBytes(), + StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); + } +} + ]]> + + + + + + diff --git a/src/it/java/verify.bsh b/src/it/java/verify.bsh new file mode 100644 index 000..a0f3f98 --- /dev/null +++ b/src/it/java/verify.bsh @@ -0,0 +1,44 @@ +/* + * 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. + */ + +// beanshell does not like much java.nio.file so let's use java.io which is more than enough for us +import java.util.stream.Collectors; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.File; + +File file = new File( basedir, "target/out" ); +
[maven-scripting-plugin] branch rmannibucau/java-scripting-draft created (now 0346ed9)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch rmannibucau/java-scripting-draft in repository https://gitbox.apache.org/repos/asf/maven-scripting-plugin.git. at 0346ed9 basic java scripting engine support This branch includes the following new commits: new 0346ed9 basic java scripting engine support The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven] branch MNG-7045 created (now 9d64fe6)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MNG-7045 in repository https://gitbox.apache.org/repos/asf/maven.git. at 9d64fe6 drop useless and outdated cdi-api from maven This branch includes the following new commits: new 9d64fe6 drop useless and outdated cdi-api from maven The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven] 01/01: drop useless and outdated cdi-api from maven
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MNG-7045 in repository https://gitbox.apache.org/repos/asf/maven.git commit 9d64fe633c9991058e5f3b69820eb2654ad7c1e0 Author: Romain Manni-Bucau AuthorDate: Thu Dec 3 20:07:03 2020 +0100 drop useless and outdated cdi-api from maven --- 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 0eceb2b..4abc7d9 100644 --- a/maven-core/src/main/resources/META-INF/maven/extension.xml +++ b/maven-core/src/main/resources/META-INF/maven/extension.xml @@ -96,9 +96,11 @@ under the License. javax.inject.* - + javax.annotation.* diff --git a/pom.xml b/pom.xml index d8e39bf..c3d3392 100644 --- a/pom.xml +++ b/pom.xml @@ -273,6 +273,12 @@ under the License. org.eclipse.sisu org.eclipse.sisu.plexus ${sisuInjectVersion} + + +javax.enterprise +cdi-api + + org.eclipse.sisu
[maven-jar-plugin] branch MJAR-276 deleted (was 4027e40)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MJAR-276 in repository https://gitbox.apache.org/repos/asf/maven-jar-plugin.git. was 4027e40 [MJAR-276] don't log useless warning when jar creation is forced and directory does not exist The revisions that were on this branch are still contained in other references; therefore, this change does not discard any commits from the repository.
[maven-jar-plugin] branch master updated (4bf3895 -> 4027e40)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/maven-jar-plugin.git. from 4bf3895 Update plexus archiver (to solve JDK-8177809) add 4027e40 [MJAR-276] don't log useless warning when jar creation is forced and directory does not exist No new revisions were added by this update. Summary of changes: src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java | 5 - 1 file changed, 4 insertions(+), 1 deletion(-)
[maven-jar-plugin] branch rmannibucau/MJAR-276_avoid-useless-warning-when-jar-creation-is-forced-even-empty deleted (was 4027e40)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch rmannibucau/MJAR-276_avoid-useless-warning-when-jar-creation-is-forced-even-empty in repository https://gitbox.apache.org/repos/asf/maven-jar-plugin.git. was 4027e40 [MJAR-276] don't log useless warning when jar creation is forced and directory does not exist The revisions that were on this branch are still contained in other references; therefore, this change does not discard any commits from the repository.
[maven-jar-plugin] branch MJAR-276 created (now 4027e40)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MJAR-276 in repository https://gitbox.apache.org/repos/asf/maven-jar-plugin.git. at 4027e40 [MJAR-276] don't log useless warning when jar creation is forced and directory does not exist No new revisions were added by this update.
[maven-jar-plugin] branch rmannibucau/MJAR-276_avoid-useless-warning-when-jar-creation-is-forced-even-empty created (now 4027e40)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch rmannibucau/MJAR-276_avoid-useless-warning-when-jar-creation-is-forced-even-empty in repository https://gitbox.apache.org/repos/asf/maven-jar-plugin.git. at 4027e40 [MJAR-276] don't log useless warning when jar creation is forced and directory does not exist This branch includes the following new commits: new 4027e40 [MJAR-276] don't log useless warning when jar creation is forced and directory does not exist The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven-jar-plugin] 01/01: [MJAR-276] don't log useless warning when jar creation is forced and directory does not exist
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch rmannibucau/MJAR-276_avoid-useless-warning-when-jar-creation-is-forced-even-empty in repository https://gitbox.apache.org/repos/asf/maven-jar-plugin.git commit 4027e40376031d8be01abddeb21de16e98ea0c58 Author: Romain Manni-Bucau AuthorDate: Wed Dec 2 09:48:50 2020 +0100 [MJAR-276] don't log useless warning when jar creation is forced and directory does not exist --- src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java b/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java index 68da0ec..d7b298f 100644 --- a/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java @@ -266,7 +266,10 @@ public abstract class AbstractJarMojo File contentDirectory = getClassesDirectory(); if ( !contentDirectory.exists() ) { -getLog().warn( "JAR will be empty - no content was marked for inclusion!" ); +if ( !forceCreation ) +{ +getLog().warn( "JAR will be empty - no content was marked for inclusion!" ); +} } else {
[maven-shade-plugin] branch master updated: [MSHADE-378] Shade plugin changes the compression level of nested jar… (#73)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git The following commit(s) were added to refs/heads/master by this push: new c798d01 [MSHADE-378] Shade plugin changes the compression level of nested jar… (#73) c798d01 is described below commit c798d01138e9fecdd6422a2a8acce22ca8987924 Author: jenrryyou AuthorDate: Sun Nov 22 23:17:56 2020 +0800 [MSHADE-378] Shade plugin changes the compression level of nested jar… (#73) * [MSHADE-378] Shade plugin changes the compression level of nested jar entries * [MSHADE-378] Shade plugin changes the compression level of nested jar entries Co-authored-by: shaoyao --- .../apache/maven/plugins/shade/DefaultShader.java | 107 +++-- .../maven/plugins/shade/DefaultShaderTest.java | 67 + 2 files changed, 165 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java b/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java index 6f3c4e6..540eccd 100644 --- a/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java +++ b/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java @@ -21,14 +21,17 @@ package org.apache.maven.plugins.shade; import java.io.BufferedOutputStream; import java.io.File; +import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; +import java.io.PushbackInputStream; import java.io.Writer; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Enumeration; @@ -42,6 +45,8 @@ import java.util.jar.JarFile; import java.util.jar.JarOutputStream; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.zip.CRC32; +import java.util.zip.ZipEntry; import java.util.zip.ZipException; import org.apache.commons.lang3.StringUtils; @@ -71,6 +76,7 @@ public class DefaultShader extends AbstractLogEnabled implements Shader { +private static final int BUFFER_SIZE = 32 * 1024; public void shade( ShadeRequest shadeRequest ) throws IOException, MojoExecutionException @@ -150,6 +156,73 @@ public class DefaultShader } } +/** + * {@link InputStream} that can peek ahead at zip header bytes. + */ +private static class ZipHeaderPeekInputStream extends PushbackInputStream +{ + +private static final byte[] ZIP_HEADER = new byte[] {0x50, 0x4b, 0x03, 0x04}; + +private static final int HEADER_LEN = 4; + +protected ZipHeaderPeekInputStream( InputStream in ) +{ +super( in, HEADER_LEN ); +} + +public boolean hasZipHeader() throws IOException +{ +final byte[] header = new byte[HEADER_LEN]; +super.read( header, 0, HEADER_LEN ); +super.unread( header ); +return Arrays.equals( header, ZIP_HEADER ); +} +} + +/** + * Data holder for CRC and Size. + */ +private static class CrcAndSize +{ + +private final CRC32 crc = new CRC32(); + +private long size; + +CrcAndSize( File file ) throws IOException +{ +try ( FileInputStream inputStream = new FileInputStream( file ) ) +{ +load( inputStream ); +} +} + +CrcAndSize( InputStream inputStream ) throws IOException +{ +load( inputStream ); +} + +private void load( InputStream inputStream ) throws IOException +{ +byte[] buffer = new byte[BUFFER_SIZE]; +int bytesRead; +while ( ( bytesRead = inputStream.read( buffer ) ) != -1 ) +{ +this.crc.update( buffer, 0, bytesRead ); +this.size += bytesRead; +} +} + +public void setupStoredEntry( JarEntry entry ) +{ +entry.setSize( this.size ); +entry.setCompressedSize( this.size ); +entry.setCrc( this.crc.getValue() ); +entry.setMethod( ZipEntry.STORED ); +} +} + private void shadeJars( ShadeRequest shadeRequest, Set resources, List transformers, RelocatorRemapper remapper, JarOutputStream jos, Multimap duplicates ) throws IOException, MojoExecutionException @@ -255,7 +328,7 @@ public class DefaultShader return; } -addResource( resources, jos, mappedName, entry.getTime(), in ); +addResource( resources, jos, mappedName, entry, jarFile ); } else
[maven-surefire] branch rmannibucau/flush-output-toggle updated (4adabcb -> 1d5e99d)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch rmannibucau/flush-output-toggle in repository https://gitbox.apache.org/repos/asf/maven-surefire.git. from 4adabcb review comments add 1d5e99d adding a system property for outputFlushInterval to be able to set in in settings.xml and not pom No new revisions were added by this update. Summary of changes: .../java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[maven-surefire] branch rmannibucau/flush-output-toggle updated (7be86d1 -> 4adabcb)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch rmannibucau/flush-output-toggle in repository https://gitbox.apache.org/repos/asf/maven-surefire.git. from 7be86d1 enable to flush regularly output of the forked process add 4adabcb review comments No new revisions were added by this update. Summary of changes: .../src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
[maven-surefire] 01/01: enable to flush regularly output of the forked process
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch rmannibucau/flush-output-toggle in repository https://gitbox.apache.org/repos/asf/maven-surefire.git commit 7be86d1ee9c7992dc7a48a218ac4318c320c2b1b Author: Romain Manni-Bucau AuthorDate: Wed Jul 8 13:02:23 2020 +0200 enable to flush regularly output of the forked process --- .../plugin/surefire/AbstractSurefireMojo.java | 15 +++- .../surefire/booterclient/BooterSerializer.java| 5 +++ ...ooterDeserializerProviderConfigurationTest.java | 2 +- ...BooterDeserializerStartupConfigurationTest.java | 2 +- .../AbstractNoninterruptibleWritableChannel.java | 6 +++ .../util/internal/WritableBufferedByteChannel.java | 2 + .../maven/surefire/booter/BooterConstants.java | 1 + .../maven/surefire/booter/BooterDeserializer.java | 4 +- .../apache/maven/surefire/booter/ForkedBooter.java | 45 ++ .../surefire/booter/ProviderConfiguration.java | 10 - .../spi/LegacyMasterProcessChannelEncoder.java | 5 +++ 11 files changed, 92 insertions(+), 5 deletions(-) diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java index 38d34fb..0f92bbf 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java @@ -809,6 +809,18 @@ public abstract class AbstractSurefireMojo private Map jdkToolchain; /** + * How often output is forced to be flushed. + * Useful when there is no output for N ms but some data are buffered. + * It will trigger a flush each configured interval to ensure + * data don't stay blocked in a buffer. + * Setting it to 0 disable that feature. + * + * @since 3.0.0-M6 + */ +@Parameter( defaultValue = "0" ) +private long outputFlushInterval; + +/** * */ @Component @@ -1850,7 +1862,8 @@ public abstract class AbstractSurefireMojo testSuiteDefinition, providerProperties, null, false, cli, getSkipAfterFailureCount(), Shutdown.parameterOf( getShutdown() ), - getForkedProcessExitTimeoutInSeconds() ); + getForkedProcessExitTimeoutInSeconds(), + outputFlushInterval ); } private static Map toStringProperties( Properties properties ) diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java index c8aee3c..6e62079 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java @@ -53,6 +53,7 @@ import static org.apache.maven.surefire.booter.BooterConstants.FORKTESTSET_PREFE import static org.apache.maven.surefire.booter.BooterConstants.INCLUDES_PROPERTY_PREFIX; import static org.apache.maven.surefire.booter.BooterConstants.ISTRIMSTACKTRACE; import static org.apache.maven.surefire.booter.BooterConstants.MAIN_CLI_OPTIONS; +import static org.apache.maven.surefire.booter.BooterConstants.OUTPUT_FLUSH_INTERVAL_MS; import static org.apache.maven.surefire.booter.BooterConstants.PLUGIN_PID; import static org.apache.maven.surefire.booter.BooterConstants.PROCESS_CHECKER; import static org.apache.maven.surefire.booter.BooterConstants.PROVIDER_CONFIGURATION; @@ -181,6 +182,10 @@ class BooterSerializer properties.addList( mainCliOptions, MAIN_CLI_OPTIONS ); } properties.setNullableProperty( SYSTEM_EXIT_TIMEOUT, toString( providerConfiguration.getSystemExitTimeout() ) ); +properties.setNullableProperty( +OUTPUT_FLUSH_INTERVAL_MS, +providerConfiguration.getOutputFlushInterval() == null +? "0" : toString( providerConfiguration.getOutputFlushInterval() ) ); File surefireTmpDir = forkConfiguration.getTempDirectory(); boolean debug = forkConfiguration.isDebug(); diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java index 7a08390..e62d1c3 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderCo
[maven-surefire] branch rmannibucau/flush-output-toggle created (now 7be86d1)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch rmannibucau/flush-output-toggle in repository https://gitbox.apache.org/repos/asf/maven-surefire.git. at 7be86d1 enable to flush regularly output of the forked process This branch includes the following new commits: new 7be86d1 enable to flush regularly output of the forked process The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven-shade-plugin] branch master updated: [MSHADE-373] allow to configure the manifest per shaded artifact. (#59)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git The following commit(s) were added to refs/heads/master by this push: new 72cf77e [MSHADE-373] allow to configure the manifest per shaded artifact. (#59) 72cf77e is described below commit 72cf77e445b502b606b36724e1c4794a7587c05c Author: Rafael Winterhalter AuthorDate: Sat Jul 4 12:11:44 2020 +0200 [MSHADE-373] allow to configure the manifest per shaded artifact. (#59) * MSHADE-373: allow to specify optional target for resource transformers. * enrich MSHADE-373 it test with multiple artifact deliveries and null/manifest-removal test + handle the case multiple manifest transformers are used for the same build Co-authored-by: Romain Manni-Bucau --- README.md | 16 +++ pom.xml| 1 + src/it/projects/MSHADE-183/verify.bsh | 4 +- src/it/projects/MSHADE-373/pom.xml | 117 + src/it/projects/MSHADE-373/verify.bsh | 62 +++ .../apache/maven/plugins/shade/mojo/ShadeMojo.java | 60 +-- .../resource/ManifestResourceTransformer.java | 31 +- .../maven/plugins/shade/mojo/ShadeMojoTest.java| 51 - 8 files changed, 328 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 6655702..c10dec7 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,22 @@ For changes of a trivial nature to comments and documentation, it is not always necessary to create a new ticket in JIRA. In this case, it is appropriate to start the first line of a commit with '(doc)' instead of a ticket number. +Developer Tips +-- + +If you machine is big enough and you want to parallelise the IT execution to validate the build +before a PR you can set the concurrency in MAVEN_OPTS: + + +MAVEN_OPTS=-Dinvoker.parallelThreads=2 mvn verify -Prun-its + + +You can also run a single IT test using: + + +mvn verify -Prun-its -Dinvoker.test=myitproject + + Additional Resources diff --git a/pom.xml b/pom.xml index 25ec427..b56c028 100644 --- a/pom.xml +++ b/pom.xml @@ -286,6 +286,7 @@ package + true src/it/projects src/it/mrm/settings.xml diff --git a/src/it/projects/MSHADE-183/verify.bsh b/src/it/projects/MSHADE-183/verify.bsh index 8511b12..52e8ab8 100644 --- a/src/it/projects/MSHADE-183/verify.bsh +++ b/src/it/projects/MSHADE-183/verify.bsh @@ -43,7 +43,7 @@ if ( !"org.apache.maven.Shade".equals( mf.getMainAttributes().getValue( "Main-Cl { throw new IllegalStateException( "META-INF/MANIFEST.MF is incomplete" ); } -if ( !"null".equals( mf.getMainAttributes().getValue( "Implementation-Build" ) ) ) +if ( null != mf.getMainAttributes().getValue( "Implementation-Build" ) ) { -throw new IllegalStateException( "META-INF/MANIFEST.MF Implementation-Build content is not null as expected." ); +throw new IllegalStateException( "META-INF/MANIFEST.MF Implementation-Build content is not null as expected. (" + mf.getMainAttributes().entrySet() + ")" ); } diff --git a/src/it/projects/MSHADE-373/pom.xml b/src/it/projects/MSHADE-373/pom.xml new file mode 100644 index 000..19a1e17 --- /dev/null +++ b/src/it/projects/MSHADE-373/pom.xml @@ -0,0 +1,117 @@ + + + + +http://maven.apache.org/POM/4.0.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd;> + 4.0.0 + + org.apache.maven.its.shade.mt + test + 1.0 + jar + + MSHADE-373 + +Test that reproduces the issue described in MSHADE-373. + + + + + + org.apache.maven.plugins + maven-shade-plugin + @project.version@ + + + + + + +org.apache.maven.plugins +maven-compiler-plugin +2.0.2 + + +org.apache.maven.plugins +maven-install-plugin +2.2 + + +org.apache.maven.plugins +maven-jar-plugin +2.2 + + + + org.apache.maven.Main + + + PASSED + PASSED + + + + + +org.apache.maven.plugins +maven-resources-plugin +2.2 + + +org.apache.maven.plugins +maven-shade-plugin +@project.version@ + + +attach-shade +package + + shade + + + true + true +
[maven-surefire] 01/01: [SUREFIRE-1798] trimStackTrace=false by default
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch SUREFIRE-1798 in repository https://gitbox.apache.org/repos/asf/maven-surefire.git commit 19d0ac14a7573f29f598a53b834bd8d85ad2839a Author: Romain Manni-Bucau AuthorDate: Tue Jun 9 08:28:31 2020 +0200 [SUREFIRE-1798] trimStackTrace=false by default --- .../java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java index 38d34fb..c5c5e2f 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java @@ -678,7 +678,7 @@ public abstract class AbstractSurefireMojo * * @since 2.2 */ -@Parameter( property = "trimStackTrace", defaultValue = "true" ) +@Parameter( property = "trimStackTrace", defaultValue = "false" ) private boolean trimStackTrace; /**
[maven-surefire] branch SUREFIRE-1798 created (now 19d0ac1)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch SUREFIRE-1798 in repository https://gitbox.apache.org/repos/asf/maven-surefire.git. at 19d0ac1 [SUREFIRE-1798] trimStackTrace=false by default This branch includes the following new commits: new 19d0ac1 [SUREFIRE-1798] trimStackTrace=false by default The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven-surefire] branch SUREFIRE-1733 updated (2ddc3ff -> e924e26)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch SUREFIRE-1733 in repository https://gitbox.apache.org/repos/asf/maven-surefire.git. from 2ddc3ff inverstigation commit add e924e26 forkedbooter must use app loader + ensure modular classpath split modules in module path and keep classpath for unamed jars No new revisions were added by this update. Summary of changes: .../ModularClasspathForkConfiguration.java | 36 ++ pom.xml| 4 +-- .../apache/maven/surefire/booter/ForkedBooter.java | 2 +- .../surefire/its/MultiModuleProjectWithJPMSIT.java | 1 + 4 files changed, 28 insertions(+), 15 deletions(-)
[maven-shade-plugin] branch master updated (830d71a -> 3691f60)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. from 830d71a [MSHADE-365] put Properties transformers in separate table add 34736cc [MSHADE-364] drop duplicate resource warning when the resource is handled by a transformer new 3691f60 Merge pull request #48 from apache/MSHADE-364 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../apache/maven/plugins/shade/DefaultShader.java | 22 ++- .../maven/plugins/shade/DefaultShaderTest.java | 161 +++-- 2 files changed, 134 insertions(+), 49 deletions(-)
[maven-shade-plugin] 01/01: Merge pull request #48 from apache/MSHADE-364
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git commit 3691f6025e9c1a7b75a7e064f144a76ca009d8b0 Merge: 830d71a 34736cc Author: Romain Manni-Bucau AuthorDate: Thu May 14 09:03:59 2020 +0200 Merge pull request #48 from apache/MSHADE-364 [MSHADE-364] drop duplicates handled by a transformer .../apache/maven/plugins/shade/DefaultShader.java | 22 ++- .../maven/plugins/shade/DefaultShaderTest.java | 161 +++-- 2 files changed, 134 insertions(+), 49 deletions(-)
[maven-shade-plugin] branch MSHADE-364 updated (d79c689 -> 34736cc)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-364 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. discard d79c689 drop duplicate resource warning when the resource is handled by a transformer add 34736cc [MSHADE-364] drop duplicate resource warning when the resource is handled by a transformer This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (d79c689) \ N -- N -- N refs/heads/MSHADE-364 (34736cc) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes:
[maven-shade-plugin] branch MSHADE-364 updated (e2ddd07 -> d79c689)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-364 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. discard e2ddd07 dropping some finals, fixing some english wordings (plural/singular) discard 34f0272 [MSHADE-364] drop duplicate resource warning when the resource is handled by a transformer add d79c689 drop duplicate resource warning when the resource is handled by a transformer This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (e2ddd07) \ N -- N -- N refs/heads/MSHADE-364 (d79c689) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: src/main/java/org/apache/maven/plugins/shade/DefaultShader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[maven-shade-plugin] branch MSHADE-364 updated (6a8986d -> 035ed39)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-364 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. from 6a8986d drop duplicate resource warning when the resource is handled by a transformer add 035ed39 dropping some finals, fixing some english wordings (plural/singular) No new revisions were added by this update. Summary of changes: .../apache/maven/plugins/shade/DefaultShader.java | 18 -- .../maven/plugins/shade/DefaultShaderTest.java | 42 +++--- 2 files changed, 37 insertions(+), 23 deletions(-)
[maven-shade-plugin] branch MSHADE-364 updated (09d6560 -> 6a8986d)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-364 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. discard 09d6560 drop duplicates handled by a transformer add 6a8986d drop duplicate resource warning when the resource is handled by a transformer This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (09d6560) \ N -- N -- N refs/heads/MSHADE-364 (6a8986d) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: .../maven/plugins/shade/DefaultShaderTest.java | 159 +++-- 1 file changed, 113 insertions(+), 46 deletions(-)
[maven-shade-plugin] 01/01: drop duplicates handled by a transformer
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MSHADE-364 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git commit 09d6560632a14f9272b08ebb13b6eeea24f02cf3 Author: Romain Manni-Bucau AuthorDate: Tue May 12 13:55:10 2020 +0200 drop duplicates handled by a transformer --- src/main/java/org/apache/maven/plugins/shade/DefaultShader.java | 4 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java b/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java index f5897c3..ffd902d 100644 --- a/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java +++ b/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java @@ -256,6 +256,10 @@ public class DefaultShader addResource( resources, jos, mappedName, entry.getTime(), in ); } +else +{ +duplicates.remove( name, jar ); +} } } }
[maven-shade-plugin] branch MSHADE-364 created (now 09d6560)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-364 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. at 09d6560 drop duplicates handled by a transformer This branch includes the following new commits: new 09d6560 drop duplicates handled by a transformer The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven-surefire] branch SUREFIRE-1781 created (now a71e86a)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch SUREFIRE-1781 in repository https://gitbox.apache.org/repos/asf/maven-surefire.git. at a71e86a logging a warning if forkcount=0 This branch includes the following new commits: new a71e86a logging a warning if forkcount=0 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven-surefire] 01/01: logging a warning if forkcount=0
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch SUREFIRE-1781 in repository https://gitbox.apache.org/repos/asf/maven-surefire.git commit a71e86a8f49116140b24aa40eeacf2a828620b2d Author: Romain Manni-Bucau AuthorDate: Sat Apr 25 17:31:27 2020 +0200 logging a warning if forkcount=0 --- .../org/apache/maven/plugin/surefire/AbstractSurefireMojo.java | 10 ++ 1 file changed, 10 insertions(+) diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java index 112de82..8a0cd0a 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java @@ -1121,10 +1121,20 @@ public abstract class AbstractSurefireMojo warnIfWrongShutdownValue(); warnIfNotApplicableSkipAfterFailureCount(); warnIfIllegalTempDir(); +warnIfForkCountIsZero(); } return true; } +private void warnIfForkCountIsZero() +{ +if ( "0".equals( getForkCount() ) ) +{ +getConsoleLogger().warning( "The parameter forkCount should likely not be 0, not forking a JVM for tests " ++ "reduce test accuracy, ensure to have a >= 1." ); +} +} + private void executeAfterPreconditionsChecked( @Nonnull DefaultScanResult scanResult ) throws MojoExecutionException, MojoFailureException {
[maven-shade-plugin] 01/01: MSHADE-353 adding a generic relocation friendly transformer delegating to other transformers the actual processing
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch rmannibucau/MSHADE-353-ensure-relocations-can-be-applied-to-any-transformer in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git commit 1840449b2cb73de77843fa5277ffec6f4d686b2f Author: Romain Manni-Bucau AuthorDate: Thu Mar 5 14:21:19 2020 +0100 MSHADE-353 adding a generic relocation friendly transformer delegating to other transformers the actual processing --- .../shade/resource/BaseRelocatingTransformer.java | 46 + .../resource/ManifestResourceTransformer.java | 18 +--- .../shade/resource/RelocationTransformer.java | 106 + src/site/apt/examples/resource-transformers.apt.vm | 43 - .../shade/resource/RelocationTransformerTest.java | 75 +++ 5 files changed, 270 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/BaseRelocatingTransformer.java b/src/main/java/org/apache/maven/plugins/shade/resource/BaseRelocatingTransformer.java new file mode 100644 index 000..4e57aee --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/shade/resource/BaseRelocatingTransformer.java @@ -0,0 +1,46 @@ +package org.apache.maven.plugins.shade.resource; + +/* + * 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.List; + +import org.apache.maven.plugins.shade.relocation.Relocator; + +/** + * Abstract class providing the needed logic to relocate any content. + */ +public abstract class BaseRelocatingTransformer implements ResourceTransformer +{ +protected String relocate( String originalValue, List relocators ) +{ +String newValue = originalValue; +for ( Relocator relocator : relocators ) +{ +String value; +do +{ +value = newValue; +newValue = relocator.relocateClass( value ); +} +while ( !value.equals( newValue ) ); +} +return newValue; +} +} diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformer.java b/src/main/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformer.java index 688078c..82b98e7 100644 --- a/src/main/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformer.java +++ b/src/main/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformer.java @@ -41,7 +41,7 @@ import org.apache.maven.plugins.shade.relocation.Relocator; * @since 1.2 */ public class ManifestResourceTransformer -implements ResourceTransformer +extends BaseRelocatingTransformer { private final List defaultAttributes = Arrays.asList( "Export-Package", "Import-Package", @@ -163,20 +163,4 @@ public class ManifestResourceTransformer jos.putNextEntry( new JarEntry( JarFile.MANIFEST_NAME ) ); manifest.write( jos ); } - -private String relocate( String originalValue, List relocators ) -{ -String newValue = originalValue; -for ( Relocator relocator : relocators ) -{ -String value; -do -{ -value = newValue; -newValue = relocator.relocateClass( value ); -} -while ( !value.equals( newValue ) ); -} -return newValue; -} } diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/RelocationTransformer.java b/src/main/java/org/apache/maven/plugins/shade/resource/RelocationTransformer.java new file mode 100644 index 000..40acb9d --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/shade/resource/RelocationTransformer.java @@ -0,0 +1,106 @@ +package org.apache.maven.plugins.shade.resource; + +/* + * 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
[maven-shade-plugin] branch rmannibucau/MSHADE-353-ensure-relocations-can-be-applied-to-any-transformer created (now 1840449)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch rmannibucau/MSHADE-353-ensure-relocations-can-be-applied-to-any-transformer in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. at 1840449 MSHADE-353 adding a generic relocation friendly transformer delegating to other transformers the actual processing This branch includes the following new commits: new 1840449 MSHADE-353 adding a generic relocation friendly transformer delegating to other transformers the actual processing The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven-shade-plugin] branch MSHADE-350_enable-to-rewrite-manifest-with-relocations updated (36249e0 -> 26f444c)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-350_enable-to-rewrite-manifest-with-relocations in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. from 36249e0 moving skipRelocators in configuration block instead of Fields one add 26f444c moving relocator configuration of ManifestResourceTransformer to {useDefaultLocators, relocators} to ensure it matches all cases without any blocker for end users No new revisions were added by this update. Summary of changes: .../resource/ManifestResourceTransformer.java | 14 +++--- src/site/apt/examples/resource-transformers.apt.vm | 50 ++ .../resource/ManifestResourceTransformerTest.java | 6 +-- 3 files changed, 61 insertions(+), 9 deletions(-)
[maven-shade-plugin] branch MSHADE-350_enable-to-rewrite-manifest-with-relocations updated (ff4dd31 -> 36249e0)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-350_enable-to-rewrite-manifest-with-relocations in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. from ff4dd31 MSHADE-350 enable to rewrite the manifest add 36249e0 moving skipRelocators in configuration block instead of Fields one No new revisions were added by this update. Summary of changes: .../maven/plugins/shade/resource/ManifestResourceTransformer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
[maven-shade-plugin] branch MSHADE-350_enable-to-rewrite-manifest-with-relocations created (now ff4dd31)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-350_enable-to-rewrite-manifest-with-relocations in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. at ff4dd31 MSHADE-350 enable to rewrite the manifest This branch includes the following new commits: new ff4dd31 MSHADE-350 enable to rewrite the manifest The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven-shade-plugin] 01/01: MSHADE-350 enable to rewrite the manifest
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MSHADE-350_enable-to-rewrite-manifest-with-relocations in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git commit ff4dd317d5f0de24f7657e36168ad1450f78dcfc Author: Romain Manni-Bucau AuthorDate: Thu Feb 6 14:54:35 2020 +0100 MSHADE-350 enable to rewrite the manifest --- .../resource/ManifestResourceTransformer.java | 32 + .../resource/ManifestResourceTransformerTest.java | 131 + 2 files changed, 163 insertions(+) diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformer.java b/src/main/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformer.java index fd0bf48..a7e2be5 100644 --- a/src/main/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformer.java +++ b/src/main/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformer.java @@ -51,6 +51,8 @@ public class ManifestResourceTransformer // Fields private boolean manifestDiscovered; +private boolean skipRelocators; + private Manifest manifest; public boolean canTransformResource( String resource ) @@ -72,10 +74,40 @@ public class ManifestResourceTransformer if ( !manifestDiscovered ) { manifest = new Manifest( is ); + +if ( relocators != null && !relocators.isEmpty() ) +{ +rewriteManifest( relocators ); +} + manifestDiscovered = true; } } +private void rewriteManifest( List relocators ) +{ +if ( skipRelocators ) +{ +return; +} +for ( final Map.Entry entry : manifest.getMainAttributes().entrySet() ) +{ +final Object value = entry.getValue(); +if ( value instanceof String ) +{ +String relContent = String.valueOf( value ); +for ( final Relocator relocator : relocators ) +{ +relContent = relocator.applyToSourceContent( relContent ); +} +if ( !relContent.equals( value ) ) +{ +entry.setValue( relContent ); +} +} +} +} + public boolean hasTransformedResource() { return true; diff --git a/src/test/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformerTest.java b/src/test/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformerTest.java new file mode 100644 index 000..daa28aa --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformerTest.java @@ -0,0 +1,131 @@ +package org.apache.maven.plugins.shade.resource; + +/* + * 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 static org.junit.Assert.assertEquals; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.util.Collections; +import java.util.jar.Attributes; +import java.util.jar.JarFile; +import java.util.jar.JarInputStream; +import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; + +import org.apache.maven.plugins.shade.relocation.Relocator; +import org.apache.maven.plugins.shade.relocation.SimpleRelocator; +import org.junit.Test; + +public class ManifestResourceTransformerTest +{ +@Test +public void rewriteManifestEntries() throws Exception +{ +final ManifestResourceTransformer transformer = new ManifestResourceTransformer(); +final Field skipRelocators = ManifestResourceTransformer.class.getDeclaredField("skipRelocators"); +skipRelocators.setAccessible(true); +skipRelocators.set(transformer, false); + +final Manifest manifest = new Manifest(); +final Attributes attributes = manifest.getMainAttributes(); +attributes.put(Attributes.Name.MANIFEST_VERSION, "1.0"); +attributes.putValue("Export-Package", + "
[maven-shade-plugin] branch MSHADE-322_2 deleted (was e300c04)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-322_2 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. was e300c04 fixing Tibor's review comments (thanks) and ensuring test works on windows This change permanently discards the following revisions: discard e300c04 fixing Tibor's review comments (thanks) and ensuring test works on windows discard 0db53c7 Merge branch 'log-all-duplicates' into MSHADE-322_2 discard 646c2c3 extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test discard 2807e5f [MSHADE-322] - fixing windows tests
[maven-shade-plugin] branch MSHADE-306 deleted (was cccc31d)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-306 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. was 31d [MSHADE-306] log all duplicates to not silently swallow a duplicate and an implicit selection This change permanently discards the following revisions: discard 31d [MSHADE-306] log all duplicates to not silently swallow a duplicate and an implicit selection
[maven-shade-plugin] branch master updated: [MSHADE-322][MSHADE-306] fixing Tibor's review comments and ensure master tests are deterministic
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git The following commit(s) were added to refs/heads/master by this push: new 57d78de [MSHADE-322][MSHADE-306] fixing Tibor's review comments and ensure master tests are deterministic 57d78de is described below commit 57d78de0664c359530f0e5c6a2bb1563b4b092d8 Author: Romain Manni-Bucau AuthorDate: Wed Aug 14 09:54:33 2019 +0200 [MSHADE-322][MSHADE-306] fixing Tibor's review comments and ensure master tests are deterministic --- .../plugins/shade/resource/properties/SortedProperties.java | 9 ++--- .../org/apache/maven/plugins/shade/DefaultShaderTest.java | 13 ++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java b/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java index 48eb5f0..f64f9f7 100644 --- a/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java +++ b/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java @@ -23,8 +23,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Enumeration; -import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -32,7 +32,10 @@ import java.util.Properties; import java.util.Set; /** - * Properties instance sorting its keys on iterations. + * Internal Properties instance sorting its keys on iterations for store() usages. + * It ensures properties persistence is deterministic. + * + * IMPORTANT: this only overrides methods used accross JVM in store() so ordering is not guaranteed for other cases. */ public class SortedProperties extends Properties { @@ -48,7 +51,7 @@ public class SortedProperties extends Properties return String.valueOf( o1.getKey() ).compareTo( String.valueOf( o2.getKey() ) ); } } ); -return new HashSet<>( entries ); +return new LinkedHashSet<>( entries ); } @Override diff --git a/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java b/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java index 54be8dd..e736d6a 100644 --- a/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java +++ b/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java @@ -65,7 +65,7 @@ public class DefaultShaderTest @Override public void debug( final String s, final Throwable throwable ) { -debugMessages.add(s); +debugMessages.add( s.replace( '\\', '/' ).trim() ); } @Override @@ -77,7 +77,7 @@ public class DefaultShaderTest @Override public void warn( final String s, final Throwable throwable ) { -warnMessages.add(s); +warnMessages.add( s.replace( '\\', '/' ).trim() ); } @Override @@ -101,7 +101,7 @@ public class DefaultShaderTest // we will shade two jars and expect to see META-INF/MANIFEST.MF overlaps, this will always be true // but this can lead to a broken deployment if intended for OSGi or so, so even this should be logged -final Set set = new LinkedHashSet(); +final Set set = new LinkedHashSet<>(); set.add( new File( "src/test/jars/test-project-1.0-SNAPSHOT.jar" ) ); set.add( new File( "src/test/jars/plexus-utils-1.4.1.jar" ) ); @@ -115,13 +115,12 @@ public class DefaultShaderTest final String failureWarnMessage = warnMessages.toString(); assertTrue(failureWarnMessage, warnMessages.contains( -"plexus-utils-1.4.1.jar, test-project-1.0-SNAPSHOT.jar define 1 overlapping resources: ")); -assertTrue(failureWarnMessage, warnMessages.contains(" - META-INF/MANIFEST.MF")); +"plexus-utils-1.4.1.jar, test-project-1.0-SNAPSHOT.jar define 1 overlapping resources:")); +assertTrue(failureWarnMessage, warnMessages.contains("- META-INF/MANIFEST.MF")); final String failureDebugMessage = debugMessages.toString(); assertTrue(failureDebugMessage, debugMessages.contains( -"We have a duplicate META-INF/MANIFEST.MF in src/test/jars/plexus-utils-1.4.1.jar" -.replace('/', File.separatorChar))); +"We have a duplicate META-INF/MANIFEST.MF in src/test/jars/plexus-utils-1.4.1.jar" )); } public void testShaderWithDefaultShadedPattern()
[maven-shade-plugin] 02/02: fixing Tibor's review comments (thanks) and ensuring test works on windows
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MSHADE-322_2 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git commit e300c0438b401ebd977f7157f925f4b8a3f1caba Author: Romain Manni-Bucau AuthorDate: Wed Aug 14 09:49:45 2019 +0200 fixing Tibor's review comments (thanks) and ensuring test works on windows --- .../plugins/shade/resource/properties/SortedProperties.java | 9 ++--- .../org/apache/maven/plugins/shade/DefaultShaderTest.java | 13 ++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java b/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java index 48eb5f0..f64f9f7 100644 --- a/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java +++ b/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java @@ -23,8 +23,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Enumeration; -import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -32,7 +32,10 @@ import java.util.Properties; import java.util.Set; /** - * Properties instance sorting its keys on iterations. + * Internal Properties instance sorting its keys on iterations for store() usages. + * It ensures properties persistence is deterministic. + * + * IMPORTANT: this only overrides methods used accross JVM in store() so ordering is not guaranteed for other cases. */ public class SortedProperties extends Properties { @@ -48,7 +51,7 @@ public class SortedProperties extends Properties return String.valueOf( o1.getKey() ).compareTo( String.valueOf( o2.getKey() ) ); } } ); -return new HashSet<>( entries ); +return new LinkedHashSet<>( entries ); } @Override diff --git a/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java b/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java index 54be8dd..e736d6a 100644 --- a/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java +++ b/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java @@ -65,7 +65,7 @@ public class DefaultShaderTest @Override public void debug( final String s, final Throwable throwable ) { -debugMessages.add(s); +debugMessages.add( s.replace( '\\', '/' ).trim() ); } @Override @@ -77,7 +77,7 @@ public class DefaultShaderTest @Override public void warn( final String s, final Throwable throwable ) { -warnMessages.add(s); +warnMessages.add( s.replace( '\\', '/' ).trim() ); } @Override @@ -101,7 +101,7 @@ public class DefaultShaderTest // we will shade two jars and expect to see META-INF/MANIFEST.MF overlaps, this will always be true // but this can lead to a broken deployment if intended for OSGi or so, so even this should be logged -final Set set = new LinkedHashSet(); +final Set set = new LinkedHashSet<>(); set.add( new File( "src/test/jars/test-project-1.0-SNAPSHOT.jar" ) ); set.add( new File( "src/test/jars/plexus-utils-1.4.1.jar" ) ); @@ -115,13 +115,12 @@ public class DefaultShaderTest final String failureWarnMessage = warnMessages.toString(); assertTrue(failureWarnMessage, warnMessages.contains( -"plexus-utils-1.4.1.jar, test-project-1.0-SNAPSHOT.jar define 1 overlapping resources: ")); -assertTrue(failureWarnMessage, warnMessages.contains(" - META-INF/MANIFEST.MF")); +"plexus-utils-1.4.1.jar, test-project-1.0-SNAPSHOT.jar define 1 overlapping resources:")); +assertTrue(failureWarnMessage, warnMessages.contains("- META-INF/MANIFEST.MF")); final String failureDebugMessage = debugMessages.toString(); assertTrue(failureDebugMessage, debugMessages.contains( -"We have a duplicate META-INF/MANIFEST.MF in src/test/jars/plexus-utils-1.4.1.jar" -.replace('/', File.separatorChar))); +"We have a duplicate META-INF/MANIFEST.MF in src/test/jars/plexus-utils-1.4.1.jar" )); } public void testShaderWithDefaultShadedPattern()
[maven-shade-plugin] 01/02: Merge branch 'log-all-duplicates' into MSHADE-322_2
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MSHADE-322_2 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git commit 0db53c7705caee71575cf629cf6baefcc0efc863 Merge: 646c2c3 2682f6e Author: Romain Manni-Bucau AuthorDate: Wed Aug 14 09:45:08 2019 +0200 Merge branch 'log-all-duplicates' into MSHADE-322_2 .../apache/maven/plugins/shade/DefaultShader.java | 48 +++--- .../maven/plugins/shade/DefaultShaderTest.java | 73 ++ 2 files changed, 112 insertions(+), 9 deletions(-)
[maven-shade-plugin] branch MSHADE-322_2 updated (646c2c3 -> e300c04)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-322_2 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. from 646c2c3 extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test add 2682f6e [MSHADE-306] - log all duplicates to not silently swallow a duplicate and an implicit selection new 0db53c7 Merge branch 'log-all-duplicates' into MSHADE-322_2 new e300c04 fixing Tibor's review comments (thanks) and ensuring test works on windows The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../apache/maven/plugins/shade/DefaultShader.java | 48 --- .../resource/properties/SortedProperties.java | 9 ++- .../maven/plugins/shade/DefaultShaderTest.java | 72 ++ 3 files changed, 117 insertions(+), 12 deletions(-)
[maven-shade-plugin] branch MSHADE-322 deleted (was 646c2c3)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-322 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. was 646c2c3 extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test The revisions that were on this branch are still contained in other references; therefore, this change does not discard any commits from the repository.
[maven-shade-plugin] branch MSHADE-322_2 created (now 646c2c3)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-322_2 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. at 646c2c3 extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test No new revisions were added by this update.
[maven-shade-plugin] 01/02: [MSHADE-322] - fixing windows tests
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MSHADE-322 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git commit 2807e5fdb8635860422a6a71175d671342324976 Author: Romain Manni-Bucau AuthorDate: Thu Aug 8 18:51:13 2019 +0200 [MSHADE-322] - fixing windows tests --- .../plugins/shade/resource/properties/PropertiesTransformerTest.java| 2 +- .../apache/maven/plugins/shade/resource/rule/TransformerTesterRule.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformerTest.java b/src/test/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformerTest.java index bd5f0e1..e0d105c 100644 --- a/src/test/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformerTest.java +++ b/src/test/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformerTest.java @@ -62,7 +62,7 @@ public class PropertiesTransformerTest assertEquals( "# Merged by maven-shade-plugin\n" + "b=2\n" + -"a=1\n", os.toString("UTF-8")); +"a=1\n", os.toString("UTF-8").replace( System.lineSeparator(), "\n" ) ); } @Test diff --git a/src/test/java/org/apache/maven/plugins/shade/resource/rule/TransformerTesterRule.java b/src/test/java/org/apache/maven/plugins/shade/resource/rule/TransformerTesterRule.java index 88d3e93..f520d7c 100644 --- a/src/test/java/org/apache/maven/plugins/shade/resource/rule/TransformerTesterRule.java +++ b/src/test/java/org/apache/maven/plugins/shade/resource/rule/TransformerTesterRule.java @@ -107,7 +107,7 @@ public class TransformerTesterRule implements TestRule assertNotNull( expected.path(), content ); assertTrue( expected.path() + ", expected=" + expected.content() + ", actual=" + content, -content.matches( expected.content() ) ); +content.replace( System.lineSeparator(), "\n" ) .matches( expected.content() ) ); } }
[maven-shade-plugin] branch MSHADE-322 created (now 646c2c3)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-322 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. at 646c2c3 extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test This branch includes the following new commits: new 2807e5f [MSHADE-322] - fixing windows tests new 646c2c3 extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven-shade-plugin] 02/02: extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MSHADE-322 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git commit 646c2c3151a25459725a21b203bdc299b2375b10 Author: Romain Manni-Bucau AuthorDate: Sun Aug 11 20:04:20 2019 +0200 extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test --- .../resource/properties/PropertiesTransformer.java | 33 + .../resource/properties/SortedProperties.java | 79 ++ .../properties/PropertiesTransformerTest.java | 6 +- 3 files changed, 83 insertions(+), 35 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java b/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java index a6a7aff..e80f8f1 100644 --- a/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java +++ b/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java @@ -25,10 +25,6 @@ import java.io.InputStream; import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Objects; import java.util.Properties; @@ -197,34 +193,7 @@ public class PropertiesTransformer implements ResourceTransformer private static Properties mergeProperties( final List sortedProperties ) { -final Properties mergedProperties = new Properties() -{ -@Override -public synchronized Enumeration keys() // ensure it is sorted to be deterministic -{ -final List keys = new LinkedList<>(); -for ( Object k : super.keySet() ) -{ -keys.add( (String) k ); -} -Collections.sort( keys ); -final Iterator it = keys.iterator(); -return new Enumeration() -{ -@Override -public boolean hasMoreElements() -{ -return it.hasNext(); -} - -@Override -public Object nextElement() -{ -return it.next(); -} -}; -} -}; +final Properties mergedProperties = new SortedProperties(); for ( final Properties p : sortedProperties ) { mergedProperties.putAll( p ); diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java b/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java new file mode 100644 index 000..48eb5f0 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java @@ -0,0 +1,79 @@ +package org.apache.maven.plugins.shade.resource.properties; + +/* + * 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.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +/** + * Properties instance sorting its keys on iterations. + */ +public class SortedProperties extends Properties +{ +@Override +public Set> entrySet() +{ +final List> entries = new ArrayList<>( super.entrySet() ); +Collections.sort( entries, new Comparator>() +{ +@Override +public int compare( Map.Entry o1, Map.Entry o2 ) +{ +return String.valueOf( o1.getKey() ).compareTo( String.valueOf( o2.getKey() ) ); +} +} ); +return new HashSet<>( entries ); +} + +@Ove
[maven-shade-plugin] branch fixing-prop-tests-on-windows deleted (was 2807e5f)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch fixing-prop-tests-on-windows in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. was 2807e5f [MSHADE-322] - fixing windows tests This change permanently discards the following revisions: discard 2807e5f [MSHADE-322] - fixing windows tests
[maven-shade-plugin] branch MSHADE-322 deleted (was 646c2c3)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-322 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. was 646c2c3 extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test This change permanently discards the following revisions: discard 646c2c3 extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test
[maven-shade-plugin] branch master updated: [MSHADE-322] - extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git The following commit(s) were added to refs/heads/master by this push: new fbefa16 [MSHADE-322] - extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test fbefa16 is described below commit fbefa1651c08f3f6026ff72502a4ee471d535cfa Author: Romain Manni-Bucau AuthorDate: Thu Aug 8 18:51:13 2019 +0200 [MSHADE-322] - extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test --- .../resource/properties/PropertiesTransformer.java | 33 + .../resource/properties/SortedProperties.java | 79 ++ .../properties/PropertiesTransformerTest.java | 6 +- .../shade/resource/rule/TransformerTesterRule.java | 2 +- 4 files changed, 84 insertions(+), 36 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java b/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java index a6a7aff..e80f8f1 100644 --- a/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java +++ b/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java @@ -25,10 +25,6 @@ import java.io.InputStream; import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Objects; import java.util.Properties; @@ -197,34 +193,7 @@ public class PropertiesTransformer implements ResourceTransformer private static Properties mergeProperties( final List sortedProperties ) { -final Properties mergedProperties = new Properties() -{ -@Override -public synchronized Enumeration keys() // ensure it is sorted to be deterministic -{ -final List keys = new LinkedList<>(); -for ( Object k : super.keySet() ) -{ -keys.add( (String) k ); -} -Collections.sort( keys ); -final Iterator it = keys.iterator(); -return new Enumeration() -{ -@Override -public boolean hasMoreElements() -{ -return it.hasNext(); -} - -@Override -public Object nextElement() -{ -return it.next(); -} -}; -} -}; +final Properties mergedProperties = new SortedProperties(); for ( final Properties p : sortedProperties ) { mergedProperties.putAll( p ); diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java b/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java new file mode 100644 index 000..48eb5f0 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java @@ -0,0 +1,79 @@ +package org.apache.maven.plugins.shade.resource.properties; + +/* + * 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.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +/** + * Properties instance sorting its keys on iterations. + */ +public class SortedProperties extends Properties +{ +@Override +public Set> entrySet() +{ +final List> entries = new ArrayList<>( super.entrySet() ); +Col
[maven-shade-plugin] branch MSHADE-322 updated (7b28524 -> 646c2c3)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-322 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. discard 7b28524 extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test new 646c2c3 extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (7b28524) \ N -- N -- N refs/heads/MSHADE-322 (646c2c3) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../plugins/shade/resource/properties/PropertiesTransformer.java | 4 .../maven/plugins/shade/resource/properties/SortedProperties.java| 5 - 2 files changed, 4 insertions(+), 5 deletions(-)
[maven-shade-plugin] 01/01: extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MSHADE-322 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git commit 646c2c3151a25459725a21b203bdc299b2375b10 Author: Romain Manni-Bucau AuthorDate: Sun Aug 11 20:04:20 2019 +0200 extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test --- .../resource/properties/PropertiesTransformer.java | 33 + .../resource/properties/SortedProperties.java | 79 ++ .../properties/PropertiesTransformerTest.java | 6 +- 3 files changed, 83 insertions(+), 35 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java b/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java index a6a7aff..e80f8f1 100644 --- a/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java +++ b/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java @@ -25,10 +25,6 @@ import java.io.InputStream; import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Objects; import java.util.Properties; @@ -197,34 +193,7 @@ public class PropertiesTransformer implements ResourceTransformer private static Properties mergeProperties( final List sortedProperties ) { -final Properties mergedProperties = new Properties() -{ -@Override -public synchronized Enumeration keys() // ensure it is sorted to be deterministic -{ -final List keys = new LinkedList<>(); -for ( Object k : super.keySet() ) -{ -keys.add( (String) k ); -} -Collections.sort( keys ); -final Iterator it = keys.iterator(); -return new Enumeration() -{ -@Override -public boolean hasMoreElements() -{ -return it.hasNext(); -} - -@Override -public Object nextElement() -{ -return it.next(); -} -}; -} -}; +final Properties mergedProperties = new SortedProperties(); for ( final Properties p : sortedProperties ) { mergedProperties.putAll( p ); diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java b/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java new file mode 100644 index 000..48eb5f0 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java @@ -0,0 +1,79 @@ +package org.apache.maven.plugins.shade.resource.properties; + +/* + * 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.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +/** + * Properties instance sorting its keys on iterations. + */ +public class SortedProperties extends Properties +{ +@Override +public Set> entrySet() +{ +final List> entries = new ArrayList<>( super.entrySet() ); +Collections.sort( entries, new Comparator>() +{ +@Override +public int compare( Map.Entry o1, Map.Entry o2 ) +{ +return String.valueOf( o1.getKey() ).compareTo( String.valueOf( o2.getKey() ) ); +} +} ); +return new HashSet<>( entries ); +} + +@Ove
[maven-shade-plugin] branch MSHADE-322 updated: extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch MSHADE-322 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git The following commit(s) were added to refs/heads/MSHADE-322 by this push: new 7b28524 extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test 7b28524 is described below commit 7b285244d569d69fe0d1b00738aa855930f0d7ce Author: Romain Manni-Bucau AuthorDate: Sun Aug 11 20:04:20 2019 +0200 extracting SortedProperties to be able to reuse it in the test validating properties keys stability + fixing related test --- .../resource/properties/PropertiesTransformer.java | 29 + .../resource/properties/SortedProperties.java | 76 ++ .../properties/PropertiesTransformerTest.java | 6 +- 3 files changed, 80 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java b/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java index a6a7aff..2f4cad3 100644 --- a/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java +++ b/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java @@ -197,34 +197,7 @@ public class PropertiesTransformer implements ResourceTransformer private static Properties mergeProperties( final List sortedProperties ) { -final Properties mergedProperties = new Properties() -{ -@Override -public synchronized Enumeration keys() // ensure it is sorted to be deterministic -{ -final List keys = new LinkedList<>(); -for ( Object k : super.keySet() ) -{ -keys.add( (String) k ); -} -Collections.sort( keys ); -final Iterator it = keys.iterator(); -return new Enumeration() -{ -@Override -public boolean hasMoreElements() -{ -return it.hasNext(); -} - -@Override -public Object nextElement() -{ -return it.next(); -} -}; -} -}; +final Properties mergedProperties = new SortedProperties(); for ( final Properties p : sortedProperties ) { mergedProperties.putAll( p ); diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java b/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java new file mode 100644 index 000..9da99c4 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/shade/resource/properties/SortedProperties.java @@ -0,0 +1,76 @@ +package org.apache.maven.plugins.shade.resource.properties; + +/* + * 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.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +public class SortedProperties extends Properties +{ +@Override +public Set> entrySet() +{ +final List> entries = new ArrayList<>( super.entrySet() ); +Collections.sort( entries, new Comparator>() +{ +@Override +public int compare( Map.Entry o1, Map.Entry o2 ) +{ +return String.valueOf( o1.getKey() ).compareTo( String.valueOf( o2.getKey() ) ); +} +}); +return new HashSet<>( entries ); +} + +@Override +public synchronized Enumeration keys() // ensure it is sorted to be deterministic +{ +final List keys = new LinkedList<>(); +for ( Object k : super
[maven-shade-plugin] branch master updated: [MSHADE-306] - log all duplicates to not silently swallow a duplicate and an implicit selection
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git The following commit(s) were added to refs/heads/master by this push: new 2682f6e [MSHADE-306] - log all duplicates to not silently swallow a duplicate and an implicit selection 2682f6e is described below commit 2682f6ec4212dad227f691e40f6067969dc503b3 Author: Romain Manni-Bucau AuthorDate: Sat Dec 15 20:44:05 2018 +0100 [MSHADE-306] - log all duplicates to not silently swallow a duplicate and an implicit selection --- .../apache/maven/plugins/shade/DefaultShader.java | 48 +++--- .../maven/plugins/shade/DefaultShaderTest.java | 73 ++ 2 files changed, 112 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java b/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java index c4d677a..80ab074 100644 --- a/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java +++ b/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java @@ -30,9 +30,11 @@ import java.io.Writer; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Enumeration; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.jar.JarEntry; @@ -226,9 +228,9 @@ public class DefaultShader } } +duplicates.put( name, jar ); if ( name.endsWith( ".class" ) ) { -duplicates.put( name, jar ); addRemappedClass( remapper, jos, jar, name, in ); } else if ( shadeRequest.isShadeSourcesContent() && name.endsWith( ".java" ) ) @@ -248,6 +250,7 @@ public class DefaultShader // Avoid duplicates that aren't accounted for by the resource transformers if ( resources.contains( mappedName ) ) { +getLogger().debug( "We have a duplicate " + name + " in " + jar ); return; } @@ -314,28 +317,55 @@ public class DefaultShader jarzS.add( jjar.getName() ); } -List classes = new ArrayList<>(); +Collections.sort( jarzS ); // deterministic messages to be able to compare outputs (useful on CI) -for ( String clazz : overlapping.get( jarz ) ) +List classes = new LinkedList<>(); +List resources = new LinkedList<>(); + +for ( String name : overlapping.get( jarz ) ) { -classes.add( clazz.replace( ".class", "" ).replace( "/", "." ) ); +if ( name.endsWith( ".class" ) ) +{ +classes.add( name.replace( ".class", "" ).replace( "/", "." ) ); +} +else +{ +resources.add( name ); +} } //CHECKSTYLE_OFF: LineLength +final Collection overlaps = new ArrayList<>(); +if ( !classes.isEmpty() ) +{ +overlaps.add( "classes" ); +} +if ( !resources.isEmpty() ) +{ +overlaps.add( "resources" ); +} + +final List all = new ArrayList<>( classes.size() + resources.size() ); +all.addAll( classes ); +all.addAll( resources ); + getLogger().warn( -Joiner.on( ", " ).join( jarzS ) + " define " + classes.size() + " overlapping classes: " ); +Joiner.on( ", " ).join( jarzS ) + " define " + all.size() ++ " overlapping " + Joiner.on( " and " ).join( overlaps ) + ": " ); //CHECKSTYLE_ON: LineLength +Collections.sort( all ); + int max = 10; -for ( int i = 0; i < Math.min( max, classes.size() ); i++ ) +for ( int i = 0; i < Math.min( max, all.size() ); i++ ) { -getLogger().warn( " - " + classes.get( i ) ); +getLogger().warn( " - " + all.get( i ) ); } -if ( classes.size() > max ) +if ( all.size() > max ) { -getLogger().warn( " - " + ( classes.size() - max ) + " more..." ); +getLogger().warn( " - " + ( all.size() - max ) + " more..."
[maven-shade-plugin] branch MSHADE-322 created (now 2807e5f)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch MSHADE-322 in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. at 2807e5f [MSHADE-322] - fixing windows tests No new revisions were added by this update.
[maven-shade-plugin] 01/01: [MSHADE-322] - fixing windows tests
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch fixing-prop-tests-on-windows in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git commit 2807e5fdb8635860422a6a71175d671342324976 Author: Romain Manni-Bucau AuthorDate: Thu Aug 8 18:51:13 2019 +0200 [MSHADE-322] - fixing windows tests --- .../plugins/shade/resource/properties/PropertiesTransformerTest.java| 2 +- .../apache/maven/plugins/shade/resource/rule/TransformerTesterRule.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformerTest.java b/src/test/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformerTest.java index bd5f0e1..e0d105c 100644 --- a/src/test/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformerTest.java +++ b/src/test/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformerTest.java @@ -62,7 +62,7 @@ public class PropertiesTransformerTest assertEquals( "# Merged by maven-shade-plugin\n" + "b=2\n" + -"a=1\n", os.toString("UTF-8")); +"a=1\n", os.toString("UTF-8").replace( System.lineSeparator(), "\n" ) ); } @Test diff --git a/src/test/java/org/apache/maven/plugins/shade/resource/rule/TransformerTesterRule.java b/src/test/java/org/apache/maven/plugins/shade/resource/rule/TransformerTesterRule.java index 88d3e93..f520d7c 100644 --- a/src/test/java/org/apache/maven/plugins/shade/resource/rule/TransformerTesterRule.java +++ b/src/test/java/org/apache/maven/plugins/shade/resource/rule/TransformerTesterRule.java @@ -107,7 +107,7 @@ public class TransformerTesterRule implements TestRule assertNotNull( expected.path(), content ); assertTrue( expected.path() + ", expected=" + expected.content() + ", actual=" + content, -content.matches( expected.content() ) ); +content.replace( System.lineSeparator(), "\n" ) .matches( expected.content() ) ); } }
[maven-shade-plugin] branch fixing-prop-tests-on-windows created (now 2807e5f)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a change to branch fixing-prop-tests-on-windows in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git. at 2807e5f [MSHADE-322] - fixing windows tests This branch includes the following new commits: new 2807e5f [MSHADE-322] - fixing windows tests The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[maven-shade-plugin] branch master updated: [MSHADE-322] - adding properties transformer (+ its microprofile and openwebbeans specific cases)
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git The following commit(s) were added to refs/heads/master by this push: new f122b47 [MSHADE-322] - adding properties transformer (+ its microprofile and openwebbeans specific cases) f122b47 is described below commit f122b4731993ca06cf8d5a052608be4dd5fc95d3 Author: Romain Manni-Bucau AuthorDate: Fri Jul 12 20:13:04 2019 +0200 [MSHADE-322] - adding properties transformer (+ its microprofile and openwebbeans specific cases) --- .../properties/MicroprofileConfigTransformer.java | 33 +++ .../OpenWebBeansPropertiesTransformer.java | 33 +++ .../resource/properties/PropertiesTransformer.java | 234 .../properties/io/NoCloseOutputStream.java | 67 ++ .../io/SkipPropertiesDateLineWriter.java | 97 + src/site/apt/examples/resource-transformers.apt.vm | 122 +++ .../properties/PropertiesTransformerTest.java | 143 + .../shade/resource/rule/TransformerTesterRule.java | 235 + 8 files changed, 964 insertions(+) diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/properties/MicroprofileConfigTransformer.java b/src/main/java/org/apache/maven/plugins/shade/resource/properties/MicroprofileConfigTransformer.java new file mode 100644 index 000..ecc49b2 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/shade/resource/properties/MicroprofileConfigTransformer.java @@ -0,0 +1,33 @@ +package org.apache.maven.plugins.shade.resource.properties; + +/* + * 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. + */ + +/** + * Enables to merge Microprofile Config configuration files properly respecting their ordinal. + * + * @since 3.2.2 + */ +public class MicroprofileConfigTransformer extends PropertiesTransformer +{ +protected MicroprofileConfigTransformer() +{ +super( null, "config_ordinal", 1000, false ); +} +} diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/properties/OpenWebBeansPropertiesTransformer.java b/src/main/java/org/apache/maven/plugins/shade/resource/properties/OpenWebBeansPropertiesTransformer.java new file mode 100644 index 000..180ac54 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/shade/resource/properties/OpenWebBeansPropertiesTransformer.java @@ -0,0 +1,33 @@ +package org.apache.maven.plugins.shade.resource.properties; + +/* + * 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. + */ + +/** + * Enables to merge openwebbeans configuration files properly respecting their ordinal. + * + * @since 3.2.2 + */ +public class OpenWebBeansPropertiesTransformer extends PropertiesTransformer +{ +protected OpenWebBeansPropertiesTransformer() +{ +super( "META-INF/openwebbeans/openwebbeans.properties", "configuration.ordinal", 100, false ); +} +} diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java b/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java new file mode 100644 index 000..a6a7aff --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/shade/resource/properties/PropertiesTransformer.java @@ -0,0 +1,234 @@ +package org.apache.maven.plugin