Publish to custom Artifactory repositories
In this tutorial, we will go through the process of publishing to a custom Artifactory repository.
The sample project is here.
You need access to your Artifactory server. For learning purpose you may get an open-source version of JFrog artifactory server on your local computer to try.
#
Project setup#
gradle.propertiesAdd Artifactory server information to gradle.properties
. We can have multiple Artifactory server settings in one gradle.properties
file. Each of the settings is identified by an ID. ("demo" in the example below.). However, we can only use one Artifactory repository for each sub-project.
# ...repository.artifactory.demo.release=http://localhostrepository.artifactory.demo.snapshot=http://localhostrepository.artifactory.demo.repoKey=demo-reporepository.artifactory.demo.username=writeuserrepository.artifactory.demo.password=....token....# ...
We need to provide a URL for the release version of the component, a URL for the snapshot version of the component, username and password of your account, and the repoKey
that represent a particular repository in the Artifactory server.
#
build.gradleTell Jarbird plugin that we want to publish to a custom Artifactory repository. We specify the ID of our Artifactory repository setting in gradle.properties
.
- build.gradle
- build.gradle.kts
// ...jarbird { pub { artifactory("demo") }}// ...
// ...jarbird { pub { artifactory("demo") }}// ...
See reference for more details about the content of pom.yaml
.
Jarbird plugin read the file and create a proper POM file for publishing automatically.
With this setup, we can see more tasks available with ./gradlew tasks
Jarbird publishing tasks------------------------jbPublish - PublishjbPublishCustomartifactory - Publish module 'customartifactory' to all targeted repositoriesjbPublishCustomartifactoryToMavenLocal - Publish module 'customartifactory' to Maven Local repositoryjbPublishToArtifactory - Publish jarbirdsamples:customartifactory:1.0 to Artifactory.jbPublishToMavenLocal - Publish to Maven Local repository
The task jbPublish
publishes component to all specified repositories, which is MavenLocal and MavenCentral for this sample. We may use jbPublishToArtifactory
to publish all of our components to the "demo" Maven repository.