![](/img/trans.png)
[英]How to get latest version number of an artifact and replace it in target file?
[英]How to get 'latest' artifact version?
我想知道Nexus是否提供API(不幸的是我沒有找到任何有用的示例)來做這種事情。 因此,在我的組ID( com.testtools )中,我獲得了工件hibi ,它以方式-major.minor.patch進行版本控制。 當前在此目錄中,我有版本:
0.0.5
0.1.2
0.1.4
我知道如何獲取某個版本或如何獲取最新的存儲版本(此處為快照),例如:
wget 'http://mynexus.se:8081/nexus/service/local/artifact/maven/content?g=com.testtools&a=hibi&v=LATEST&r=snapshots' --content-disposition
給我hibi-0.1.4。 但是對於這個hibi工件,我必須能夠獲得某些次要版本的最新補丁 。 因此,如果我通過0.0,如何獲得0.0.5(如果我通過0.1,如何獲得0.1.4)? 嘗試過類似的東西:
wget 'http://mynexus.se:8081/nexus/service/local/artifact/maven/content?g=com.testtools&a=hibi&v=0.1.*&r=snapshots' --content-disposition
但它無法正常運行(找不到工件)。 我會很高興提出任何建議。
這是一個簡單的pom.xml,它將其依賴項(我以slf4j為例)復制到目錄“目的地”。 只需以“ mvn clean install”開始。
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>YourGroup</groupId>
<artifactId>Test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>[1.6.0,1.7.0)</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>destination</outputDirectory>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<configuration>
<allowSnapshots>true</allowSnapshots>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.