Skip to end of metadata
Go to start of metadata
Table of Contents

Overview

The Gradle Artifactory Plugin supports all versions of Gradle including Gradle 2.0 and is available from the Gradle Plugins Gallery.

The previous Gradle publishing model for Ivy and Maven publications is fully supported by the Gradle Artifactory Plugin.

If you are already using the Gradle Artifactory Plugin, and are upgrading it to be compliant with Gradle 2.0, please refer to Upgrading the Gradle Artifactory Plugin.

Using Gradle versions below 2.0

If you are using a version of Gradle below v2.0 please refer to Using Older Versions of Gradle.

Using the Correct Plugin ID

The Gradle Artifactory Plugin ID depends on two parameters:

  • Whether you are using the old or the new Gradle publishing mechanism
  • The version of the plugin

To simplify these documentation pages, the plugin ID will be referred to using a <PLUGIN ID> placeholder.

This placeholder should be replaced with the plugin IDs listed in the table below:

 

Plugin version 2.x

Plugin version 3.0.1 and higher

New Gradle publication mechanism

artifactory-publishcom.jfrog.artifactory

Old Gradle configuration mechanism

artifactorycom.jfrog.artifactory-upload

Download and Installation

Automatic Installation

Modify your Gradle scripts to download the Gradle Artifactory Plugin using the plugins closure as follows:

Downloading the Gradle Artifactory Plugin from Bintray

Using a Snapshot Version

To use a snapshot version of the plugin take the following steps:

  • If you have added the plugins closure described above, you need to remove that. It is not needed when using a snapshot version of the plugin.

Add the following repositories closure

Repositories closure
In the dependencies DSL change the version tag to 3.0.x-SNAPSHOT as follows:
Dependencies DSL

Apply the plugin to your project using the correct plugin ID

Using the new Gradle publishing mechanism?  Expand source

Manual Installation

The latest plugin jar file can be downloaded from the  JFrog Artifactory public demo.  Copy the jar into your gradle home plugins directory ( ~/.gradle/plugins).
Then add the following line to your project build script:

 


Configuration

Using the Artifactory Plugin DSL

The Gradle Artifactory plugin can be configured using its own Convention DSL inside the build.gradle script of your root project.

The syntax of the Convention DSL is described below:

Mandatory items within the relevant context are prefixed with '+'. All other items are optional.

Using the old Gradle publishing mechanism?  Expand source

The Artifactory Project Publish Task

The Artifactory Publishing Plugin creates an artifactoryPublish Gradle task for each project the plugin is applied to. The task is configured by the publish closure of the plugin.

You can configure the project-level task directly with the task's artifactoryPublish closure, which uses identical Syntax to that of the plugin's publish.defaults closure.

Controlling the Published Modules

To control which modules of a multi-module build, are published to Artifactory you can:

  1. Omit the 'artifactory' plugin from a project that does not publish anything. Note that this does not apply to the root project that contains the convention object, and so, requires the plugin to be applied.
  2. Activate the corresponding artifactoryPublish Gradle task manually for each project to which you wish to apply the plugin. 
    For example in our  Gradle project example you can run:

    Activating the plugin manually
  3. Use the artifactoryPublish.skip flag to deactivate analysis and publication.

Controlling the Build Name Number in BuildInfo

By default, BuildInfo is published with a build name constructed from the name of your root project and a build number that is the start date of the build.
You can control the build name and number values by specifying the following properties respectively:

Specifying the build name and number

The above properties are specified as standard  Gradle properties.

You can also control the build name and number from within the Convention object DSL as shown at the end of the Convention DSL syntax above.


Upgrading from Gradle 1.x to Gradle 2.x

If you are already using the Gradle Artifactory Plugin and only need to upgrade Gradle version 1.x to Gradle v2.x, follow these steps:

  1. Add the following plugins closure:
    plugins {
        id '<PLUGIN ID>' version '3.0.1

    }

     

  2. Remove the plugin dependency inside your buildScript section:
    dependencies {
        classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.2.4')
    }

  3. The following line should also be removed from the build.gradle script:
    apply plugin: '<PLUGIN ID>'

Watch the Screencast

To see the Gradle Artifactory Plugin in action please watch the following screencast:

 

 

 

  • No labels