我有以下 ext.libraries 定义,我想将其公开给我使用 gradle 构建的所有项目。我该怎么做。我在哪里可以定义它,以便它对我的项目全局可用?
我的项目结构如下:
--projects
----BaseFrameWork
----ProjectA
----ProjectB
settings.gradle(项目目录)
includeFlat 'BaseFramework', 'ProjectA', 'ProjectB'
build.gradle(项目目录)
ext.libraries = [
lib_core:[
":junit:4.0:",
":log4j:1.2.8:",
":ojdbc6:",
":struts:1.1-tiger:"
],
lib_jaxb: [
":jaxb-api:2.1.3:",
":jaxb-impl:2.1.3:"
]
]
allprojects {
apply plugin: 'java'
}
build.gradle (BaseFramework 目录)
apply plugin: 'java'
sourceSets.main.java.srcDir 'src/java'
println "The root project is: " + rootProject
compileJava {
options.compilerArgs << '-nowarn'
}
jar {
manifest {
attributes("Implementation-Title": "BaseFramework", "Implementation-Version": "1")
}
from ('./META-INF/') {
include 'DomainConfig.xml'
into('META-INF')
}
}
repositories {
flatDir dirs: "D:/myrepo"
}
dependencies {
compile libraries.lib_commons
compile libraries.lib_core
compile libraries.lib_jaxb
}
然后我尝试以下并得到一个错误。它无法在根 build.gradle 文件中看到我的库属性。看起来它也将我的 BaseFramework 项目视为根?
D:\projects>cd BaseFramework
D:\projects\BaseFramework>gradle build
The root project is: root project 'BaseFramework'
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\prod\BaseFramework\build.gradle' line: 25
* What went wrong:
A problem occurred evaluating root project 'BaseFramework'.
> Could not find property 'libraries' on root project 'BaseFramework'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2.624 secs
D:\projects\BaseFramework>
请帮忙 :(