我在我的项目中使用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
?
答案 0 :(得分:1)
这是我的做法:
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
}