У меня есть этот многомодульный проект maven:
ModuleA
src
pom.xml
target
ModuleA-with-dependencies-shaded.jar (version 4.1 of lucene relocated)
ModuleB
src
pom.xml
target
ModuleB-with-dependencies.jar (version 7.5.0 of lucene)
ModuleDist
assembly
all.xml
pom.xml (shaded plugin for jar + assembly for Docker)
Плагины dist pom настроены следующим образом:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<shadedClassifierName>all</shadedClassifierName>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<!--remove models from jar see mitie -->
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>.dat</resource>
</transformer>
</transformers>
<artifactSet>
<excludes>
<exclude>log4j:log4j:jar:</exclude>
</excludes>
</artifactSet>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<id>make-dist</id>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/assembly/all.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
И сборка all.xml:
<assembly>
<id>all</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/main/docker</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>lib</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>
Поскольку ModuleA
имеет транзитивную зависимость от lucene 4.1
(но перемещена, чтобы не конфликтовать с модулем B), а ModuleB
имеет транзитивную зависимость от lucene 7.5.0
, я хотел бы использовать ранее построенный и затененный jar ModuleA
в затененном плагине maven ModuleDist
(потому что, если я перемещаю lucene в ModuleDist
, он перемещает все классы lucene).
Как я могу это сделать?
или есть другой способ сделать это?
<classifier>shaded</classifier>
... - person khmarbaise   schedule 04.03.2020