maven学习笔记

研究了几个maven的问题,在这里记录一下:

1.在构建的时候自动生成javadoc和source包,需要在pom中添加如下内容

<execution> 
  <phase>package</phase>
     <goals> 
       <goal>jar</goal> 
     </goals> 
</execution>

 

  如果phase不写的话在mvn package执行时候将不会执行这段

2.发布source, javadoc, binary jar包:

maven 发布三步: 
mvn clean install 
mvn release:prepare 
mvn release:perform 
如果不想在部署时候把javadoc和sourece传上去可做如下配置:

<plugins> 
<plugin> 
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-release-plugin</artifactId> 
<configuration> 
<tagBase>http://*****/tags/</tagBase> <useReleaseProfile>false</useReleaseProfile> 
</configuration> 
</plugin> 
</plugins>
 
 3.如果想将自己的构件发布到远程中央仓库可以在pom中增加如下配置:
<distributionManagement> 

<repository> 
<id>releases</id> 
<name>releases</name> <url>http://hostname/nexus/repositories/releases/</url> </repository> 

<snapshotRepository> 
<id>snapshots</id> 
<name>snapshots</name> <url>http://hostname/nexus/repositories/snapshots/</url> </snapshotRepository>
 
</distributionManagement> 
 
 
 4. maven构件中的坐标包含四个要素: {groupId, artifactId, type, classifier},type默认是jar, classifier,这个实际没用到过
官方文档 写道
The classifier of the dependency. This allows distinguishing two artifacts that belong to the same POM but were built differently, and is appended to the filename after the version. For example, jdk14 and jdk15

 

5.可以从maven-metadata.xml 中看出当前最新版本,以及一些build信息

 

 

 

你可能感兴趣的:(maven)