Skip to end of metadata
Go to start of metadata

Overview

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

The plugin supports both Gradle Configurations and Publications for deploying artifacts to Artifactory.

Getting Started Using the Plugin

The following 3 steps add the Gradle Artifactory Plugin to your Gradle build script.

Step 1: Apply the plugin

Build script snippet for use in all Gradle versions
Build script snippet for use in Gradle 2.1 and above

Currently the "plugins" notation cannot be used for applying the plugin for sub projects, when used from the root build script

Step 2: Add the "artifactory" closure

Add the bellow "artifactory" closure, replacing your Artifactory URL, publication and resolution repositories and also your deployer and resolver Artifactory credentials.

Step 3: Run the build

 

The next thing you want to do is to tell the plugin which of the build artifacts you'd like to deploy to Artifactory.
To do that, you need to add to the "artifactory" closure references to Gradle Publications or Gradle Configuratio which include your build artifacts. See "The Artifactory Plugin DSL" section for details.
We also recommend looking at our gradle-examples., to see how this can be done.

 

Using the Correct Plugin ID

The Gradle Artifactory Plugin ID depends on two parameters:

  • Whether you are using Gradle Publications or Gradle Configurations
  • 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

When using Gradle publications

artifactory-publishcom.jfrog.artifactory

When using Gradle configurations

artifactorycom.jfrog.artifactory-upload

Page Contents


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 examples 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.


Examples

Project examples which use the Gradle Artifactory Plugin are available here.


Watch the Screencast

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

 

 

 

  • No labels