如何在部署时单独打包源文档jar?

时间:2015-09-06 20:35:28

标签: maven

我注意到大多数发行版打包了他们的工件,如

my-1.0.jar
my-1.0-sources.jar
my-1.0-documentation.jar

当我进行部署时,我目前只获得my-1.0.jar如何将源和文档生成为单独的jar?

1 个答案:

答案 0 :(得分:0)

我将maven-source-pluginmaven-javadoc-plugin添加到了我的父pom.xml的build.plugins部分。值得一提的是,我原本不小心将它们放在pluginManagement中,当然只有当我手动将它们包含在孩子身上时才会有效。

<build>
<plugins>
  <plugin>
    <artifactId>maven-source-plugin</artifactId>
    <executions>
      <execution>
        <id>attach-sources</id>
        <goals>
          <goal>jar</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
  <plugin>
    <artifactId>maven-javadoc-plugin</artifactId>
    <executions>
      <execution>
        <id>attach-javadocs</id>
        <goals>
          <goal>jar</goal>
        </goals>
      </execution>
    </executions>