You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "James Z.M. Gao (Jira)" <ji...@apache.org> on 2022/12/04 02:05:00 UTC
[jira] [Comment Edited] (MSHADE-124) Need better plan for getting dependency-reduced-pom.xml out of basedir
[ https://issues.apache.org/jira/browse/MSHADE-124?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17642859#comment-17642859 ]
James Z.M. Gao edited comment on MSHADE-124 at 12/4/22 2:04 AM:
----------------------------------------------------------------
[~kriegaex] Here is a single pom test case, the change of the basedir fails the assembly plugin.
{code:java}
<?xml version="1.0" encoding="UTF-8"?>
<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>g</groupId>
<artifactId>a</artifactId>
<version>0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.jar.forceCreation>true</maven.jar.forceCreation>
<createDependencyReducedPom>true</createDependencyReducedPom>
</properties>
<dependencies>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<createDependencyReducedPom>${createDependencyReducedPom}</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<descriptorRefs>
<!-- should put this pom.xml into the archive files -->
<descriptorRef>src</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>assembly</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> {code}
Place it in an empty folder, then the command `mvn package` should successfully create target/a-0-src.tar.gz file containing this pom.xml. But the latest version (3.4.1) of maven-shade-plugin fails the command with error:
{noformat}
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:3.4.2:single (assembly) on project a: Failed to create assembly: Error creating assembly archive src: archive cannot be empty -> [Help 1]
{noformat}
To work around, `mvn package -DcreateDependencyReducedPom=false` will generate the expected archive file. In addition, the patch at [https://github.com/apache/maven-shade-plugin/pull/128] can also pass this test.
was (Author: gzm55):
[~kriegaex] Here is a single pom test case, the change of the basedir fails the assembly plugin.
{code:java}
<?xml version="1.0" encoding="UTF-8"?>
<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>g</groupId>
<artifactId>a</artifactId>
<version>0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.jar.forceCreation>true</maven.jar.forceCreation>
<createDependencyReducedPom>true</createDependencyReducedPom>
</properties>
<dependencies>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<createDependencyReducedPom>${createDependencyReducedPom}</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<descriptorRefs>
<!-- should put this pom.xml into the archive files -->
<descriptorRef>src</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>assembly</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> {code}
Run `mvn package` should successfully create target/a-0-src.tar.gz file containing this pom.xml. But the latest version (3.4.1) of maven-shade-plugin fails the command with error:
{noformat}
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:3.4.2:single (assembly) on project a: Failed to create assembly: Error creating assembly archive src: archive cannot be empty -> [Help 1]
{noformat}
To work around, `mvn package -DcreateDependencyReducedPom=false` will generate the expected archive file. In addition, [https://github.com/apache/maven-shade-plugin/pull/128] can also pass this test.
> Need better plan for getting dependency-reduced-pom.xml out of basedir
> ----------------------------------------------------------------------
>
> Key: MSHADE-124
> URL: https://issues.apache.org/jira/browse/MSHADE-124
> Project: Maven Shade Plugin
> Issue Type: Bug
> Affects Versions: 1.7.1
> Reporter: Benson Margulies
> Priority: Major
>
> MSHADE-123 reported that putting the d-r-p into some location other
> than 'basedir' causes 'basedir' to follow it around, which can break builds.
> This is hard to fix, given the core maven definition of basedir as 'the dir containing the pom' with no option to change it.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)