I have created a custom packaging type in my maven plugin so that I can deploy files in this custom format.
E.g. I have a project that uses this format for packaging. The pom.xml has:
<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> <groupId>com.example</groupId> <artifactId>mylib</artifactId> <version>1.0-SNAPSHOT</version> <packaging>mybin</packaging> ....
I am able to deploy successfully to a repository. But now I want to use this as a dependency in another project.
E.g. by adding something like this:
<dependency> <groupId>com.example</groupId> <artifactId>mylib</artifactId> <version>1.0-SNAPSHOT</version> <type>mybin</type> </dependency>
This is working fine, also except that
mybin format includes some nested resources such as jar files) that I would like to include in the classpath.
I so far I’ve attempted to programmatically extract the jars from inside a mojo and programmatically add it to the project using
project.getModel().addDependency(systemJarDep), but this doesn’t seem to be picked up by the compiler.
How can this be done in Maven?
It seems that this sort of thing cannot be done in Maven.
I am solving my problem by adjusting the format of my custom package type to be a jar file itself, with all of the classes that I want on the classpath directly inside it. The other sub-resources that I don’t require on the classpath (at least by default) are bundled inside the META-INF directory.
This is not ideal, but it is an acceptable solution for now.