1

I'd like to freely modify artifact names of dependencies in my build.gradle file as part of an Android project. To do so I'm starting off with a custom configuration as show here, but instead of filtering I'd like to search and replace / map names:

configurations {
    mymodule
}

dependencies {
    mymodule 'mygroup:mymodule:1.1.1'

    // How to do something with configurations.mymodule to map e.g.
    // 'some-name-1.0.jar' to 'some-other-name-1.0.jar' instead of filtering?
    compile configurations.mymodule.filter { it.name == 'mymodule-client-1.1.1.jar' } 
}

According to this answer configurations are just (lazy) FileCollections, but being new to Gradle / Groovy I simply cannot figure out the syntax.

I've tried

compile configurations.mymodule.collect { new File(it.path, it.name.replaceAll('some-name', 'some-other-name') ) }

but that does not seem to change anything WRT the file names.

Community
  • 1
  • 1
sschuberth
  • 28,386
  • 6
  • 101
  • 146
  • What's the motivation? Just changing the names won't change the file names on disk. – Peter Niederwieser Jul 24 '14 at 10:13
  • The motivation is to solve http://stackoverflow.com/questions/24908203/using-gradles-artifact-only-notation-with-a-custom-artifact-name. The files on disk (that is, on the Artifactory server in my case) are such that the defaults cannot be used. – sschuberth Jul 24 '14 at 10:18
  • But doesn't this mean that the files aren't even downloaded correctly? In that case, changing file names won't help. (Methods such as `filter` operate on the local files *after* they have been resolved.) – Peter Niederwieser Jul 24 '14 at 10:50
  • Correct, the files are not even downloaded correctly. I though I would be able to change the name *before* the download this way, so that the (oddly) named files could be correctly retrieved from the server. – sschuberth Jul 24 '14 at 10:52
  • You cannot change the name before the download in this way. – Peter Niederwieser Jul 24 '14 at 12:28
  • Ok, thanks. If you know of a way to solve the original problem please reply to http://stackoverflow.com/questions/24908203/using-gradles-artifact-only-notation-with-a-custom-artifact-name. – sschuberth Jul 24 '14 at 12:45

0 Answers0