I want to reutilize an app but add my own resource files to it. "appToReutilize" is a uber JAR (aka fat JAR) except the resource files.
myApp's project has no code, just src/main/resources/*, a pom.xml and assembly.xml. My goal is simple, when I build myApp I want 2 files:
I figured how to package my resources files into a zip using maven-assembly-plugin:
<groupId>com.me</groupId>
<artifactId>myApp</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>com.someone</groupId>
<artifactId>appToReutilize</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
<finalName>resources</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>properties-config</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
assembly.xml:
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 https://maven.apache.org/xsd/assembly-2.2.0.xsd">
<id>properties-config</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/main/resources</directory>
<outputDirectory>./</outputDirectory>
<includes>
<include>*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
I read some more about this plugin and learned there's a way to package the app and the resources into a single jar but that's not what I need.
How do I solve this?
Solved using the maven-dependency-plugin!
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.someone</groupId>
<artifactId>appToReutilize</artifactId>
<version>2.0</version>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
<destFileName>appToReutilize.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</plugin>