You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Alexander Ashitkin (Jira)" <ji...@apache.org> on 2023/01/15 03:08:00 UTC

[jira] [Commented] (MBUILDCACHE-35) Incorrect pom is put to local repo for module with maven-shade-plugin

    [ https://issues.apache.org/jira/browse/MBUILDCACHE-35?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17676971#comment-17676971 ] 

Alexander Ashitkin commented on MBUILDCACHE-35:
-----------------------------------------------

I will try to reproduce it, but so far looks like attaching the shaded artifact with a different classifier could be a working workaround.

> Incorrect pom is put to local repo for module with maven-shade-plugin
> ---------------------------------------------------------------------
>
>                 Key: MBUILDCACHE-35
>                 URL: https://issues.apache.org/jira/browse/MBUILDCACHE-35
>             Project: Maven Build Cache Extension
>          Issue Type: Bug
>            Reporter: Maximilian Novikov
>            Priority: Major
>
> Original reporter: spirin.anton@gmail.com
> There is an issue with maven incremental build if module uses maven-shade plugin. If user executes mvnw clean install command and module is not changed then wrong pom file will be put into local maven repository and it will break module dependencies.
> Steps to reproduce:
>  # create a module with dependencies and with maven-shade plugin (see below)
>  # build module using incremental build: mvnw clean install (install command is required to put artifact into local maven repo)
>  # change something in module to trigger incremental build (for instance some symbols here <exclude>META-INF/test-run-01.txt</exclude>)
>  # build module again: mvnw clean install
>  # check that local repo has correct dependency reduced pom (ie pom file loaded into the repo does not have dependencies org.apache.commons:commons-lang3)
> {code:java}
> [devbox ~/.m2/repository/com/db/test/mvnbuild/mvnbuild-test/1.0]$ ll
> -rw-r--r--. 1 devbox users    716 Dec 13 09:49 maven-metadata-local.xml
> -rw-r--r--. 1 devbox users 584570 Dec 13 09:49 mvnbuild-test-1.0.jar
> -rw-r--r--. 1 devbox users   1512 Dec 13 09:49 mvnbuild-test-1.0.pom
> -rw-r--r--. 1 devbox users    208 Dec 13 09:49 _remote.repositories
> [devbox ~/.m2/repository/com/db/test/mvnbuild/mvnbuild-test/1.0]$ less mvnbuild-test-1.0.pom
> {code}
>  # do not change module and build it again: mvnw clean install
> *Expected:* local repositiry should have dependency reduced pom
> *Actual:* local repo has a pom file taken from source code ie with all dependencies
> As a result in class path there will be duplicated set of class files:
>  # from shaded module
>  # due to this defect from org.apache.commons:commons-lang3
> *Original POM*
> {code:java}
> <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>com.db.test.mvnbuild</groupId>
>     <artifactId>mvnbuild-test</artifactId>    
>     <version>1.0</version>
>     <packaging>jar</packaging>
>     <name>MvnTest</name>
>     <dependencies>
>         <dependency>
>             <groupId>org.apache.commons</groupId>
>             <artifactId>commons-lang3</artifactId>
>             <version>3.11</version>
>         </dependency>
>     </dependencies>
>     <build>
>         <plugins>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-shade-plugin</artifactId>
>                 <version>3.4.1</version>
>                 <executions>
>                     <execution>
>                         <phase>package</phase>
>                         <goals>
>                             <goal>shade</goal>
>                         </goals>
>                     </execution>
>                 </executions>
>                 <configuration>
>                     <createDependencyReducedPom>true</createDependencyReducedPom>
>                     <artifactSet>
>                         <includes>
>                             <include>org.apache.commons:commons-lang3</include>
>                         </includes>
>                     </artifactSet>
>                     <filters>
>                         <filter>
>                             <artifact>*:*</artifact>
>                             <excludes>
>                                 <exclude>META-INF/test-run-01.txt</exclude>
>                             </excludes>
>                         </filter>
>                     </filters>
>                 </configuration>
>             </plugin>
>         </plugins>
>     </build>
> </project>
> {code}
> *Dependency reduced POM*
> {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/maven-v4_0_0.xsd">
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>com.db.test.mvnbuild</groupId>
>   <artifactId>mvnbuild-test</artifactId>
>   <name>MvnTest</name>
>   <version>1.0</version>
>   <build>
>     <plugins>
>       <plugin>
>         <artifactId>maven-shade-plugin</artifactId>
>         <version>3.4.1</version>
>         <executions>
>           <execution>
>             <phase>package</phase>
>             <goals>
>               <goal>shade</goal>
>             </goals>
>           </execution>
>         </executions>
>         <configuration>
>           <createDependencyReducedPom>true</createDependencyReducedPom>
>           <artifactSet>
>             <includes>
>               <include>org.apache.commons:commons-lang3</include>
>             </includes>
>           </artifactSet>
>           <filters>
>             <filter>
>               <artifact>*:*</artifact>
>               <excludes>
>                 <exclude>META-INF/test-run-01.txt</exclude>
>               </excludes>
>             </filter>
>           </filters>
>         </configuration>
>       </plugin>
>     </plugins>
>   </build>
> </project>{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)