日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

创建Maven源代码和Javadoc工件

發布時間:2023/12/3 java 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 创建Maven源代码和Javadoc工件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

許多人都知道Maven源代碼和Javadoc工件,但是不知道為什么要創建它們。 我肯定在這個陣營中–我可以理解為什么人們想要此信息,但是由于要手動導航Maven存儲庫,因此獲取信息似乎相對效率較低。

然后我被線索棒擊中。

這些工件由IDE而非人員使用。 如果您使用的是Maven依賴項,那么IDE足夠聰明,可以知道如何查找這些工件。 當您單步調試器中的代碼時,將使用源工件-您不再需要將源代碼顯式綁定到IDE中的庫。 javadoc工件用于編輯器中的自動完成和上下文相關幫助。

這些都不是必需的-多年以來我一直很高興使用'vi'-但是當您大多數都知道自己需要什么但不確定細節時,它肯定會提高您的生產率。

源工件

源工件最容易創建。 添加一個將作為標準構建的一部分自動運行的插件,您已完成。 構建花費的時間稍長一些,但您只需要創建幾個目錄的歸檔文件就不必擔心了。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><build><plugins><!-- create source jar --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-source-plugin</artifactId><version>2.1.1</version><executions><execution><id>attach-sources</id><phase>verify</phase><goals><!-- produce source artifact for project main sources --><goal>jar-no-fork</goal><!-- produce test source artifact for project test sources --><goal>test-jar-no-fork</goal></goals></execution></executions></plugin></plugins></build> </project>

Javadoc工件

Javadoc工件要復雜一些,因為您可能希望同時創建一個對人類友好的網站。 根據我的經驗,最大的問題是外部類是不透明的,因為它花費了大量的精力來創建必要的鏈接。 現在,maven插件會為我們解決這個問題!

構建該工件需要花費大量時間,因此您可能不想每次都這樣做。 有兩種方法–明確指定Maven目標或將其綁定到自定義配置文件,例如'javadoc'。 以下配置使用自定義配置文件。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><profiles><!-- create javadoc --><profile><id>javadoc</id><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-javadoc-plugin</artifactId><version>2.9.1</version><configuration><detectLinks /><includeDependencySources>true</includeDependencySources><dependencySourceIncludes><dependencySourceInclude>com.invariantproperties.project.student:*</dependencySourceInclude></dependencySourceIncludes><!-- heavily used dependencies --><links><link>http://docs.oracle.com/javase/7/docs/api/</link><link>http://docs.oracle.com/javaee/6/api</link><link>http://docs.spring.io/spring/docs/current/javadoc-api/</link><link>http://docs.spring.io/spring-data/commons/docs/1.6.2.RELEASE/api/</link><link>http://docs.spring.io/spring-data/jpa/docs/1.4.3.RELEASE/api/</link><link>http://docs.spring.io/spring-data/data-jpa/docs/1.4.3.RELEASE/api/</link><link>https://jersey.java.net/apidocs/1.17/jersey/</link><link>http://hamcrest.org/JavaHamcrest/javadoc/1.3/</link><link>http://eclipse.org/aspectj/doc/released/runtime-api/</link><link>http://eclipse.org/aspectj/doc/released/weaver-api</link><link>http://tapestry.apache.org/5.3.7/apidocs/</link></links></configuration><executions><execution><id>aggregate</id><!-- <phase>site</phase> --><phase>package</phase><goals><goal>aggregate</goal><goal>jar</goal></goals></execution></executions></plugin></plugins></build><reporting><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-javadoc-plugin</artifactId><version>2.9.1</version><configuration><!-- Default configuration for all reports --></configuration><reportSets><reportSet><id>non-aggregate</id><configuration><!-- Specific configuration for the non aggregate report --></configuration><reports><report>javadoc</report></reports></reportSet><reportSet><id>aggregate</id><configuration><!-- Specific configuration for the aggregate report --></configuration><reports><report>aggregate</report></reports></reportSet></reportSets></plugin></plugins></reporting></profile></profiles> </project>

包信息.java

最后,每個軟件包都應該具有package-info.java文件。 這將替換舊的package-info.html文件,但由于它允許使用類注釋,因此是一個改進。 (由于它是無效的類名,因此不會被編譯。)

我發現包括指向資源的鏈接非常有幫助,這些鏈接可以幫助我理解類的外觀。 例如,“學生”項目中的元數據包包含指向我的博客文章,我認為有用的其他博客文章甚至適當的Oracle教程的鏈接。 在公司中,這些可能是指向Wiki頁面的鏈接。

/** * Classes that support JPA Criteria Queries for persistent entities.* * @see <a href="http://invariantproperties.com/2013/12/19/project-student-persistence-with-spring-data/">Project Student: Persistence with Spring Data</a>* @see <a href="http://invariantproperties.com/2013/12/29/project-student-jpa-criteria-queries/">Project Student: JPA Criteria Queries</a>* @see <a href="http://www.petrikainulainen.net/programming/spring-framework/spring-data-jpa-tutorial-part-four-jpa-criteria-queries/">Spring Data JPA Tutorial Part Four: JPA Criteria Queries</a> [www.petrikainulainen.net]* @see <a href="http://docs.oracle.com/javaee/6/tutorial/doc/gjitv.html">JEE Tutorial</a> * * @author Bear Giles <bgiles@coyotesong.com>*/ package com.invariantproperties.project.student.metamodel;

源代碼

  • 源代碼位于https://github.com/beargiles/project-student [github]和http://beargiles.github.io/project-student/ [github頁面]。

參考: Invariant Properties博客上的JCG合作伙伴 Bear Giles 創建Maven源代碼和Javadoc工件 。

翻譯自: https://www.javacodegeeks.com/2014/02/creating-maven-source-and-javadoc-artifacts.html

總結

以上是生活随笔為你收集整理的创建Maven源代码和Javadoc工件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。