Gradle 渐变将生成脚本依赖项复制到文件夹
我们正在使用gradle构建一个应用程序,我希望在发行版的一部分中包含一个外部jar,它不是配置文件夹中的运行时依赖项。这个jar是应用程序安装的一部分,它包含一些定制的ant任务 我们的构建脚本依赖项如下所示:Gradle 渐变将生成脚本依赖项复制到文件夹,gradle,Gradle,我们正在使用gradle构建一个应用程序,我希望在发行版的一部分中包含一个外部jar,它不是配置文件夹中的运行时依赖项。这个jar是应用程序安装的一部分,它包含一些定制的ant任务 我们的构建脚本依赖项如下所示: buildscript { ... dependencies { classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1' classpath 'my-group:
buildscript {
...
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1'
classpath 'my-group:custom-tasks:1.2.3'
}
}
task copyCustomTasks {
doLast {
copy {
// This below is a make up to express what I want
from buildscript.dependencies
include 'custom-tasks*.jar'
into "$buildDir/config"
}
}
}
如何访问并将custom-task-1.2.3.jar
复制到某个文件夹中,以便将其包含在分发版中?如下所示:
buildscript {
...
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1'
classpath 'my-group:custom-tasks:1.2.3'
}
}
task copyCustomTasks {
doLast {
copy {
// This below is a make up to express what I want
from buildscript.dependencies
include 'custom-tasks*.jar'
into "$buildDir/config"
}
}
}
如果这不是gradle做事的方式,请让我知道我有什么选择
提前感谢您的帮助
更新
我通过创建一个额外的配置以不同的方式解决了问题。不过,我仍然有兴趣了解如何在运行时访问构建脚本依赖项。再次感谢您的投入
configurations {
install {
description = "application install classpath"
transitive = true
}
}
...
dependencies {
...
install('my-group:custom-tasks:1.2.3')
...
}
...
task copyInstallDeps {
doLast {
copy {
from configurations.install
into "$buildDir/config"
}
}
}
你很接近:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.guava:guava:18.0'
}
}
task copyLibs(type: Copy) {
from buildscript.configurations.classpath
into 'lib'
}
谢谢欧泊。看起来我缺少了一些研究GradleAPI的基本策略。当您看到buildscript有一个dependencies条目时,您会假设这是您应该指向它的方式。记住/认识到应该使用
buildscript.configurations.classpath
而不是buildscript.dependentials.classpath
的简单方法是什么?是我还是API有点不一致。无论如何,谢谢你的有效回答。