我正在编写gradle脚本,我需要从artifactory下载多个jar文件我正在使用apply plugin' java'在gradle脚本中,能够轻松地从artifactory中获取这些jar文件,但是如果我应用这个插件,它会自动运行jar任务并创建我不想要的jar。有没有办法从artifactory下载jar文件/不使用java插件,以便jar任务无法触发。
apply plugin 'java'
apply plugin: 'base'
//-- set the group for publishing
group = 'com.abcdef.covery'
/**
* Initializing GAVC settings
*/
def buildProperties = new Properties()
file("version.properties").withInputStream {
stream -> buildProperties.load(stream)
}
//add the jenkins build version to the version
def env = System.getenv()
if (env["BUILD_NUMBER"]) buildProperties.coveryadBuildVersion += "_${env["BUILD_NUMBER"]}"
version = buildProperties.scoveryadBuildVersion
println "${version}"
//name is set in the settings.gradle file
group = "com.abcdef.discovery"
version = buildProperties.coveryadBuildVersion
println "Building ${project.group}:${project.name}"
repositories {
maven {
url "http://art.tsh.tho.com:90000/artifactory/services"
}
}
dependencies {
runtime "covery.services:AddService:1.0@jar"
runtime "covery.services:AddService:1.1@jar"
runtime "covery.services:Services:1.0@jar"
runtime "covery.services:Services:1.1@jar"
}
task copyDeps(type: Copy) {
from configurations.runtime
into 'services/discovery/services/'
}
输出:下面显示了在脚本中使用java插件时正在运行的几项任务,如果我不使用那么它就不会从artifactory下载jar文件。
16:28:32构建com.abcdefgh.discovery:cdad 16:28:33 [buildinfo]在' C:\ Windows \ TEMP \ buildInfo429617857022686528.properties'中找到的属性文件 16:28:35:copyDeps UP-TO-DATE 16:28:36:deletebuild 16:28:37:buildreportZip 16:28:38:deleteGraphicsAssets 16:28:47:解压缩 16:28:47:compileJava UP-TO-DATE 16:28:47:processResources UP-TO-DATE 16:28:47:上课日期 16:28:47:罐子 16:28:47:artifactoryPublish 16:28:47部署工件:http://localhost:8081/artifactory/libs-release-local/com/abcdefg/covery/cdad/03_00_00_183/cdad-03_00_00_183.zip 16:28:53部署工件:http://localhost:8081/artifactory/libs-release-local/com/abcdefl/covery/cdad/03_00_00_183/cdad-03_00_00_183.jar
答案 0 :(得分:1)
您无需添加java插件即可下载依赖项。如果您没有任何java源文件,我建议您使用baseplugin:
apply plugin: 'base'
repositories {
mavenCentral()
}
configurations {
nameOfMyConfiguration
}
dependencies {
nameOfMyConfiguration 'org.scala-lang:scala-library:2.10.4'
}
task zipMyStuff(type: Zip) {
from configurations.nameOfMyConfiguration
}