How to deploy/resolve different artifact types through a Gradle job?

Subject 

How to deploy/resolve different artifact types through a Gradle job?

Description

The Gradle plugin allow you to upload any file to any repo type according to your requirements

Resolution

You can use your Gradle job to upload/download your desired artifacts from Artifactory.
Not just to a Maven repository, but also a generic, rpm, etc.. (according to your artifact desired types).

Here is an example of a build.gradle which demonstrate 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 this example, 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:
User-added image