Gradle Artifactory Plugin

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

Overview

Artifactory offers full integration with Gradle via two alternative ways:

  1. Build Server Integration - When running Gradle builds in you continuous integration build server, it is recommended you use one of the Artifactory Plugins for Jenkins, TeamCity or Bamboo to configure resolution and publishing to Artifactory with build-info capturing, via your build server UI.
  2. Standalone Integration - Which is the method described on this page, for when running standalone Gradle build scripts using the Gradle Artifactory plugin.
    The Gradle Artifactory plugin offers a simple DSL to perform the following as part of your Gradle build:
    1. Define default dependency resolution from Artifactory
    2. Define configurations whose artifacts will be published to Artifactory after a full (multi-module) successful build
    3. Define properties that will be attached to published artifacts in Artifactory metadata
    4. Capture and publish a build-info object to Artifactory build-info REST API to provide a fully traceable build context

Gradle Compatibility

Plugin Version Compatible with Gradle
2.0.4 gradle-1.0-milestone-3
2.0.5 gradle-1.0-milestone-4
2.0.6 gradle-1.0-milestone-3
2.0.10 gradle-1.0-milestone-6
2.0.10 gradle-1.0-milestone-7

Downloading and Installing the Artifactory Plugin

Manual Installation

The latest plugin jar file can be downloaded from here and copy it to your gradle home plugins directory ~/.gradle/plugins.
And add the following to your project:

Automatic Installation

Alternatively, you can add to your Gradle scripts to fetch the plugin using the standard Ivy resolution. For example:

The above script will automatically download the plugin, and make it available to the buildScript of your projects.

Adding the Plugin to Your Project(s)

In order to apply the plugin in your Gradle projects, the following closure needs to be declared in your build.gradle script:

In a multi-project build, you'd want to apply the plugin to all projects:

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.

The Properties Closure DSL

The properties closure in artifactory.publish.defaults and artifactpryPublish task accept the following syntax:

A configuration that is a valid name of a configuration of the project. You can use all to apply the properties to all configurations.
An artifact specification filter for matching the artifacts to which properties should be attached. The filter may contain wildcards: * for all characters or ? for a single character.
A list of key/value(s) properties that will be attached to to the published artifacts that match the filter.

The Artifactory Project Publish Task

Behind the scenes the Gradle Artifactory Plugin creates an 'artifactoryPublish' Gradle task for each project the plugin is applied to. The artifactoryPublish 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 closure.

Controlling the Published Modules

To control which modules of a multi-module build, will be published to Artifactory you should manual activate the corresponding 'artifactoryPublish' Gradle task for each project you wish to.
For example in our Gradle project example you can run: ./gradlew clean api:artifactory:publish shared:artifactoryPublish

Controlling BuildInfo's Build Name and Build Number

By default, BuildInfo will be published with a build name that is 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 build number values by specifying the following properties, respectively:

The above properties are specified as standard Gradle properties.

Watch the Screencast

To see the Gradle Artifactory Plugin in action you can watch the following screencast below.

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Oct 29, 2010

    How can I expose my custom generated artifact to the gradle-artifactory plugin?

    Davide
    UPDATE:
    Since I've just reported an ad-hoc request on the plugin JIRA, I'm now reducing this comment details.
    Please see the relevant issue for more details.