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.
defaults
actually goes insideartifactory.publish
, not just in rootartifactory
task. – IncompliantError:(x, 0) Could not find property 'java' on SoftwareComponentInternal set.
Could you please post the full script? – Pogueapply plugin: 'maven'
the pom file is generated and if we have'apply plugin: 'maven-publish'
the jar file is published. And I didn't have to havepublishing.publications.mavenJava(MavenPublication) { from components.java }
. However you got to havedefault {publications ('mavenJava'); publishConfigs('archives', 'published') }
– Heeltap