Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

gradle - Downloading only a POM file from Maven/JFrog repository

I would like to fetch/download only! a POM file from a properly published (with metadata) artifact.

It is easy to write a task downloading jars only

task getArtifacts(type: Copy) {
  from configurations.myConf
  into myWorkingDir
}

and setting the transitive flag to false for myConf(iguration).

But how to download the related POM files only!

The real reason for this is: I obfuscate the downloaded jars, then deploy them back to the repository as an obfuscated version. But I would like provide the pom metadata for the obfuscated artifacts … just using artifacts.add(xxx.pom) before publicizing.

Maybe you know any other idea how to implement the publication of obfuscated jars with metadata in Gradle?

question from:https://stackoverflow.com/questions/65833426/downloading-only-a-pom-file-from-maven-jfrog-repository

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use an ArtifactResolutionQuery to manually resolve artifacts of a specific type:

def result = dependencies.createArtifactResolutionQuery()
    .forModule('group', 'name', 'version')
    .withArtifacts(JvmLibrary, MavenPomArtifact)
    .execute()

for (component in result.resolvedComponents) {
    component.getArtifacts(MavenPomArtifact).each { println it.file }
}

I'm not sure if the actual artifact will be resolved with this method, too, but you may just use the path of the POM file. Please note, that you should call this functionality during the execution phase, either by defining a new task type with a @TaskAction or by using a doFirst/doLast closure.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.6k users

...