I am a newbie to Gradle and Artifactory and I want to upload a JAR file to Artifactory.
Here is my build.gradle
file:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'artifactory-publish'
groupId = 'myGroup'
version = '1.0'
def artifactId = projectDir.name
def versionNumber = version
artifactory {
contextUrl = 'http://path.to.artifactory' // base artifactory url
publish {
repository {
repoKey = 'libs-releases' // Artifactory repository key to publish to
username = 'publisher' // publisher user name
password = '********' // publisher password
maven = true
}
}
}
artifactoryPublish {
dependsOn jar
}
After running the artifactoryPublish
task, the build is successful as shown below:
> gradle artifactoryPublish --stacktrace
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar
:artifactoryPublish
Deploying build info to: http://path.to.artifactory/api/build
BUILD SUCCESSFUL
Total time: 7.387 secs
However, there is nothing sent to Artifactory except the build info.
Any help will be much appreciated.
Edit:
As JBaruch mentioned, I've added the following:
apply plugin: 'maven-publish'
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
and defaults section to artifactory task:
defaults {
publications ('mavenJava')
}
Now it works.
Thanks.
That's because you don't have any publications
. The artifactory-publish
plugin works with maven-publish
plugin and uploads publications
.
If you prefer working with the old maven plugin, you need artifactory
plugin, not artifactory-publish
.
Take a look at the Overview part in "Working with Gradle" page of the official docs.