Reputation: 15042
I am new to gradle and artifactory both.
What I want to accomplish is to have separate projects with each project creating a jar file that will be used by other projects in the same application.
For example, I have a utility project that has, wait for it..., utility classes. I then have a services project with the, that's right, services. The services use the utilities to accomplish some of their work.
I've spent several hours and finally have the utility project committing to my artifactory repository using this script:
buildscript {
repositories {
mavenLocal()
ivy {
url 'http://picard:8080/artifactory/plugins-release'
}
jcenter()
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"
}
}
apply plugin: 'java'
apply plugin: "com.jfrog.artifactory"
archivesBaseName = 'heavyweight-software-util'
repositories {
mavenCentral()
ivy {
url 'http://picard:8080/artifactory/plugins-release'
}
}
dependencies {
testCompile("junit:junit:4.11")
}
task wrapper(type: Wrapper) {
gradleVersion = '1.8'
}
artifactory {
contextUrl = "http://picard:8080/artifactory" //The base Artifactory URL if not overridden by the publisher/resolver
publish {
repository {
repoKey = 'libs-release-local'
username = 'xxxx'
password = "xxxx"
maven = false
ivy {
ivyLayout = '[organization]/[module]/[revision]/[type]s/ivy-[revision].xml'
artifactLayout = '[organization]/[module]/[revision]/[type]s/[module](-[classifier])-[revision].[ext]'
mavenCompatible = false
}
}
}
resolve {
repository {
repoKey = 'libs-release'
username = 'xxxx'
password = "xxxx"
maven = false
ivy {
ivyLayout = '[organization]/[module]/[revision]/[type]s/ivy-[revision].xml'
artifactLayout = '[organization]/[module]/[revision]/[type]s/[module](-[classifier])-[revision].[ext]'
mavenCompatible = false
}
}
}
}
When I run this I get the following:
C:\Users\thom\git\utility\Utility>gradle artifactoryPublish
[buildinfo] Not using buildInfo properties file for this build.
:artifactoryPublish
Deploying build descriptor to: http://picard:8080/artifactory/api/build
Build successfully deployed. Browse it in Artifactory under http://picard:8080/a
rtifactory/webapp/builds/Utility/1436807848026/2015-07-13T13:17:27.704-0400/
BUILD SUCCESSFUL
Total time: 6.874 secs
Hurrah! Or, so I thought.
Because as soon as this wrapped up, I thought, "Now how do I get this file out." I looked at the links above and they're there, but I can't see how this is a jar file. I tried looking at libs-release-local in my tree browser, but it shows 0 artifacts.
Here's what I found under build info JSON under the build:
{
"version" : "1.0.1",
"name" : "Utility",
"number" : "1436807848026",
"type" : "GRADLE",
"buildAgent" : {
"name" : "Gradle",
"version" : "2.4"
},
"agent" : {
"name" : "Gradle",
"version" : "2.4"
},
"started" : "2015-07-13T13:17:27.704-0400",
"durationMillis" : 474,
"principal" : "thom",
"artifactoryPrincipal" : "admin",
"licenseControl" : {
"runChecks" : false,
"includePublishedArtifacts" : false,
"autoDiscover" : false,
"licenseViolationsRecipientsList" : "",
"scopesList" : ""
},
"buildRetention" : {
"count" : -1,
"deleteBuildArtifacts" : true,
"buildNumbersNotToBeDiscarded" : [ ]
},
"governance" : {
"blackDuckProperties" : {
"runChecks" : false,
"includePublishedArtifacts" : false,
"autoCreateMissingComponentRequests" : false,
"autoDiscardStaleComponentRequests" : false
}
}
}
I've googled and researched and can't seem to figure out how to make use of the jar file I have committed to my repository.
Upvotes: 1
Views: 2891
Reputation: 15042
OK, after reading: https://docs.gradle.org/current/userguide/publishing_ivy.html and https://docs.gradle.org/current/userguide/artifact_management.html and finally, http://forums.jfrog.org/405-HTTP-method-PUT-not-supported-td5786632.html I have pieced together an answer to my question. I have attached the build script that performs the upload properly...
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"
}
}
apply plugin: 'java'
apply plugin: 'ivy-publish'
archivesBaseName = 'heavyweight-software-util'
repositories {
mavenCentral()
ivy {
url 'http://picard:8080/artifactory/plugins-release'
}
}
dependencies {
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.+'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.+'
testCompile("junit:junit:4.11")
}
publishing {
publications {
ivy(IvyPublication) {
organisation 'com.heavyweightsoftware'
module 'heavyweight-util'
revision '1.0'
from components.java
}
}
repositories {
ivy {
url 'http://picard:8080/artifactory/libs-release-local'
credentials {
username "xxxxx"
password "xxxxx"
}
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '1.8'
}
Now that I know that the publication is working correctly, I should be able to use the repository without issue.
Upvotes: 2