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

Overview

The Gradle Artifactory Plugin supports 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 artifactory-publish plugin from version 2.2.3.

For full details on version compatibility please refer to the Gradle Artifactory Compatibility Table.

Source Code Available!

This plugin is an open source project on GitHub which you can freely browse and fork.

Using Gradle versions below 1.8

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


Download and Installation

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:

Automatic Installation

Modify your Gradle scripts to fetch the plugin using the standard Ivy resolution.

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

For example:

Using the Gradle Plugins Gallery
Using Gradle 1.8 or lower? Use the 'buildscript' closure instead  Expand source

Using a snapshot version of the plugin

To use a snapshot version of the plugin simply replace the repositories DSL with the following:

repositories {
    maven { url 'http://repo.jfrog.org/artifactory/gradle-plugins-snapshots' }
}
In the dependencies DSL change the version tag to 2.2.x-SNAPSHOT

Adding the Artifactory Plugin to Your Projects

To use the Artifactory publishing plugin in your Gradle projects, you need to add the following closure to your build.gradle script:

In a multi-project build, you need to add the plugin to all projects:

Using Gradle 1.8 or lower? Use this code instead.  Expand source

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 the artifactory.publish.defaults and artifactoryPublish tasks uses the following syntax:

publicationName

A valid name for a publication of the project. You can use all to apply the properties to all publications.

group:module:version:classifier@type

A filter that specifies the artifacts to which properties should be attached. The filter may contain wildcards: * for all characters or ? for a single character.

key:'value'

A list of key/value properties that will be attached to to the published artifacts matching the filter.

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.

Watch the Screencast

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

 

 

  • No labels