views:

60

answers:

1

I have a hierarchical maven project, from which I am trying to build a native installer for several of the sub-modules. I am using my product name as a prefix: <finalName>xyz-${artifactId}</finalName> in the parent POM so that all my artifact jars have a standard naming convention.

xyz-parent
 +-- util
      +--- target/xyz-util.jar
 +-- core
      +--- target/xyz-core.jar
 +-- app1 <--- "builds an installer as part of the package phase"
      +--- target/xyz-app1.jar
 +-- app2 <--- "builds an installer as part of the package phase"
      ...

I need to materialize all the dependent jars into a directory (since inno setup knows nothing about maven). So for each submodule which is an installer I plan to use maven-assembly-plugin, then use something like the following in my inno setup:

Source: "target\pkg\lib\*.jar"; DestDir: "{app}\external";  Flags: ignoreversion;

When I run mvn clean package, I get a target/xyz-app1-bin/xyz-app1/lib directory with all of the dependent jars, however none of the jars produced by my sibling projects have their correct final names (e.g. I have util-0.0.1-SNAPSHOT.jar instead of xyz-util.jar)

This problem seems similar to this post, but I have no idea what "attach" is (perhaps deprecated).

A: 

I was unable to use finalName directly, however, I did manage to re-implement the finalName logic I wanted using dependency sets -- thus partitioning my dependencies into an external and internal set (based on the groupId):

<assembly>  
  <id>bin</id>  
  <formats>
    <format>dir</format>
  </formats>
  <dependencySets>
    <dependencySet>
      <outputDirectory>external</outputDirectory>
      <outputFileNameMapping>
        ${artifact.artifactId}.${artifact.extension}
      </outputFileNameMapping>
      <excludes>
        <exclude>com.xyz:*</exclude>
      </excludes>
    </dependencySet>

    <dependencySet>
      <outputDirectory>lib</outputDirectory>
      <outputFileNameMapping>
        xyz-${artifact.artifactId}.${artifact.extension}
      </outputFileNameMapping>
      <includes>
        <include>com.xyz:*</include>
      </includes>
    </dependencySet>

  </dependencySets>
</assembly>
Justin