gpt4 book ai didi

maven - Gradle:获取依赖项的实际快照文件名

转载 作者:行者123 更新时间:2023-12-04 18:24:12 25 4
gpt4 key购买 nike

我在我的项目中使用 SnapShot:

dependencies {
compile group: 'xx.xx.xx.xx', name: 'xxx', version: '1.0-SNAPSHOT', ext: 'zip'
}

这里是pom文件中的依赖信息

<dependency>
<groupId>xx.xx.xx.xx</groupId>
<artifactId>xxx</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

如何获取实际的快照文件名而不是 1.0-SNAPSHOT

最佳答案

这是我的做法:

configurations.each {
Set<ResolvedArtifact> resolvedArtifacts = it.getResolvedConfiguration().getResolvedArtifacts()
resolvedArtifacts.each { resolvedArtifact ->
ModuleVersionIdentifier mvi = resolvedArtifact.getModuleVersion().getId()
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', mvi.getGroup())
dependencyNode.appendNode('artifactId', mvi.getName())
dependencyNode.appendNode('version', getRealVersion(resolvedArtifact.getFile().getName(),mvi.getName()))
}
}

ext.getRealVersion = { fileNameWithVersion, fineName ->
def real_version = fileNameWithVersion.substring(fineName.length()+1, fileNameWithVersion.length())
real_version = real_version.substring(0, real_version.length()-4)
return real_version
}

关于maven - Gradle:获取依赖项的实际快照文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35471725/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com