gpt4 book ai didi

java - 是否必须定义java插件来下载gradle脚本中的依赖关系?

转载 作者:行者123 更新时间:2023-11-30 08:16:03 25 4
gpt4 key购买 nike

我正在编写gradle脚本,我需要从artifactory下载多个jar文件我在gradle脚本中使用应用插件“java”,并且能够轻松地从artifactory获取这些jar文件,但是如果我应用这个插件它就会运行jar 任务会自动创建我不想要的 jar。有没有办法使用/不使用 java 插件从artifactory 下载 jar 文件,以便 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 插件时运行的几个任务,如果我不使用,那么它不会从 Artifact 下载 jar 文件。

16:28:32 构建 com.abcdefgh.discovery:cdad16:28:33 [buildinfo] 在“C:\Windows\TEMP\buildInfo429617857022686528.properties”中找到属性文件16:28:35 :copyDeps 最新16:28:36 :删除构建16:28:37 :buildreportZip16:28:38 :删除图形资源16:28:47 :解压16:28:47 :compileJava 最新16:28:47 :processResources 最新16:28:47:类(class)最新16:28:47 : jar 16:28:47 :artifactory发布16:28:47 部署工件:http://localhost:8081/artifactory/libs-release-local/com/abcdefg/covery/cdad/03_00_00_183/cdad-03_00_00_183.zip16:28:53 部署工件:http://localhost:8081/artifactory/libs-release-local/com/abcdefl/covery/cdad/03_00_00_183/cdad-03_00_00_183.jar

最佳答案

您不需要添加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
}

关于java - 是否必须定义java插件来下载gradle脚本中的依赖关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29662494/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com