Adding another project's jar as a resource using Maven

java, maven

Solution

This task is calling for `maven-assembly-plgin` or `maven-dependency-plugin`

(I expect that updater is also maven project) this shoudl be proper configuration for maven-dependency-plugin [I did not test this, you might also need to put updater to project depndencies]

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.7</version>
        <executions>
          <execution>
            <id>copy</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>company.com.project</groupId>
                  <artifactId>Updater</artifactId>
                  <version>0.0.1-SNAPSHOT</version>
                  <type>jar</type>
                  <outputDirectory>${project.build.outputDirectory}/classes</outputDirectory>
                  <destFileName>updater.jar</destFileName>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

Problem

Within my project I have a sub-project auto-updater. Basically a jar file that is extracted and run when an update is available. Is it possible to compile the sub-project, then place the outputted jar as a `generated-resource` so that the `updater.jar` is included in the final jar such as: ``` Project-1.0.jar |-updater.jar |-Main.class |-B.class ``` Thanks in advance for any help(I'm new to Maven)

Original source