Maven build plugin executed on child projects

I have the following problem. I have a multi-module project. I want to run the maven-assembly plugin on a toplevel pom, which is also the parent pom for its modules. I want the plugin to execute only on the top level pom. He is currently trying to execute on all submodules. I do not want this, because I just need to capture all the sources from all the modules and submodules in one place (the target directory is toplevel.)

Here is my descriptor:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>src</id>
<formats>
    <format>zip</format>
</formats>
<moduleSets>
    <moduleSet>
        <includeSubModules>true</includeSubModules>
        <sources>
            <useDefaultExcludes>true</useDefaultExcludes>
            <includeModuleDirectory>false</includeModuleDirectory>
            <fileSets>
                <fileSet>
                    <outputDirectory>/</outputDirectory>
                    <useDefaultExcludes>true</useDefaultExcludes>
                    <includes>
                        <include>src/main/**</include>
                        <include>src/test/**</include>
                        <include>target/classes/**</include>
                    </includes>
                </fileSet>
            </fileSets>
        </sources>
    </moduleSet>
</moduleSets>

The pom file is as follows:

<?xml version="1.0"?>
<project
      xmlns="http://maven.apache.org/POM/4.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
      >

<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>myid</groupId>
    <artifactId>myartid</artifactId>
    <version>1.1</version>
</parent>
<groupId>myid2</groupId>
<artifactId>TopLevelBuild</artifactId>
<packaging>pom</packaging>
<version>5.5-SNAPSHOT</version>
<name>Some Application</name>
<modules>
    <module>1</module>
    <module>2</module>
    <module>3</module>
    <module>4</module>
    <module>5</module>
    <module>6</module>
</modules>
<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit-dep</artifactId>
        <version>4.8.2</version>
        <scope>compile</scope>
    </dependency>
</dependencies>
</project>

Parent pom just contains some dependencies that I want to inherit in all modules. Submodules have the current pom as the parent. Now, if I run:

mvn assembly: single -Ddescriptor = somedes.xml

, . , , , . ?

...
[INFO] Processing sources for module project: LAST MODULE
[INFO] Building zip: ..../target/TopLevelBuild-5.5-SNAPSHOT-src.zip
[INFO] ------------------------------------------------------------------------
[INFO] Building deploy
[INFO]    task-segment: [assembly:single]
[INFO] ------------------------------------------------------------------------
[INFO] [assembly:single {execution: default-cli}]
[INFO] Processing sources for module project: module1-submodule1:jar:5.5-SNAPSHOT
[INFO] Processing sources for module project: module1-submodule1:jar:5.5-SNAPSHOT
[INFO] Building zip: .../module1/target/module1-5.5-SNAPSHOT-src.zip
[INFO] ------------------------------------------------------------------------
[INFO] Building module1
[INFO]    task-segment: [assembly:single]
[INFO] ------------------------------------------------------------------------
[INFO] [assembly:single {execution: default-cli}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to create assembly: Error creating assembly archive src: You must set at least one file.

:

-Dexecution.inherited = false

.

-Dassembly.ignoreMissingDescriptor = true

. ?

+3
5

-Dassembly.runOnlyAtExecutionRoot =

, , .

+2

maven-assembly-plugin pom.

<runOnlyAtExecutionRoot>true</runOnlyAtExecutionRoot>
+5

, param "-Dexecution.inherited=false".

I have defined non-inheritance on the xml tag <inherited>false</inherited>in the pom.xml of the child module, it works.

+2
source

I don’t know if I understand the situation. But to disable plugin execution, try the following:

        <!-- Don't run the reporting tool in submodule. -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions combine.self="override" combine.>
                <execution><id>reporting</id><phase>none</phase></execution>
            </executions>
        </plugin>

You need to know the execution identifier from the parent and put it in this fragment ....

Here is a good clear explanation: http://www.sonatype.com/people/2011/01/maven-how-to-merging-plugin-configuration-in-complex-projects/

NTN

0
source

You can disable maven-assembly-pluginmaven none in phase .

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-assembly-plugin</artifactId>
  <version>2.5</version>
  <executions>
    <execution>
      <phase>none</phase>
      <goals>
        <goal>single</goal>
      </goals>
    </execution>
  </executions>
</plugin>
0
source

All Articles