我将 Maven 3.x 与maven-assembly-plugin
. 当我构建我的项目时,我收到以下消息。
引起:org.apache.maven.lifecycle.LifecycleExecutionException: 未能执行目标 org.apache.maven.plugins:maven-assembly-plugin:2.2.1:single (tarball) 在项目 [ProjectName] 上:无法创建程序集: 将文件 'io.something:artifactid:jar:1.5.0' 添加到存档时出错: /path/to/project/target/scoverage-classes 不是文件。
我正在使用scoverage进行 Scala 编译和测试,但我不知道为什么maven-assembly-plugin
要包含该子目录。
该项目相当复杂(“高度嵌套”的maven项目),但我会发布相关部分。在构建插件部分。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<tarLongFileMode>gnu</tarLongFileMode>
<descriptors>
<descriptor>src/main/assembly/job.xml</descriptor>
<descriptor>src/main/assembly/src.xml</descriptor>
</descriptors>
<archive>
<index>true</index>
</archive>
</configuration>
<executions>
<execution>
<id>tarball</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>1.3.0</version>
</plugin>
在报告插件部分。
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>1.3.0</version>
<configuration>
<scalaVersion>2.10.4</scalaVersion>
<highlighting>true</highlighting>
<aggregate>true</aggregate>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
程序集job.xml
描述符如下。我怀疑这个描述符是罪魁祸首(有target
引用)。
<assembly
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns = "http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xsi:schemaLocation = "http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>job</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<unpack>false</unpack>
<scope>runtime</scope>
<outputDirectory>target</outputDirectory>
</dependencySet>
<dependencySet>
<unpack>false</unpack>
<scope>system</scope>
<outputDirectory>target</outputDirectory>
<excludes>
<exclude>${artifact.groupId}:${artifact.artifactId}</exclude>
</excludes>
</dependencySet>
</dependencySets>
</assembly>
程序集src.xml
描述符如下。
<assembly
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns = "http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xsi:schemaLocation = "http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>dependencies</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
</assembly>