Reputation: 6281
I've created a task that can extract local .tar files (which I previously manually downloaded from Artifactory) as a test. How can I reference the files when they are on Artifactory from my gradle script? Should I just use the server path? All I've done with gradle is basic stuff and haven't worked with repositories.
I'd also like to perform a certain action based on whether the file has changed since I last ran the script, is that possible?
Upvotes: 0
Views: 1585
Reputation: 33436
One way of doing this would be to create a new configuration
for your TAR file. In my example I gave it the name myTar
. In the repositories closure you define the URL to your Artifactory repository and reference the TAR file as dependency in the dependencies
closure. When running Gradle it will download the file for you and put it in your local repository. As I read you already created a task that extracts the TAR file. I created a task named extractMyTar
which references your downloaded TAR file by its configuration name and untars it into a local directory.
configurations {
myTar
}
repositories {
mavenRepo urls: 'http://my.artifactory/repo'
}
dependencies {
myTar 'your.org:artifact-name:1.0@tar'
}
task extractMyTar << {
File myTarFile = configurations.getByName('myTar').singleFile
if(myTarFile.exists()) {
ant.untar(src: myTarFile, dest: file('myDestDir'))
}
}
Upvotes: 1