将 Gradle 配置转换为 Ant 路径
Convert Gradle configuration into Ant path
如何将 Gradle 配置转换为 Ant 路径?
build.gradle
片段
configurations {
install
}
dependencies {
install "com.oracle:ojdbc6:12.1.0.2"
install project(':myproject')
install ...
}
需要 install
配置(包括其传递依赖项)作为 ant 任务的参数:
ant.updateDatabase(classpathref: 'installCpRef')
使用 ant.path(id: 'installCpRef', location: configurations.install.asPath)
不起作用,因为 ant.path
将位置视为单个路径规范。这仅在路径上只有一个元素时有效。
一个解决方案是像那样手动指定所有依赖项
ant.path(id: 'install.cp') {
fileset(dir: '<aPath>', includes: '<aJar>')
fileset(dir: '<anotherPath>') {
include (name: '**/*.jar')
}
}
这意味着重新声明所有依赖项,包括传递依赖项,这是不可接受的。
如何自动将 configuration.install
转换为 ant 路径?
谢谢
请参阅 ant 文档path-like structures
The location attribute specifies a single file or directory relative
to the project's base directory (or an absolute filename), while the
path attribute accepts colon- or semicolon-separated lists of
locations.
这应该有效:
ant.classpath(id: 'install.cp', path: configurations.install.asPath)
ant.updateDatabase(classpathref: 'install.cp')
如何将 Gradle 配置转换为 Ant 路径?
build.gradle
片段
configurations {
install
}
dependencies {
install "com.oracle:ojdbc6:12.1.0.2"
install project(':myproject')
install ...
}
需要 install
配置(包括其传递依赖项)作为 ant 任务的参数:
ant.updateDatabase(classpathref: 'installCpRef')
使用 ant.path(id: 'installCpRef', location: configurations.install.asPath)
不起作用,因为 ant.path
将位置视为单个路径规范。这仅在路径上只有一个元素时有效。
一个解决方案是像那样手动指定所有依赖项
ant.path(id: 'install.cp') {
fileset(dir: '<aPath>', includes: '<aJar>')
fileset(dir: '<anotherPath>') {
include (name: '**/*.jar')
}
}
这意味着重新声明所有依赖项,包括传递依赖项,这是不可接受的。
如何自动将 configuration.install
转换为 ant 路径?
谢谢
请参阅 ant 文档path-like structures
The location attribute specifies a single file or directory relative to the project's base directory (or an absolute filename), while the path attribute accepts colon- or semicolon-separated lists of locations.
这应该有效:
ant.classpath(id: 'install.cp', path: configurations.install.asPath)
ant.updateDatabase(classpathref: 'install.cp')