是否必须定义java插件才能在gradle脚本中下载Depdency?
我正在编写gradle脚本,我需要从artifactory下载多个jar文件。我正在gradle脚本中使用apply插件“java”,能够轻松地从artifactory获取这些jar文件,但是如果我应用这个插件,它会自动运行jar任务并创建我不想要的jar。有没有办法下载jar文件使用/不使用java插件,使jar任务无法触发是否必须定义java插件才能在gradle脚本中下载Depdency?,java,gradle,build.gradle,Java,Gradle,Build.gradle,我正在编写gradle脚本,我需要从artifactory下载多个jar文件。我正在gradle脚本中使用apply插件“java”,能够轻松地从artifactory获取这些jar文件,但是如果我应用这个插件,它会自动运行jar任务并创建我不想要的jar。有没有办法下载jar文件使用/不使用java插件,使jar任务无法触发 apply plugin 'java' apply plugin: 'base' //-- set the group for publishing group = '
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 Building com.abcdefgh.discovery:cdad
16:28:33在“C:\Windows\TEMP\buildInfo429617857022686528.Properties”找到[buildinfo]属性文件
16:28:35:copyDeps最新
16:28:36:deletebuild
16:28:37:buildreportZip
16:28:38:删除图形集
16:28:47:解压
16:28:47:compileJava最新版本
16:28:47:processResources最新
16:28:47:最新课程
16:28:47:jar
16:28:47:artifactoryPublish
16:28:47部署工件:
16:28:53部署工件:您不需要添加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
}