1

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

父级
|- 基础
|- 基础阴影

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

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

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

这是我的base-shadedPOM 的插件配置。不好意思说了这么多,最后还是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>
4

1 回答 1

0

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

于 2014-07-03T11:33:17.643 回答