我只是想将一些文件复制到一些目录中,并使用这个插件,因为我被告知它很方便。但是,每当我尝试mvn install
时,插件会以某种方式尝试遍历我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>
这是我的 asssembly.xml
,我指定要复制的内容:
<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>install</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>project.release/template</directory>
<outputDirectory>project.release/install</outputDirectory>
<lineEnding>unix</lineEnding>
<filtered>true</filtered>
<includes>
<include>run.all.sh</include>
<include>kill.all.sh</include>
<include>packlogs.sh</include>
</includes>
<excludes>
<exclude>config.properties</exclude>
<exclude>run.all.ant</exclude>
<exclude>run.ant</exclude>
<exclude>packlogs.sh</exclude>
<exclude>install.sh</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>
鉴于此,为什么插件会尝试为每个模块执行此操作?我只是希望它发生在一个名为project.release的模块中,而这就是它。我将pom.xml
和assembly.xml
放在父目录中,以供参考。
更新:对于那些想要查看我的项目层次结构的人,这是我的主人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>
答案 0 :(得分:1)
鉴于此,为什么插件会尝试为每个人执行此操作 模块?
因为这是多模块项目的本质。
我只想让它发生在一个叫做project.release的模块上 那就是它。我将我的pom.xml和assembly.xml都放到了父级 目录,供您参考。
我提供一些提示,而不是一个完整的解决方案。
project.release
的附加模块。将其添加到根POM中的<modules>
元素。订单无关紧要project.release
project.release
的POM中,根据需要将依赖项添加到其他模块。project.release
文件夹中,将程序集描述符放在src/main/assembly
中。描述符中的目录条目应该相对于project.release