0

I'm working on a maven web project. I've created a different maven project containing a couple of applets i want to use in the main project. This project is added as a dependency to the main project.

In my Applet-project POM,

I've added a plugin for creating a jar with dependencies,

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.3</version>
    <configuration>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
    </configuration>
    <executions>
      <execution>
        <id>make-assembly</id> <!-- this is used for inheritance merges -->
        <phase>package</phase> <!-- bind to the packaging phase -->
        <goals>
          <goal>single</goal>
        </goals>
      </execution>
    </executions>
</plugin>

I've also signed the uberjar to avoid some security restrictions.

<plugin>
    <artifactId>maven-jar-plugin</artifactId>
    <executions>
      <execution>
        <goals>
          <goal>sign</goal>
        </goals>
      </execution>
      <execution>
        <id>make-assembly</id>
        <phase>package</phase>
        <goals>
          <goal>sign</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <jarPath>${project.build.directory}/${project.build.FinalName}-${project.packaging}-with-dependencies.${project.packaging}</jarPath>
      <keystore>${basedir}/signstore.jks</keystore>
      <alias>signstore</alias>
      <storepass>signstore</storepass>
    </configuration>
  </plugin>

I now want to copy the signed uberjar to the webapp folder whenever i build the main project, so my HTML files can use it.

Is this possible? I've only managed to copy the jar without the dependencies.

Roman C
  • 49,761
  • 33
  • 66
  • 176
  • If you want to copy this jar i would take a deep look into the maven-dependency-plugin to use it for copying. I'm not sure if this will fit your requirements. – khmarbaise May 06 '12 at 13:12
  • Well, I've looked into that, but I don't how to select the jar with the dependencies instead of the standard jar. – user1337157 May 06 '12 at 14:03
  • Specify the jar-with-the-dependencies as a `dependency` in your main project. That will make available this jar for copying. – Raghuram May 06 '12 at 17:39

1 Answers1

0

I had the same problem with jar-with-dependencies, it is much more easy to build it using maven shade plugin:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>your.main.Class</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

This was working in no time after hours fighting with the maven jar plugin. It also solves conflicts between dependencies for you

Eugenio Cuevas
  • 10,858
  • 3
  • 29
  • 51