我们正在使用gradle构建我们的一个应用程序,其中一部分分发包含了一个外部的jar文件,该文件不是运行时依赖项,而是在config文件夹中。该jar文件作为应用程序安装的一部分是必需的,并且包含一些自定义ant任务。
我们的构建脚本依赖关系如下:
我该如何访问并将
我们的构建脚本依赖关系如下:
buildscript {
...
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1'
classpath 'my-group:custom-tasks:1.2.3'
}
}
我该如何访问并将
custom-task-1.2.3.jar
复制到特定文件夹中,以便我可以将其包含在我的分发中?类似下面这样的方式: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.configurations.classpath
应该被使用而不是buidscript.dependencies.classpath
?是我自己的问题还是API有点不一致。无论如何,感谢您的有效回答。 - Julian