Java资源分享网 - 专业的Java学习网站 学Java,上Java资源分享网
Learning Apache Maven PDF 下载
匿名网友发布于:2024-06-24 08:03:04
(侵权举报)
(假如点击没反应,多刷新两次就OK!)

Learning Apache Maven PDF 下载 图1

 

 

资料内容:

 

Chapter 2: Access Maven informations in
code
Introduction
It is sometimes useful to get the maven properties, such as the current version, in code. Here are
some ways to to it.
Examples
Getting the version number from within a jar
If you package your application in a jar using the maven-jar-plugin or the maven-assembly-plugin, an
easy way to get the current pom version is to add an entry in the manifest, which is then available
from Java.
The secret is to set the addDefaultImplementationEntries flag to true (and the
addDefaultSpecificationEntries is you also need the artifact id).
jar plugin configuration:

 

<build>
 <plugins>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-jar-plugin</artifactId>
 <configuration>
 <archive>
 <manifest>
 <mainClass>...</mainClass>
 <addDefaultImplementationEntries>
 true
 </addDefaultImplementationEntries>
 </manifest>
 </archive>
 </configuration>
 </plugin>
 </plugins>
</build>