Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the correct place to store assembly files in Maven?

In Maven's assembly guide (https://maven.apache.org/guides/mini/guide-assemblies.html), it is stated:

You'll notice that the assembly descriptor is located in ${project.basedir}/src/assembly which is the standard location for assembly descriptors.

But in the maven assembly plugin page (https://maven.apache.org/plugins/maven-assembly-plugin/examples/sharing-descriptors.html) it says:

Note: Your assembly descriptors must be in the directory /src/main/resources/assemblies to be available to the Assembly Plugin.

Are them 2 different things? Is any of them outdated?

like image 841
Whimusical Avatar asked Dec 24 '22 07:12

Whimusical


1 Answers

It is the difference between using assemblies and making them available to other projects.

The idea of putting assembly descriptors in src/main/resources/assemblies is to make them available to other modules or projects. You create a project, say my-assembly-descriptor, with one or more assembly descriptors in src/main/resources/assemblies. Then in a different project that you want to use the descriptor in you configure the assembly plugin to use my-assembly-descriptor as a dependency.

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.6</version>
    <dependencies>
      <dependency>
        <groupId>your.group.id</groupId>
        <artifactId>my-assembly-descriptor</artifactId>
        <version>1.0-SNAPSHOT</version>
      </dependency>
    </dependencies>
    <executions>
      ...
    </executions>
  </plugin>

The assembly plugin finds your descriptors on its classpath and can use them.

The assembly descriptors placed in src/assembly can be used to assemble artifacts but the can't be reused in other modules or projects.

like image 143
Matt Champion Avatar answered Jan 05 '23 01:01

Matt Champion