Artifactory provides tight integration with Gradle. All that is needed is a simple modification of your
build.gradle script file with a few configuration parameters.
Both the new and older publishing mechanisms of Gradle are supported, however some of the steps to configure the Gradle Artifactory Plugin depend on the version you are using, and these are detailed in the documentation pages.
The Gradle Artifactory Plugin can be used whether you are running builds using a CI server, or running standalone builds. In either case, you should note the following points:
- CI Server Integration
When running Gradle builds in your continuous integration server, we recommend using one of the Artifactory Plugins for Jenkins, TeamCity or Bamboo.
You can use your build server UI to configure resolving and publishing artifacts through Artifactory to capture exhaustive build information.
- Standalone Integration
The Gradle Artifactory plugin offers a simple DSL to perform the following steps in your Gradle build:
- Define the default dependency resolution from Artifactory.
- Define configurations that publish artifacts to Artifactory after a full (multi-module) successful build.
- Define properties that should be attached to published artifacts in Artifactory metadata.
- Capture and publish a build-info object to the Artifactory build-info REST API to provide a fully traceable build context.
Source Code Available!
This Gradle Artifactory Plugin is an open source project on GitHub which you can freely browse and fork.
The following sections describe the main configuration steps and provide a sample Gradle script that shows the information you need to get started using Gradle with Artifactory.
Configuring Artifact Resolution
Using the Gradle Build Script Generator
With Artifactory's Gradle Build Script Generator, you can easily create a Gradle init script that handles resolution.
In the Home tab, select Client Settings | Gradle Build Script.
|The repository that should be used to resolve plugins/libraries|
Use Maven/Use Ivy
|When checked, specifies that resolving should be done using the Maven/Ivy pattern|
|The repository that should be used to publish libraries|
Publish Maven Descriptor/
Publish Ivy Descriptor
|When checked, specifies that library should be published using a Maven/Ivy descriptor|
|Specifies the layout of the corresponding repository|
Provisioning Dynamic Settings for Users
Artifactory lets you deploy and provision a dynamic settings template for your users. Once downloaded, settings are generated according to your own logic and can automatically include user authentication information.
Sample Build Script and Properties
You can download sample scripts from the JFrog GitHub public repository.
For Gradle to build your project and upload generated artifacts to Artifactory, you need to run the following command:
For more details on building your projects with Gradle, please refer to the Gradle Documentation.
Getting debug information from Gradle
We highly recommend running Gradle with the
-d option to get useful and readable information if something goes wrong with your build.
Dependency Declaration Snippets
Artifactory can provide you with dependency declaration code snippets that you can simply copy into the Gradle Dependency Declaration section of your
In the Repository Browser (Artifacts tab and then Browse | Tree Browser), drill down in the repository tree and select an artifact to display the corresponding dependency declaration that you can copy into your