我知道您使用程序集插件执行此操作,并且我尝试了许多描述符但它们无法正常工作。我无法理解错误信息的含义。
项目架构:
---sti (parent project containing a pom.xml)
-----sti-any23
-----sti-common-util
-----sti-kbsearch
-----sti-websearch
-----sti-main
sti 是聚合器项目。模块 sti-main 取决于所有其他四个模块。
父项目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>....</groupId>
<artifactId>sti</artifactId>
<version>1.0alpha</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven-install-plugin.version>2.5.2</maven-install-plugin.version>
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
<maven-source-plugin.version>2.2.1</maven-source-plugin.version>
<exec-maven-plugin.version>1.4.0</exec-maven-plugin.version>
<maven-shade-plugin.version>2.3</maven-shade-plugin.version>
</properties>
<modules>
<module>sti-any23</module>
<module>sti-common-util</module>
<module>sti-kbsearch</module>
<module>sti-websearch</module>
<module>sti-main</module>
</modules>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
<configuration>
<mainClass/>
</configuration>
</plugin>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>config/maven-assembly/module.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
描述符&#39; config / maven-assembly / module.xml&#39;看起来像:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<!-- TODO: a jarjar format would be better -->
<id>alljars</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>true</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
</assembly>
我得到的错误:
[WARNING] Cannot include project artifact: uk.ac.shef.dcs:sti:pom:1.0alpha; it doesn't have an associated file or directory.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] sti-any23 .......................................... SUCCESS [ 1.709 s]
[INFO] sti-common-util .................................... SUCCESS [ 0.728 s]
[INFO] sti-kbsearch ....................................... SUCCESS [ 1.213 s]
[INFO] sti-websearch ...................................... SUCCESS [ 0.433 s]
[INFO] sti-main ........................................... SUCCESS [ 2.855 s]
[INFO] sti ................................................ FAILURE [ 0.389 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.839 s
[INFO] Finished at: 2016-07-26T19:50:53+01:00
[INFO] Final Memory: 75M/505M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.4:single (make-assembly) on project sti: Failed to create assembly: Error creating assembly archive alljars: You must set at least one file. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :sti
我还尝试了在stackoverflow上找到的许多其他描述符,但它们都没有工作。我想我必须有一些错误的基本概念,但我不知道它是。
请提出任何建议。感谢
答案 0 :(得分:1)
我从未见过在父项目中使用程序集插件。您的父模块为<packaging>pom</packaging>
。它的输出只是一个pom
文件。除POM之外还有任何物理伪像输出是没有意义的。
在我看来,您应该将程序集插件声明移动到子模块,并仅将其作为此子模块的一部分执行。应该将所有其他项目声明为此模块的依赖项,从这一点开始,您应该构建程序集。