maven assembly插件在每个模块上循环,而没有被告知这样做

maven assembly插件在每个模块上循环,而没有被告知这样做,maven,maven-assembly-plugin,Maven,Maven Assembly Plugin,我只是尝试将一些文件复制到一些目录中,并使用这个插件,因为我被告知它很方便。但是,每当我尝试执行mvn安装时,插件都会尝试在我的pom.xml中的每个模块上循环(我从未要求它执行此类操作),并尝试执行一些操作,然后给出以下错误: Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single (make-install-assembly) on project untoldProject Faile

我只是尝试将一些文件复制到一些目录中,并使用这个插件,因为我被告知它很方便。但是,每当我尝试执行
mvn安装时,插件都会尝试在我的
pom.xml
中的每个模块上循环(我从未要求它执行此类操作),并尝试执行一些操作,然后给出以下错误:

Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single (make-install-assembly) on project untoldProject Failed to create assembly: Error creating assembly archive install: You must set at least one file.
我希望这个插件只在某些模块(以及不是模块的文件夹)上运行,我已经在我的汇编文件的路径中指定了这些模块。所以我不知道为什么插件会尝试对每个模块执行此操作

下面是我使用插件的
pom.xml

<!-- This plugin is used to copy the necessary files to project.release/install folder -->
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.6</version>
          <executions>
            <execution>
              <id>make-install-assembly</id>
              <phase>package</phase>
              <goals>
                <goal>single</goal>
              </goals>
              <inherited>true</inherited>
              <configuration>
                <descriptors>
                  <descriptor>assembly.xml</descriptor>
                </descriptors>
                <appendAssemblyId>false</appendAssemblyId>
                <attach>true</attach>
              </configuration>
            </execution>
          </executions>
        </plugin>
既然如此,为什么插件会尝试对每个模块执行此操作?我只希望它发生在一个名为project.release的模块上,就这样。我将我的
pom.xml
assembly.xml
都放在父目录中,供您参考

更新:对于那些想查看我的项目层次结构的人,这里是我的master
pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>runtime_project</groupId>
   <artifactId>runtime_project.master</artifactId>
   <version>1.0.0-SNAPSHOT</version>
   <packaging>pom</packaging>
   <properties>
      <jdk.version>1.8</jdk.version>
   </properties>
   <modules>
      <module>project.messages</module>
      <module>project.base</module>
      <module>project.logging</module>
      <module>project.mission.launch</module>
      <module>project.mission.detach</module>
      <module>project.settingsStore</module>
   </modules>
   <build>
      <sourceDirectory>src/</sourceDirectory>
      <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
               <source>${jdk.version}</source>
               <target>${jdk.version}</target>
            </configuration>
        </plugin>  

        <!-- This plugin is used to delete the contents of the project.release/install folder-->
        <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
                <execution>
                    <id>auto-clean</id>
                    <phase>initialize</phase>
                    <goals>
                      <goal>clean</goal>
                    </goals>
                </execution>
           </executions>
            <configuration>
                <verbose>true</verbose>
                <excludeDefaultDirectories>true</excludeDefaultDirectories>
                <filesets>
                  <fileset>
                    <directory>project.release/install</directory>
                    <followSymlinks>false</followSymlinks>
                    <useDefaultExcludes>true</useDefaultExcludes>
                    <includes>
                      <include>**/*</include>
                    </includes>
                  </fileset>
                </filesets>
            </configuration>
        </plugin>   
        <!-- This plugin is used to copy the necessary files to project.release/install folder -->
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.6</version>
          <executions>
            <execution>
              <id>make-install-assembly</id>
              <phase>package</phase>
              <goals>
                <goal>single</goal>
              </goals>
              <inherited>true</inherited>
              <configuration>
                <descriptors>
                  <descriptor>deploy.xml</descriptor>
                </descriptors>
                <appendAssemblyId>false</appendAssemblyId>
                <attach>true</attach>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
   </build>
</project>

4.0.0
运行时项目
运行时_project.master
1.0.0-SNAPSHOT
聚甲醛
1.8
project.messages
project.base
project.logging
项目、任务、发射
project.mission.detach
project.settingsStore
src/
maven编译器插件
3.2
${jdk.version}
${jdk.version}
maven清洁插件
3.0.0
自动清洗
初始化
清洁的
真的
真的
project.release/install
假的
真的
**/*
maven汇编插件
2.6
制作安装组件
包裹
单一的
真的
deploy.xml
假的
真的
既然如此,为什么插件每次都会尝试执行此操作 模块

因为这是多模块项目的本质

我只希望它发生在一个名为project.release的模块上,然后 就这样。我将pom.xml和assembly.xml都放在父对象中 目录,供您参考

我给出了一些提示,但不是一个完整的解决方案

  • 创建一个名为
    project.release
    的附加模块。将其添加到根POM中的
    元素。顺序不重要
  • 将maven assembly插件的插件条目从根POM移动到
    project.release的POM
  • project.release
    的POM中,根据需要向其他模块添加依赖项
  • project.release
    文件夹中,将程序集描述符放置在
    src/main/assembly
    中。描述符中的目录项应与
    project.release的模块根相对

  • @Ulrich请再检查一次,这足够了还是您需要更多?好的。第一:maven多模块项目的本质是在根POM的
    中定义的插件在所有模块上执行。第二:您提到了一个名为
    project.release
    的模块,但它不包括在您的模块列表中。第一点:如何使它仅对某些特定模块执行,而不是对所有模块执行?第二:它只是一个文件夹(抱歉,它不是一个带有
    pom.xml
    的模块),我想从中复制文件。它必须是一个带有
    pom.xml
    的模块吗?如果您需要更多信息,请告诉我。因此,为了让这个插件运行,操作文件夹应该是模块的根文件夹,是这样吗?我们的共识是,我们不能使用它从主POM执行简单的文件夹/文件操作。@Schütze correct。如果德语不是问题,请参阅Martin Spiller,“Maven 3-Konfigurationsmanagement mit Java”,顺便提一下,我注意到了,但您知道为什么它会将文件复制到
    target
    文件夹中,并留下类似
    [INFO]将文件复制到~/workspace\u runtime\u project/project.release/target/project.release-1.0.0[警告]程序集文件:~/workspace\u runtime\u project/project.release/target/project.release-1.0.0不是常规文件(可能是目录)。无法将其附加到项目生成以进行安装或部署。
    <?xml version="1.0" encoding="UTF-8"?>
    <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/xsd/maven-4.0.0.xsd">
       <modelVersion>4.0.0</modelVersion>
       <groupId>runtime_project</groupId>
       <artifactId>runtime_project.master</artifactId>
       <version>1.0.0-SNAPSHOT</version>
       <packaging>pom</packaging>
       <properties>
          <jdk.version>1.8</jdk.version>
       </properties>
       <modules>
          <module>project.messages</module>
          <module>project.base</module>
          <module>project.logging</module>
          <module>project.mission.launch</module>
          <module>project.mission.detach</module>
          <module>project.settingsStore</module>
       </modules>
       <build>
          <sourceDirectory>src/</sourceDirectory>
          <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                   <source>${jdk.version}</source>
                   <target>${jdk.version}</target>
                </configuration>
            </plugin>  
    
            <!-- This plugin is used to delete the contents of the project.release/install folder-->
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>auto-clean</id>
                        <phase>initialize</phase>
                        <goals>
                          <goal>clean</goal>
                        </goals>
                    </execution>
               </executions>
                <configuration>
                    <verbose>true</verbose>
                    <excludeDefaultDirectories>true</excludeDefaultDirectories>
                    <filesets>
                      <fileset>
                        <directory>project.release/install</directory>
                        <followSymlinks>false</followSymlinks>
                        <useDefaultExcludes>true</useDefaultExcludes>
                        <includes>
                          <include>**/*</include>
                        </includes>
                      </fileset>
                    </filesets>
                </configuration>
            </plugin>   
            <!-- This plugin is used to copy the necessary files to project.release/install folder -->
            <plugin>
              <artifactId>maven-assembly-plugin</artifactId>
              <version>2.6</version>
              <executions>
                <execution>
                  <id>make-install-assembly</id>
                  <phase>package</phase>
                  <goals>
                    <goal>single</goal>
                  </goals>
                  <inherited>true</inherited>
                  <configuration>
                    <descriptors>
                      <descriptor>deploy.xml</descriptor>
                    </descriptors>
                    <appendAssemblyId>false</appendAssemblyId>
                    <attach>true</attach>
                  </configuration>
                </execution>
              </executions>
            </plugin>
          </plugins>
       </build>
    </project>