Take the 2-minute tour ×

I need to produce an artifact from Maven module, which will contain only *Foo.class files from ./target/classes. It has to be a proper artifact that can be used later as a normal dependency for another project. It means that it has to contain its own pom.xml. I tried maven-dependency-plugin and maven-shade-plugin to no avail:

  • maven-dependency-plugin doesn't generate pom.xml, but only copies files into JAR - this is not enough for a Maven dependency

  • maven-shade-plugin doesn't allow to pick files by mask, and besides that it unpacks all dependencies into target artifact (which is not what I need).

What is a possible workaround?

share|improve this question
Are you sure maven-shade-plugin does not allow masking? see shade includes and excludes: maven.apache.org/plugins/maven-shade-plugin/examples/… –  Hannes R. Dec 5 '11 at 8:09
include/exclude in shade plugin is used to filter content of module dependencies, not content of the module itself. –  yegor256 Dec 5 '11 at 8:21
Is the pom.xml of this artifact the same as that of the module? –  Raghuram Dec 5 '11 at 8:27
No, it has to be different. Key difference is in dependencies list. I need this new pom.xml to have all dependencies from the module in compile scope, no matter what scope they had before. –  yegor256 Dec 5 '11 at 8:35

1 Answer 1

up vote 1 down vote accepted

You can use the maven-jar-plugin with several executions, includes/excludes plus classifier to put your classes into several artifacts.

See this answer: http://stackoverflow.com/a/8209544/34088

share|improve this answer
@yegor256. How did you ensure the artifact had a custom pom.xml? –  Raghuram Dec 6 '11 at 4:29

Your Answer


