简体   繁体   English

Maven SNAPSHOT不会生成快照版本

[英]Maven SNAPSHOT does not generate snapshot version

I am using pom.xml with following content. 我正在将pom.xml与以下内容配合使用。 I am expecting it to generate a war file with unique id, but it keeps on generating war file with name myproject-0.1.0.Build-SNAPSHOT.war . 我期望它生成具有唯一ID的war文件,但它将继续生成名为myproject-0.1.0.Build-SNAPSHOT.war war文件。

I would like my war file to be created with unique id. 我希望使用唯一的ID创建战争文件。 Something like https://repo.spring.io/libs-snapshot/org/springframework/spring-core/4.3.9.BUILD-SNAPSHOT/ . https://repo.spring.io/libs-snapshot/org/springframework/spring-core/4.3.9.BUILD-SNAPSHOT/之类的东西。 I compared my pom file with the pom file in the folder, but could not locate much differece. 我将我的pom文件与文件夹中的pom文件进行了比较,但是找不到太大的区别。

Command used: 使用的命令:

mvn package

pom.xml file: https://codepen.io/anon/pen/gWmpZb pom.xml文件: https//codepen.io/anon/pen/gWmpZb

If you need versioned snapshots then you can get them from your managed repository following a mvn deploy . 如果需要版本快照,则可以在mvn deploy从托管存储库中获取它们。

It stores SNAPSHOTS with a timestamped version, such as 它存储带有时间戳的版本的SNAPSHOTS,例如

  myproject-0.1.0.Build-20170403.013619-3.war

These can normally retrieved via HTTP. 这些通常可以通过HTTP检索。

Alternatively, if you're using git and Maven 3.2.1 or newer you can do something like: 另外,如果您使用的是git和Maven 3.2.1或更高版本,则可以执行以下操作:

Configure your default profile in settings.xml with a property named sha1 : 使用名为sha1的属性在settings.xml中配置默认​​配置文件:

<properties>
   ...
   <sha1>SNAPSHOT</sha1>
   ...
</properties>

Then you can execute maven like: 然后,您可以像执行maven:

mvn clean install -Dsha1=`git rev-parse --short HEAD`

and get a locally built artifact that is versioned like: 并获得一个本地版本的工件,其版本如下:

myproject-0.1.0.Build-9b5a664.war

This is a version coupled with your last git commit . 这是您最后一次git commit加上的版本。

Details of this and similar mechanisms are in the Maven 3.2.1 Release Notes . 有关此机制和类似机制的详细信息,请参见Maven 3.2.1发行说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM