如何使用maven-assembly-plugin排除某些目标输出子目录?

时间:2017-01-31 12:28:51

标签: maven maven-3 maven-assembly-plugin scoverage

我正在使用Maven 3.x和maven-assembly-plugin。当我构建我的项目时,我收到以下消息。

Caused by: org.apache.maven.lifecycle.LifecycleExecutionException: 
Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2.1:single (tarball) 
on project [ProjectName]: Failed to create assembly: 
Error adding file 'io.something:artifactid:jar:1.5.0' to archive: 
/path/to/project/target/scoverage-classes isn't a file.

我正在使用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>

在reporting-plugins部分。

<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>

0 个答案:

没有答案