I recently need to be able to publish two artifacts from one maven module within a multi module build. I fumbled around for a while looking for the best way to handle this. The key was defining the classifier under configuration.
Maven pom.xml
<?xml version="1.0"?> <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> <parent> <groupId>net.kyleryan</groupId> <artifactId>myproject</artifactId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>implementation</artifactId> <version>1.0-SNAPSHOT</version> <name>GSSMFrameworkV2</name> <dependencies> <!-- dependencies --> </dependencies> <build> <!-- Define the classes that will make up the client jar --> <plugins> <plugin> <artifactId>maven-jar-plugin</artifactId> <version>2.3.2</version> <executions> <execution> <id>client</id> <phase>package</phase> <goals> <goal>jar</goal> </goals> <configuration> <classifier>client</classifier> <includes> <include>net/kyleryan/exception/FrameworkExceptionHandler.class</include> <include>net/kyleryan/exception/UserException.class</include> <include>net/gm/gssm/framework/ui/controller/MyController.class</include> <include>net/gm/gssm/framework/ui/handler/MyHandler.class</include> </includes> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>
Referencing the client jar in another module looks like this.
Dependency Example
<dependency> <groupId>net.kyleryan</groupId> <artifactId>implementation</artifactId> <version>1.0-SNAPSHOT</version> <classifier>client</classifier> </dependency>