[英]How can I tell maven to prefer SNAPSHOT versions over incremental versions?
因為我的增量內部版本號= CI內部版本號,所以我不想將增量內部版本號放入我的開發POM中。 它應僅具有主要和次要版本組件。
但是,同一框架內的另一個組件將要說“如果SNAPSHOT版本在本地存在,請使用該版本,否則請使用最新的增量版本”。
如何在我的POM中指定?
我嘗試了這個:
<dependencies>
<dependency>
<groupId>com.example.ajb.versionpoc</groupId>
<artifactId>downstream</artifactId>
<version>[1.1-SNAPSHOT],[1.1,2.0)</version>
</dependency>
</dependencies>
但這是行不通的。 仍將版本解析為例如1.1.23。 我如何告訴Maven更喜歡SNAPSHOT版本?
我不太了解您要做什么,但這是一般性的協議:
基於@ DB5關於配置文件的建議,我認為您可以聲明一個包含快照依賴項的特定配置文件。 可以根據本地存儲庫中該庫的存在來完成此類配置文件的激活。
在您的pom的profiles
部分中添加以下片段:
<profile>
<!--This profile will prefer the SNAPSHOT version if it exists locally-->
<id>local</id>
<activation>
<file>
<exists>${user.home}/.m2/repository/mygroup/myartifact/myversion-SNAPSHOT/myartifact-myversion-SNAPSHOT.jar</exists>
</file>
</activation>
<dependencies>
<dependency>
<groupId>mygroup</groupId>
<artifactId>myartifact</artifactId>
<version>myversion-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<!--This profile will prefer the released version if the SNAPSHOT does not exist locally-->
<id>released</id>
<activation>
<file>
<missing>${user.home}/.m2/repository/mygroup/myartifact/myversion-SNAPSHOT/myartifact-myversion-SNAPSHOT.jar</missing>
</file>
</activation>
<dependencies>
<dependency>
<groupId>mygroup</groupId>
<artifactId>myartifact</artifactId>
<version>myversion</version>
</dependency>
</dependencies>
</profile>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.