У меня есть 2 проекта, проект A и проект B. Проект A зависит от проекта B.
pom.xml проекта A:
<dependencies>
<dependency>
<groupId>nft.dcs</groupId>
<artifactId>B</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<appendAssemblyId>true</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-vision-plugin</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/assembly/dep.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
Затем я компилирую свой проект, и он создает банку со всеми ненужными мне зависимостями. Созданы дополнительные папки, которые не нужно включать в файл jar. Я думаю, что эти зависимости тянутся вместе с зависимостью от проекта B.
Используя файл dep.xml , я указываю, какие папки вам не нужно включать в файл jar.
dep.xml
<id>with-spec</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
<unpack>true</unpack>
<unpackOptions>
<excludes>
<exclude>nft/**</exclude>
<exclude>com/**</exclude>
<exclude>impl/**</exclude>
<exclude>javax/**</exclude>
<exclude>junit/**</exclude>
<exclude>org/**</exclude>
<exclude>oshi/**</exclude>
<exclude>sound/**</exclude>
</excludes>
</unpackOptions>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
Этот метод просто ужасен. Скажите, пожалуйста, можно ли добавить в класс jar только классы из зависимости и не тянуть все остальные папки.