The Gradle plugin allows you to upload any file to any repo type according to your requirements. Inclusive, you can use Gradle jobs to upload/download your desired artifacts to/from Artifactory; not only to a Maven repository, but any other that suits your needs. Following is an example of a build.gradle, which demonstrates both resolution and deployments (with a few dependencies):
buildscript { repositories { jcenter() dependencies { classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '4+') } } } configurations { generic { description = 'generic' } } task copyDependencies(type: Copy) { from configurations.generic into "resolved" } dependencies { generic "com.github.jnr:jffi:1.2.7@jar" } allprojects { apply plugin: 'com.jfrog.artifactory' group = 'org.jfrog.example.gradle' version = "1.2" status = "release" } configurations { published } def f1 = file("to_deploy.txt") def f2 = file("resolved/jffi-1.2.7.jar") def f3 = file("patch-1.16.zip") def f4 = file("php54-php-5.4.16-16.el6.centos.alt.x86-64.rpm") artifacts { published file: f1, name: f1.getName(), type: 'txt' published file: f2, name: f2.getName(), type: 'jar' published file: f3, name: f3.getName(), type: 'zip' published file: f4, name: f4.getName(), type: 'rpm' } task resolve << { configurations.generic.files } artifactory { contextUrl = 'http://localhost:8080/artifactory' publish { repository { repoKey = 'generic-local' username = "admin" password = "password" } defaults { publishConfigs('published') } } resolve { repository { repoKey = 'maven-remote' username = "admin" password = "password" } } } task wrapper(type: Wrapper) { gradleVersion = '2.0' }
In the example below, the .jar file will be resolved through a remote repository and the other artifacts will be deployed from the local env to a generic repository (generic-local). When you run the job, you should expect the following client response:
> Configure project : The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead. at build_85cbi8h7b7eao0r2czredl0se.run(/Users/guyco/Work/test/build.gradle:47) Cannot publish Ivy descriptor if ivyDescriptor not set in task 'archives' and no ':' configuration exists in project '{}'. Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path. Download http://localhost:8080/artifactory/maven-remote/com/github/jnr/jffi/1.2.7/jffi-1.2.7.pom Download http://localhost:8080/artifactory/maven-remote/com/github/jnr/jffi/1.2.7/jffi-1.2.7.jar > Task :artifactoryDeploy Deploying artifact: http://localhost:8080/artifactory/generic-local/org/jfrog/example/gradle/test/1.2/jffi-1.2.7.jar-1.2.jar Deploying artifact: http://localhost:8080/artifactory/generic-local/org/jfrog/example/gradle/test/1.2/patch-1.16.zip-1.2.zip Deploying artifact: http://localhost:8080/artifactory/generic-local/org/jfrog/example/gradle/test/1.2/php54-php-5.4.16-16.el6.centos.alt.x86-64.rpm-1.2.rpm Deploying artifact: http://localhost:8080/artifactory/generic-local/org/jfrog/example/gradle/test/1.2/to_deploy.txt-1.2.txt Deploying build descriptor to: http://localhost:8080/artifactory/api/build Build successfully deployed. Browse it in Artifactory under http://localhost:8080/artifactory/webapp/builds/test/1524562242226 BUILD SUCCESSFUL in 12s 3 actionable tasks: 3 executed
Eventually, the repository structure should look like this:
Published: Nov. 1, 2018
Last updated: Dec. 21, 2020
Keywords: Gradle, JCenter, user plugin