You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2022/05/06 08:59:05 UTC

[maven-assembly-plugin] branch master updated: [MASSEMBLY-956] Resolve only what is needed for final assembly (#55)

This is an automated email from the ASF dual-hosted git repository.

cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-assembly-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 27b9baa4 [MASSEMBLY-956] Resolve only what is needed for final assembly (#55)
27b9baa4 is described below

commit 27b9baa408184ab64fdb648e480df7120e088b41
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Fri May 6 10:59:00 2022 +0200

    [MASSEMBLY-956] Resolve only what is needed for final assembly (#55)
    
    m-assembly-p resolves even plugins used to build dependencies we refer to, which is unwanted.
    All we really want are dependencies we refer to, not plugins and plugin parents used to build
    dependencies we refer to.
---
 src/it/projects/bugs/massembly-956/pom.xml         | 62 ++++++++++++++++++++++
 .../bugs/massembly-956/src/assembly/assembly.xml   | 36 +++++++++++++
 src/it/projects/bugs/massembly-956/verify.groovy   | 25 +++++++++
 .../archive/task/AddDependencySetsTask.java        |  4 +-
 .../archive/task/AddDependencySetsTaskTest.java    |  6 +--
 5 files changed, 127 insertions(+), 6 deletions(-)

diff --git a/src/it/projects/bugs/massembly-956/pom.xml b/src/it/projects/bugs/massembly-956/pom.xml
new file mode 100644
index 00000000..c25157ec
--- /dev/null
+++ b/src/it/projects/bugs/massembly-956/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="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">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugins.assembly.its</groupId>
+  <artifactId>massembly-920</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+
+  <name>MASSEMBLY-956</name>
+
+  <dependencies>
+    <!-- This dependency's build uses tycho: but we are not interested in it, so it should not be resolved -->
+    <dependency>
+      <groupId>org.eclipse.sisu</groupId>
+      <artifactId>org.eclipse.sisu.inject</artifactId>
+      <version>0.3.5</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>massembly-956</id>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+            <configuration>
+              <descriptors>
+                <descriptor>src/assembly/assembly.xml</descriptor>
+              </descriptors>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file
diff --git a/src/it/projects/bugs/massembly-956/src/assembly/assembly.xml b/src/it/projects/bugs/massembly-956/src/assembly/assembly.xml
new file mode 100644
index 00000000..b0b5e1b2
--- /dev/null
+++ b/src/it/projects/bugs/massembly-956/src/assembly/assembly.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
+	<id>jar</id>
+	<formats>
+		<format>jar</format>
+	</formats>
+	<includeBaseDirectory>false</includeBaseDirectory>
+	<dependencySets>
+		<dependencySet>
+			<outputDirectory>/</outputDirectory>
+			<useProjectArtifact>false</useProjectArtifact>
+			<unpack>true</unpack>
+			<scope>runtime</scope>
+		</dependencySet>
+	</dependencySets>
+</assembly>
\ No newline at end of file
diff --git a/src/it/projects/bugs/massembly-956/verify.groovy b/src/it/projects/bugs/massembly-956/verify.groovy
new file mode 100644
index 00000000..c219a421
--- /dev/null
+++ b/src/it/projects/bugs/massembly-956/verify.groovy
@@ -0,0 +1,25 @@
+
+/*
+ * 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.
+ */
+
+def sisuPom = new File( localRepositoryPath, 'org/eclipse/sisu/org.eclipse.sisu.inject/0.3.5/org.eclipse.sisu.inject-0.3.5.pom' )
+def tychoPom = new File(localRepositoryPath, 'org/eclipse/tycho/tycho-maven-plugin/0.22.0/tycho-maven-plugin-0.22.0.pom')
+
+assert sisuPom.isFile()
+assert !tychoPom.isFile()
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTask.java b/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTask.java
index a3738e1b..4c1fff71 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTask.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTask.java
@@ -42,6 +42,7 @@ import org.apache.maven.plugins.assembly.model.UnpackOptions;
 import org.apache.maven.plugins.assembly.utils.AssemblyFormatUtils;
 import org.apache.maven.plugins.assembly.utils.FilterUtils;
 import org.apache.maven.plugins.assembly.utils.TypeConversionUtils;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
@@ -183,7 +184,8 @@ public class AddDependencySetsTask
 
     private ProjectBuildingRequest getProjectBuildingRequest( AssemblerConfigurationSource configSource )
     {
-        return configSource.getMavenSession().getProjectBuildingRequest();
+        return new DefaultProjectBuildingRequest( configSource.getMavenSession().getProjectBuildingRequest() )
+                .setProcessPlugins( false );
     }
 
     private boolean isUnpackWithOptions( DependencySet dependencySet )
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTaskTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTaskTest.java
index 1d316b1a..99ad00d1 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTaskTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTaskTest.java
@@ -386,14 +386,12 @@ public class AddDependencySetsTaskTest
         Artifact am1 = mock( Artifact.class );
         when( am1.getGroupId() ).thenReturn( "group" );
         when( am1.getArtifactId() ).thenReturn( "artifact" );
-        when( am1.getId() ).thenReturn( "group:artifact:1.0:jar" );
         artifacts.add( am1 );
 
         Artifact am2 = mock( Artifact.class );
         when( am2.getGroupId() ).thenReturn( "group2" );
         when( am2.getArtifactId() ).thenReturn( "artifact2" );
         when( am2.getId() ).thenReturn( "group2:artifact2:1.0:jar" );
-        when( am2.getDependencyConflictId() ).thenReturn( "group2:artifact2:jar" );
         artifacts.add( am2 );
 
         final DependencySet dependencySet = new DependencySet();
@@ -422,14 +420,12 @@ public class AddDependencySetsTaskTest
         Artifact am1 = mock( Artifact.class );
         when( am1.getGroupId() ).thenReturn( "group" );
         when( am1.getArtifactId() ).thenReturn( "artifact" );
-        when( am1.getId() ).thenReturn( "group:artifact:1.0:jar" );
         artifacts.add( am1 );
 
         Artifact am2 = mock( Artifact.class );
         when( am2.getGroupId() ).thenReturn( "group2" );
         when( am2.getArtifactId() ).thenReturn( "artifact2" );
         when( am2.getId() ).thenReturn( "group2:artifact2:1.0:jar" );
-        when( am2.getDependencyConflictId() ).thenReturn( "group2:artifact2:jar" );
         artifacts.add( am2 );
 
         final DependencySet dependencySet = new DependencySet();
@@ -482,7 +478,7 @@ public class AddDependencySetsTaskTest
         when( pbRes.getProject() ).thenReturn( project );
 
         final ProjectBuilder projectBuilder = mock( ProjectBuilder.class );
-        when( projectBuilder.build( any( Artifact.class ), eq( pbReq ) ) ).thenReturn( pbRes );
+        when( projectBuilder.build( any( Artifact.class ), any( ProjectBuildingRequest.class ) ) ).thenReturn( pbRes );
 
         final AddDependencySetsTask task = new AddDependencySetsTask( Collections.singletonList( dependencySet ),
                                                                       artifacts, project, projectBuilder );