You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Keith Beattie <ks...@gmail.com> on 2007/06/27 09:18:59 UTC

Q: assembling multi-module where one module has multiple jar artifacts

Hello all,

I've got a multi-module project using the assembly plugin to collect all the
resulting jar files into a dir with their dependencies.  One of the modules
generates several jar files and does so using the jar and build-helper
plugins.  Thanks to this list, I've gotten this all working, but in such a
clumsy way, it seems like I'm misunderstanding how the plugins I'm using
were intended to be used.  So, I'd like to ask here if there is a better way
to do it.

My 'trigger' project is the one which generates multiple jar files, this is
done in the trigger/pom.xml using a multiple execution elements under the
jar plugin distinguishing each with a classifier like so:

          <execution>
            <id>global-trig</id>
            <goals>
              <goal>jar</goal>
            </goals>
            <configuration>
              <classifier>gtrig</classifier>
              <archive>
                <manifest>
                  <mainClass>
icecube.daq.trigger.component.GlobalTriggerComponent</mainClass>
                  <addClasspath>true</addClasspath>
                </manifest>
              </archive>
            </configuration>
          </execution>

These vary in their id, classifier and mainClass.

Then I use at the bottom of this trigger/pom.xml file the build-helper
plugin to attach these as artifacts to the project by repeating artifact
elements:

                <artifact>
                  <classifier>gtrig</classifier>
                  <file>${project.build.directory}/${artifactId}-${version}-
gtrig.jar</file>
                  <type>jar</type>
                </artifact>

Again these differ by classifier.

Now in the top-level, I'm using a src/assembly/dist.xml to assembly a dist
dir.  This file starts off with the usual moduleSets including each module,
but for the trigger, the only way I could get it to work (and pick up all
the extra "-gtrig.jar" files) was to add repeating moduleSet elements like
this:

    <moduleSet>
      <includes>
        <include>edu.wisc.icecube:trigger:*:*</include>
      </includes>
      <binaries>
        <includeDependencies>false</includeDependencies>
        <attachmentClassifier>gtrig</attachmentClassifier>
        <outputDirectory></outputDirectory>

<outputFileNameMapping>${artifactId}-${version}-${classifier}.${extension}</outputFileNameMapping>
        <unpack>false</unpack>
      </binaries>
    </moduleSet>

one for each of the extra jar files the trigger project generates.

I would like to cut down on the duplication in at least the dist.xml file.
My first attempt at having only one moduleSet with "
edu.wisc.icecube:trigger:*:*" as the sole include for the trigger module
didn't work.

Actually when writing this just now, I noticed that I left off some of the
trigger artifacts in the build-helper plugin in the trigger/pom.xml, meaning
the the assembly distribution must *not* be using that list to pull in the
artifacts.  Indeed removing the build-helper plugin entirely doesn't break
anything here. Though with it in place and running mvn -X it certainly
appears that the build-helper is indeed attaching them as artifacts.  This
is must be where at least part of my misunderstanding lies...

Finally, there is the following warning shown when the assembly is done:
  [WARNING] NOTE: Currently, inclusion of module dependencies may produce
unpredictable results if a version conflict occurs.
Is this related?  And/or when might I know if a version conflict is
occurring?

TIA for any suggestions, pointers, etc.
ksb