【问题标题】:Including a synthetic file as javadoc artifact in a Maven build在 Maven 构建中包含合成文件作为 javadoc 工件
【发布时间】:2014-05-09 11:48:33
【问题描述】:

我正在使用 Maven 构建一个多模块项目,其中一个模块代表另一个模块的阴影版本:

父母
|- 基地
|- 底色

base 模块包含我所有的源文件,但我想将依赖项导入到我自己的命名空间中。这个阴影模块由我的 base-shaded 模块描述,它基本上只包含一个 POM,它配置了对 base 和 Maven Shade 插件的依赖。

这很好用。 Shade 插件包含所有依赖项并创建一个着色工件,包括一个源工件。但是,我缺少一个不是由 Shade 插件创建的 javadoc 工件。因此,我试图复制base 模块的javadoc 工件。然而,release:release 目标忽略了这些阻止我部署到 Maven Central 的工件。尽管如此,我还是设法将这些文件复制并包含在安装目标中。

有没有一种规范的方法可以在构建中包含非汇编文件?我开始认为我可能是错误的方法。

这是我的base-shaded POM 的插件配置。不好意思说了这么多,最后还是Maven XML:

    <!-- Shade dependencies -->
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-shade-plugin</artifactId>
      <version>${version.plugin.shade}</version>
      <executions>
        <execution>
          <phase>package</phase>
          <goals>
            <goal>shade</goal>
          </goals>
        <configuration>
        <shadedArtifactAttached>false</shadedArtifactAttached>
        <createDependencyReducedPom>true</createDependencyReducedPom>
        <dependencyReducedPomLocation>
          ${project.build.directory}/dependency-reduced-pom.xml
        </dependencyReducedPomLocation>
        <createSourcesJar>true</createSourcesJar>
        <shadeSourcesContent>true</shadeSourcesContent>
        <relocations>
          <relocation>
            <pattern>${shade.source}</pattern>
            <shadedPattern>${shade.target}</shadedPattern>
          </relocation>
        </relocations>
      </configuration>
    </execution>
  </executions>
</plugin>
<!-- Copy dependency version's javadoc artifacts -->
<plugin>
  <groupId>com.github.goldin</groupId>
  <artifactId>copy-maven-plugin</artifactId>
  <version>${version.plugin.copy}</version>
  <executions>
    <execution>
      <phase>package</phase>
        <goals>
          <goal>copy</goal>
        </goals>
        <configuration>
          <resources>
            <resource>
              <targetPath>${project.build.directory}</targetPath>
              <file>
                ${project.basedir}/../base/target/base-${project.version}-javadoc.jar
              </file>
              <destFileName>base-${project.version}-javadoc.jar</destFileName>
            </resource>
          <resource>
            <targetPath>${project.build.directory}</targetPath>
            <file>
              ${project.basedir}/../base/target/base-${project.version}-javadoc.jar.asc
            </file>
            <destFileName>base-shaded-${project.version}-javadoc.jar.asc</destFileName>
          </resource>
        </resources>
      </configuration>
    </execution>
  </executions>
</plugin>
<!-- Because the javadoc files are copied manually, they must be installed manually as well -->
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-install-plugin</artifactId>
  <executions>
    <execution>
      <id>install-javadoc</id>
      <phase>install</phase>
      <goals>
        <goal>install-file</goal>
      </goals>
      <configuration>
        <groupId>${project.groupId}</groupId>
        <artifactId>${project.artifactId}</artifactId>
        <version>${project.version}</version>
        <packaging>jar</packaging>
        <classifier>javadoc</classifier>
        <file>${build.directory}/base-shaded-${project.version}-javadoc.jar</file>
      </configuration>
    </execution>
    <execution>
      <id>install-javadoc-asc</id>
      <phase>install</phase>
      <goals>
        <goal>install-file</goal>
      </goals>
      <configuration>
        <groupId>${project.groupId}</groupId>
        <artifactId>${project.artifactId}</artifactId>
        <version>${project.version}</version>
        <packaging>jar.asc</packaging>
        <classifier>javadoc</classifier>
        <file>${build.directory}/base-shaded-${project.version}-javadoc.jar.asc</file>
      </configuration>
    </execution>
  </executions>
</plugin>

【问题讨论】:

    标签: java maven maven-shade-plugin


    【解决方案1】:

    当然,这个任务有一个插件,build-helper-maven-plugin

    【讨论】:

    • 这对于实现您的请求而不是简单链接的示例会更有帮助。 :(。xkcd.com/979 是相关的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-15
    • 1970-01-01
    • 2014-08-22
    • 2014-04-02
    • 1970-01-01
    • 2014-04-07
    相关资源
    最近更新 更多