Maven Shade和Clover不在mvn网站工作

时间:2014-09-24 04:15:59

标签: maven maven-2 maven-shade-plugin clover

我有父项目和一些子项目。有些孩子彼此之间有依赖关系。例如:parent - >孩子1,父母 - >孩子2,孩子1 - >孩子2(Child1依赖孩子2) 这是我在我的poms中所做的事情:

  <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-shade-plugin</artifactId>
      <version>2.3</version>
  </plugin>
        <plugin>
    <groupId>com.atlassian.maven.plugins</groupId>
    <artifactId>maven-clover2-plugin</artifactId>
    <version>3.1.10.1</version>
    <configuration>
      <jdk>${compile.source}</jdk>
      <generateHtml>true</generateHtml>
      <generatePdf>false</generatePdf>
      <generateXml>true</generateXml>
    </configuration>
    <executions>
      <execution>
        <phase>pre-site</phase>
        <goals>
          <goal>instrument</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
  <reportPlugins>
              <plugin>
          <groupId>com.atlassian.maven.plugins</groupId>
          <artifactId>maven-clover2-plugin</artifactId>
          <version>3.1.10.1</version>
          <configuration>
            <jdk>${compile.source}</jdk>
            <generateHtml>true</generateHtml>
            <generatePdf>false</generatePdf>
            <generateXml>true</generateXml>
          </configuration>
        </plugin>
  </reportPlugins>

Child pom看起来像这样:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <createDependencyReducedPom>false</createDependencyReducedPom>
      <filters>
        <filter>
          <artifact>*:*</artifact>
          <excludes>
            <exclude>META-INF/*.SF</exclude>
            <exclude>META-INF/*.DSA</exclude>
            <exclude>META-INF/*.RSA</exclude>
            <exclude>META-INF/LICENSE</exclude>
            <exclude>config.properties</exclude>
          </excludes>
        </filter>
      </filters>
      <transformers>
        <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
          <mainClass>com.cerner.pophealth.program.runtime.pipeline.Main</mainClass>
        </transformer>
      </transformers>
    </configuration>
  </plugin>

我面临的问题是mvm site-deploy因以下错误而失败:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:1.7.1:shade (default) on project foo: Error creating shaded jar: error in opening zip file /foo/bar/target/classes -> [Help 1]

mvn site-deploy从foo-parent级别运行。

我注意到即使网站运行时三叶草也试图在目标/三叶草/文件夹中创建着色jar。

感谢任何帮助。

2 个答案:

答案 0 :(得分:0)

使用配置文件启用/禁用着色插件。

   <profiles>
<profile>
  <id>shade</id>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>

答案 1 :(得分:0)

maven-clover2-plugin有两个可用于源代码检测的目标:

clover2:instrument 目标在Maven中建立并行构建生命周期以便检测源。这意味着源根(如 src / main / java src / test / java )以及输出文件夹(如 target / classes )被重定向到 target / clover 目录。在某些情况下,这样的文件夹重定向可能会导致其他Maven插件运行出现问题。

clover2:setup 目标在Maven的默认构建生命周期中执行代码检测。这意味着输出文件夹保持不变(例如,已检测的类放入 target / classes )。

我建议尝试clover2:设置clover2的目标:仪器一。但是,请记住,拨打&#39; clover2:setup&#39;与“安装”一起安装&#39;或者“部署”&#39;将导致将安装已检测版本的JAR。除非这是一个理想的行动,否则