Maven pom.xml - Project Aggregation

We have .pom aggregation, which includes several separate modules, similar to the Maven Documentation :

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1</version>
  <packaging>pom</packaging>

  <modules>
    <module>my-module</module>
    <module>my-module-2</module>
  </modules>
</project>

Is there a way to get artifacts from collectors (.JAR files) from these two modules into a common "dist" directory after assembly? I did not want to configure the output directory for individual modules from "my-module / target", since they can also be created separately.

I am new to Maven, so I'm sure there is an easy way to do this. I'm missing.

+3
source share
4 answers

(.JAR ) "dist" ?

Maven Assembly Plugin , . , . dir moduleSets, .

8.2. Maven 8.5.5. sectionSets .

+2

, :

        <plugin>
            <artifactId>maven-resources-plugin</artifactId>

            <executions>
                <execution>
                    <id>copy-jars</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <resources>
                            <resource>
                                <directory>../src/my-module/target</directory>
                                <includes>
                                    <include>**/my-module*.jar</include>
                                </includes>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

, Assembly .

+1

, maven

0
source

As @Pangea said, the build plugin will do this. Just run the assembly:assemblytarget with the appropriate parameter set outputDirectory.

Additional information at http://maven.apache.org/plugins/maven-assembly-plugin/assembly-mojo.html

0
source

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


All Articles