How to use Maven assembly in several projects?

I have a Maven assembly that I want to use in several projects. How to reuse it without hard coding path?

+3
source share
1 answer

In the latest version of the build plugin (2.2-beta-2), you can use [general descriptor] [1]. Define a descriptor in the src / main / resources / assemblies folder of an individual project and install or expand it.

For projects that want to use a descriptor, determine the dependency on the descriptor project in the assembly plugin configuration, then refer to the assembly.

: , . , /assemblies/myassembly.xml, /myassembly.xml , magic assemblysies. .

, src/main resources, .. assemblysies/myassembly.xml not. XML.

:

<build>
  ...
  <plugins>
    ...
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <version>2.2-beta-2</version>
      <!--declare plugin has a dependency on the descriptor project -->
      <dependencies>
        <dependency>
          <groupId>your.group.id</groupId>
          <artifactId>my-assembly-descriptor</artifactId>
          <version>1.0-SNAPSHOT</version>
        </dependency>
      </dependencies>
      <executions>
        <execution>
          <id>make-assembly</id>
          <phase>package</phase>
          <goals>
            <goal>single</goal>
          </goals>
          <configuration>
            <!-- This is where we use our shared assembly descriptor -->
            <descriptors>
              <descriptor>assemblies/myassembly.xml</descriptor>
            </descriptors>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
+2

Source: https://habr.com/ru/post/1714048/


All Articles