1

I want to create multiple jars in one maven project. The number of jars that would be generated is not known explicitly. It depends on the number of some packages.

I found how to create a jar with maven-jar-plugin based on explicity pointed package

<configuration>
    <includes>
        <include>com/processor/plugin/**</include>
    </includes>
</configuration>

But in my case, the names of packages under com.processor.plugin are not known.

XProcessor and XProcessorProvider form a jar.

| com   
  | processor
    | plugin
      | first 
        | FirstProcessor.java
        | FirstProcessorProvider.java
      | second
        | SecondProcessor.java
        | SecondProcessorPorvider.java
      | third
        | ThirdProcessor.java
        | ThirdProcessorProvider.java

Expected result of mvn package: first.jar, second.jar, third.jar

Is it possible at all?

What is the cause of these maybe strange requirements? I'm going to use ServiceLoader which requires jar(s) with META-INF/service/ProcessorProvider file. But this would be solved with http://metainf-services.kohsuke.org/

Fortyrunner
  • 12,702
  • 4
  • 31
  • 54
LancerX
  • 1,211
  • 7
  • 23
  • 40
  • I see why you want a jar per package but why can't you create a module for each jar you want in this case? – Daniel Kaplan Oct 25 '13 at 21:03
  • What do you mean "create a module for each jar"? maven module? – LancerX Oct 25 '13 at 22:34
  • Yes, dynamically, if necessary. – Daniel Kaplan Oct 25 '13 at 22:46
  • 2
    +1 for turning these into separate Maven modules. I'm not sure if it's possible at all what you actually asked, nor should you care. Maven is about *convention over configuration*, and you're trying to swim upstream. As a rule of thumb, you should create as many modules as needed to keep functional areas separated and (this applies to you) to be able to independently deploy your units. – Sander Verhagen Oct 26 '13 at 18:53

0 Answers0