import org.apache.tools.ant.filters.ReplaceTokens 导入一个类
apply plugin: 'java' 引入插件
apply from: 'common.gradle'引入gradle文件
ext.os = System.getProperty('os.name').toLowerCase()
ext.pluginsDir = "${rootDir}/specialpurpose"
全局属性,”ext.XXX“
def jvmArguments = ['-Xms128M', '-Xmx1024M'] 这个应该是局部变零吧
ext.ofbizMainClass = 'org.apache.ofbiz.base.start.Start' 这个比较重要,启动类
// Java compile options, syntax gradlew -PXlint build
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
if (project.hasProperty('Xlint')) {
options.compilerArgs << "-Xlint"
}
}
编译时,设置的编码类型。task.withType 任务类型
def File gitFooterFile = file("${rootDir}/runtime/GitInfo.ftl")
def File svnFooterFile = file("${rootDir}/runtime/SvnInfo.ftl")
def Object xxx 这也是一种定义类型
defaultTasks 'build' 默认任务
、、、、、、、、、、、、、、、、、、华丽的分割线、、、、、、、、、、、、、、、
allprojects {
repositories{
jcenter()
mavenLocal()
}
}
subprojects {
configurations {
// compile-time plugin libraries
pluginLibsCompile
// runtime plugin libraries
pluginLibsRuntime
//compile-only libraries
pluginLibsCompileOnly
}
}
configurations {
junitReport {
description = 'libraries needed to run junitreport for OFBiz unit tests'
}
ofbizPlugins {
description = 'ofbiz plugin dependencies configuration'
transitive = true
}
}
这里风格陡然一变。
理解为仍然定义属性 ,理解为数组形式呗,也可以立即为json。比如取值:
configurations.
junitReport.
description =
'ofbiz plugin dependencies configuration'
dependencies {
// ofbiz compile libs
compile 'apache-xerces:xercesImpl:2.9.1'
.....
// ofbiz runtime libs
runtime 'de.odysseus.juel:juel-spi:2.2.7'
。。。。
}
这里就是依赖jar包了。
def activateAndInstallPlugin(pluginId) {
activatePlugin pluginId
def gradleRunner = os.contains('windows') ? 'gradlew.bat' : './gradlew'
exec { commandLine gradleRunner, 'installPlugin', "-PpluginId=${pluginId}" }
}
定义函数
build.gradle里常见格式,都见过面了,慢慢细细研究吧