简体   繁体   English

如何获得“最新”工件版本?

[英]How to get 'latest' artifact version?

I'm wondering if Nexus provides API (I unfortunately didn't find any useful examples) to do such thing. 我想知道Nexus是否提供API(不幸的是我没有找到任何有用的示例)来做这种事情。 So, in my group id ( com.testtools ) I got artifact hibi which is versioned in manner - major.minor.patch . 因此,在我的组ID( com.testtools )中,我获得了工件hibi ,它以方式-major.minor.patch进行版本控制。 Currently in this directory I've got versions: 当前在此目录中,我有版本:

0.0.5
0.1.2
0.1.4

I know how to get certain version or how get latest stored version (here - snapshot), eg: 我知道如何获取某个版本或如何获取最新的存储版本(此处为快照),例如:

wget 'http://mynexus.se:8081/nexus/service/local/artifact/maven/content?g=com.testtools&a=hibi&v=LATEST&r=snapshots' --content-disposition

give me hibi-0.1.4. 给我hibi-0.1.4。 But for this hibi artifact I have to be able to get the latest patch for certain minor version . 但是对于这个hibi工件,我必须能够获得某些次要版本的最新补丁 So how can I get 0.0.5 if I pass 0.0 (or 0.1.4 if I pass 0.1)? 因此,如果我通过0.0,如何获得0.0.5(如果我通过0.1,如何获得0.1.4)? Tried something like: 尝试过类似的东西:

wget 'http://mynexus.se:8081/nexus/service/local/artifact/maven/content?g=com.testtools&a=hibi&v=0.1.*&r=snapshots' --content-disposition

but it isn't work properly (artifact not found). 但它无法正常运行(找不到工件)。 I'll be glad for any suggestions. 我会很高兴提出任何建议。

Here is a simple pom.xml, which will copy its dependencies (I used slf4j as an example) to the directory "destination". 这是一个简单的pom.xml,它将其依赖项(我以slf4j为例)复制到目录“目的地”。 Just start it with "mvn clean install". 只需以“ 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.

相关问题 如何获取工件的最新版本号并将其替换到目标文件中? - How to get latest version number of an artifact and replace it in target file? 如何使用JSONP在Bintray上获取工件的最新版本 - How to get latest version of a artifact on Bintray using JSONP 我怎样才能将最新版本的我的关系工件放入我的詹金斯批处理脚本中? - How can I get the latest version of my nexus artifact into my jenkins batchscript? 我如何告诉Maven从自定义链接存储库获取最新版本的工件 - how do i tell maven to get latest version of artifact from custom nexus repository Jenkins-从远程存储库获取最新的工件版本 - Jenkins - get latest artifact version from remote repository 从 maven nexus 获取某个次要版本的最新工件 - Get latest artifact from maven nexus for a certain minor version 什么是工件的最新版本? - What the latest version published of an artifact? Maven究竟如何找到最新版本的工件? - How exactly does Maven find the LATEST version of an artifact? 如何使用Artifactory查询语言查找最新的工件版本? - How to find the latest artifact version with Artifactory Query Language? 如何使用不具有最新版本的Maven构件的Gradle构建android应用? - How to build android app with Gradle with not the latest version of maven artifact?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM