You need plugins :
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
to build project and retrieve jars from artifactory:
buildscript {
repositories {
maven {
url 'http://[IP]:[PORT]/artifactory/gradle-dev'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
mavenCentral()
}
dependencies { classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.5.4" }
}
repositories {
mavenCentral()
mavenLocal()
}
Artifactory configs:
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'gradle-dev-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
publications('mavenJava')
}
publishBuildInfo = true
publishArtifacts = true
publishPom = true
}
resolve {
repository {
repoKey = 'gradle-dev'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
}
and for publishing:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
gradle.properties
artifactory_user=publisher
artifactory_password=*****
artifactory_contextUrl=http://IP:PORT/artifactory
So everything is just simple. If you want to upload your jar:
gradle artifactoryPublish