简体   繁体   English

如何使用以太获取最新的时间戳快照依赖?

[英]How to use aether to get the latest timestamped snapshot dependency?

I am using aether to resolve dependencies.我正在使用以太解决依赖关系。 But in case of a snapshot dependencies where there are multiple timestamps for the same version, it does not honor the timestamps but picks the first available.但是,如果快照依赖项存在同一版本的多个时间戳,它不遵守时间戳而是选择第一个可用的。 How to read timestamps using aether?如何使用以太读取时间戳?

I am using the following block of code to calculate both snapshot and release versions我正在使用以下代码块来计算快照和发布版本

public class GetDirectDependencies
   {

public static void main( String[] args )
    throws Exception
{
    System.out.println( "------------------------------------------------------------" );
    System.out.println( GetDirectDependencies.class.getSimpleName() );

    RepositorySystem system = Booter.newRepositorySystem();

    RepositorySystemSession session = Booter.newRepositorySystemSession( system );

    Artifact artifact = new DefaultArtifact( "org.eclipse.aether:aether-impl:1.0.0.v20140518" );

    ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
    descriptorRequest.setArtifact( artifact );
    descriptorRequest.setRepositories( Booter.newRepositories( system, session ) );

    ArtifactDescriptorResult descriptorResult = system.readArtifactDescriptor( session, descriptorRequest );

    for ( Dependency dependency : descriptorResult.getDependencies() )
    {
        System.out.println( dependency );
    }
}

}

This is from their documentation https://github.com/eclipse/aether-demo/blob/master/aether-demo-snippets/src/main/java/org/eclipse/aether/examples/GetDirectDependencies.java这是来自他们的文档https://github.com/eclipse/aether-demo/blob/master/aether-demo-snippets/src/main/java/org/eclipse/aether/examples/GetDirectDependencies.java

I achieved this by configuring the following session property我通过配置以下会话属性来实现这一点

aether.artifactResolver.snapshotNormalization=false

Example:例子:

mvn -Daether.artifactResolver.snapshotNormalization=false  clean install

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

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