Помпон-код внизу ниже создает файл classpath, содержащий все файлы jar относительно кэша .m2 maven:
${M2_REPO}\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;${M2_REPO}\com\github\jnr\jnr-ffi\2.1.7\jnr-ffi-2.1.7.jar;...
Все зависимости аккуратно копируются в target / lib
${project.build.directory}/lib
Интересно, как заставить maven создавать путь к классам, используя путь к моей директории target / lib, а не кеш maven:
target/libslf4j-api-1.7.25.jar:target/lib/jnr-ffi-2.1.7.jar:...
Я использую следующий код maven:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
<execution>
<id>build-classpath</id>
<phase>package</phase>
<goals>
<goal>build-classpath</goal>
</goals>
<configuration>
<attach>true</attach>
<outputFile>${project.build.directory}/classpath</outputFile>
</configuration>
</execution>
</executions>
</plugin>