创建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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/364662.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

JS内置方法(object)

属性 constructorprototype 实例方法 1、toString()返回当前对象的字符串形式&#xff0c;返回值为String类型。 2、toLocaleString()返回当前对象的"本地化"字符串形式&#xff0c;以便于当前环境的用户辨识和使用&#xff0c;返回值为String类型。 3、valueOf()返回…

金蝶云php webapi,K/3 Cloud Web API销售出库单PHP完整示例【分享】

按照惯例&#xff0c;先上图【销售出库单】保存&#xff0c;如图&#xff1a;已经打印出 登陆请求及登陆成功&#xff0c;保存请求及保存成功的返回信息。如下代码&#xff0c;是完全可以直接进行运行的代码&#xff0c;具体详见代码中注释。[code]//K/3 Cloud 业务站点地址$cl…

JavaFX自定义控件– Nest Thermostat第2部分

自从我开始创建Nest恒温器FX自定义控件以来&#xff0c;已经有一段时间了&#xff01; 因此&#xff0c;上次&#xff0c;如Gerrit Grunwald所建议&#xff0c;我花了一些时间用inkscape复制Nest恒温器设计&#xff0c;这是构建JavaFX版本的第一步。 今天&#xff0c;我想与大…

函数和模块的使用

函数&#xff1a; 函数作用&#xff1a; 减少代码重复 增加程序可扩展性 使程序易于维护 函数定义&#xff1a; 关键字&#xff1a;def 名称&#xff1a;与变量名命名规则相同 参数&#xff1a; def fun() #无参数 def fun(x) #普通参数 def fun(name, age22, happyalex) #默…

关于 Error: No PostCSS Config found in 的错误

问题描述&#xff1a; 项目在本地运行不报错&#xff0c;上传到 GitHub 之后&#xff0c;再 clone 到本地&#xff0c; npm install安装完成之后再执行 npm run dev这时报错 Error: No PostCSS Config found in... 本以为是 GitHub 上传的问题&#xff0c;后开又试了两回&am…

haproxy实现会话保持

HAProxy系列文章&#xff1a;http://www.cnblogs.com/f-ck-need-u/p/7576137.html 1.反向代理为什么需要设置cookie 任何一个七层的http负载均衡器&#xff0c;都应该具备一个功能&#xff1a;会话保持。会话保持是保证客户端对动态应用程序正确请求的基本要求。 还是那个被举烂…

java dubbo 方案,Missing artifact com.alibaba:dubbo:jar:2.8.4 dubbo解决方案

由于maven中心仓库中没有dubbo2.8.4&#xff0c;所以需要到github中下载源码包自己编译。下载解压后&#xff0c;进入解压目录执行命令&#xff1a;mvn install -Dmaven.test.skiptrue2.mvn install:install-file -Dfiled:\xxx\dubbo-2.8.4.jar -DgroupIdcom.alibaba -Dartifac…

Java 8:Lambda表达式与自动关闭

如果您通过Neo4j的Java API和Java 6使用了Neo4j的早期版本&#xff0c;则可能具有与以下类似的代码&#xff0c;以确保在事务中进行写操作&#xff1a; public class StylesOfTx {public static void main( String[] args ) throws IOException{String path "/tmp/tx-st…

vue之computed和watch

计算属性 computed 侦听器or观察者 watch 一直以来对computed和watch一知半解&#xff0c;用的时候就迷迷糊糊的&#xff0c;今天仔细看了看文档&#xff0c;突然茅塞顿开&#xff0c;原来就是这么简单啊&#xff1a; computed&#xff0c;通过别人改变自己watch&#xff0c;…

python实现简单的百度翻译

这段时间&#xff0c;一直在学python,想找点东西实现一下&#xff0c;练手&#xff0c;所以我想通过python代码来实现翻译&#xff0c;话不多说&#xff0c;看吧&#xff01; 以chrome为例 1 打开百度翻译 https://fanyi.baidu.com 2 找到请求的url地址 https://fanyi.baidu.…

php不会写 能看懂,人人都能看懂的全栈开发教程——PHP

既然我们是要实现从数据库里读取任务列表这个需求&#xff0c;那么首先我们就得知道如何通过编程的方式从数据库里把数据读出来。这里我们就选 PHP 作为我们的编程语言来实现我们的想法。为什么是 PHP 呢&#xff1f;主要有以下两个原因&#xff1a;PHP 比较简单&#xff0c;入…

与詹金斯一起连续交付Heroku

如果您安装了Jenkins Git插件&#xff0c;那么利用Jenkins并针对Heroku的连续交付管道的设置就非常简单。 通过此管道&#xff0c;对特定Git分支的更改将导致Heroku部署。 为了使此部署过程正常运行&#xff0c;您应该至少使用两个Git分支&#xff0c;因为您希望有一个针对自动…

Goland软件使用教程(二)

Goland软件使用教程&#xff08;二&#xff09;一、编码辅助功能 1. 智能补全 IDE通过自动补全语句来帮助您来编写代码。快捷键“Ctrlshift空格”将会给你一个在当前上下文中最相关符号的列表&#xff0c;当您选择一个建议时&#xff0c;它会相应的将有关包导入到你的当前…

Vue style里面使用@import引入外部css, 作用域是全局的解决方案

问题描述 使用import引入外部css&#xff0c;作用域却是全局的 <template></template><script>export default {name: "user"}; </script><!-- Add "scoped" attribute to limit CSS to this component only --> <styl…

java输出减法表,Calendarjava时间加减法和格式化输出

Calendar calendar Calendar.getInstance();//减三天calendar.add(5, -3);//将Calendar类型转换成Date类型Date tasktimecalendar.getTime();//设置日期输出的格式//六天calendar.add(5, 6);Date tasktime2calendar.getTime();SimpleDateFormat dfnew SimpleDateFormat("…

集合对象根据某个字段首字母排序

import java.text.Collator; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Locale;/*** 排序后的对象集合* param list* return*/public Li…

Storm Trident拓扑中的错误处理

这篇文章总结了我在设计Storm Trident拓扑时当前的错误处理方法。 我在这里关注代码设计&#xff0c;而不是监督或冗余之类的部署良好实践。 由于Storm的实时流性质&#xff0c;当面对大多数错误时&#xff0c;我们最终将不得不移至下一个数据。 在这种情况下&#xff0c;错误…

vue路由知识整理

vue路由知识整理 对于单页应用,官方提供了vue-router进行路由跳转的处理.我们已经可以通过组合组件来组成应用程序&#xff0c;当你要把 vue-router 添加进来&#xff0c;我们需要做的是&#xff0c;将组件(components)映射到路由(routes)&#xff0c;然后告诉 vue-router 在哪…

ATS日志说明

ATS日志说明 转&#xff1a;http://www.safecdn.cn/在ATS日志中我们经常遇到形形色色的缓存结果码&#xff0c;为了更清晰地认识它们&#xff0c;相关资料整理到这里&#xff1a;TCP_HIT请求对象的一份合法拷贝被缓存&#xff0c;ATS将发送该对象给clientTCP_MISS请求对象未缓存…

leetcode 134. 加油站(Gas Station)

目录 题目描述&#xff1a;示例 1:示例 2:解法&#xff1a;题目描述&#xff1a; 在一条环路上有 N 个加油站&#xff0c;其中第 i 个加油站有汽油 gas[i] 升。 你有一辆油箱容量无限的的汽车&#xff0c;从第 i 个加油站开往第 i1 个加油站需要消耗汽油 cost[i] 升。你从其中的…