maven打包源代码sources.jar和javadoc.jar帮助文档

maven中如何打包源代码 *-sources.jar

方式一 :   命令行方式

进入cmd命令行,进入项目工程pom.xml所在路径目录,运行mvn source:jar 和 mvn javadoc:jar,此方法只生成到项目目录下,不拷贝到仓库。


 

方式二: 使用IDE,如eclipse

  右键点击项目中的 pom.xml 文件,“ Run as ”,选择“ Run Configurations... ”,如下图 

结果 


 

发布到本地Maven仓库中,在pom.xml添加如下:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-source-plugin</artifactId>
      <version>2.1.2</version>
      <executions>
        <execution>
          <id>attach-sources</id>
          <phase>verify</phase>
          <goals>
            <goal>jar-no-fork</goal>
          </goals>
        </execution>
      </executions>
    </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.6.1</version>
        <configuration>
        </configuration>
        <executions>
          <execution>
            <id>attach-javadoc</id>
            <phase>verify</phase>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

  </plugins>
</build>            

     右键点击项目中的 pom.xml 文件,“ Run as ”,选择“ Maven install ” 


 

在新的项目pom.xml中,即可使用:

<dependency>
  <groupId>org.xxxx</groupId>
  <artifactId>rfidsocket</artifactId>
  <version>1.0.0</version>
</dependency>

  

原文地址:https://www.cnblogs.com/timssd/p/5777667.html