将gradle与本地工件库一起使用
我对gradle和artifactory都是新手 我想要完成的是拥有独立的项目,每个项目创建一个jar文件,供同一应用程序中的其他项目使用 例如,我有一个实用程序项目,它有,等等…,实用程序类。然后我有一个服务项目,是的,服务。这些服务使用这些实用程序来完成一些工作 我花了几个小时,终于让实用程序项目使用以下脚本提交到我的artifactory存储库:将gradle与本地工件库一起使用,gradle,ivy,artifactory,Gradle,Ivy,Artifactory,我对gradle和artifactory都是新手 我想要完成的是拥有独立的项目,每个项目创建一个jar文件,供同一应用程序中的其他项目使用 例如,我有一个实用程序项目,它有,等等…,实用程序类。然后我有一个服务项目,是的,服务。这些服务使用这些实用程序来完成一些工作 我花了几个小时,终于让实用程序项目使用以下脚本提交到我的artifactory存储库: buildscript { repositories { mavenLocal() ivy {
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
}
}
}
}
当我运行此命令时,会得到以下结果:
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
万岁!或者,我是这么想的
因为当这一切结束后,我想,“现在我该如何把这个文件拿出来。”我看了上面的链接,它们就在那里,但我看不出这是一个jar文件。我尝试在我的树浏览器中查看libs release local,但它显示0个工件
以下是我在build下的build info JSON下找到的内容:
{
"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
}
}
}
我已经在谷歌上搜索和研究过了,但似乎还不知道如何利用我提交给存储库的jar文件。好的,在阅读之后:最后,我拼凑出了我问题的答案。我已经附上了正确执行上传的构建脚本
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'
}
既然我知道出版物正常运行,我应该能够毫无问题地使用存储库。那么…/builds/Utility/1436807848026/2015-07-13T13:17:27.704-0400/文件夹中有什么?人工制品什么也看不出来?你看了硬盘上的这个文件夹了吗?@sydd“常规信息”下有一个版本号,但当我看发布的工件时,没有找到任何记录。构建信息JSON中有一些东西,我将添加到问题中。@sydd硬盘上的文件在哪里?我找到了一个构建,但没有找到。这是线索吗?