文件位置:
project.ext.installerHome = project.projectDir
project.ext.installerWorkDir = Paths.get(project.installerHome as String, 'work').toAbsolutePath().toString()
project.ext.customConfigDir = Paths.get(project.installerHome as String, 'customconfig').toAbsolutePath().toString()
project.ext.suiteHome = getSuiteHome()
上面的代码获得customconfig和work文件夹的绝对路径:
getSuiteHome:获得整个Hybris目录路径,比如C:\Code\hybris670
给每个subproject添加libs文件夹内的.jar依赖:
project.subprojects.each { subProject ->
subProject.buildscript.dependencies {
delegate.classpath(fileTree(dir: "${rootProject.projectDir}/libs", include: '*.jar'))
}
}
将标准和错误输出记录到logs文件夹下面的日志文件去:
printRecipeDescription: 打印recipes文件夹下的子文件夹比如b2b_acc内的readme.txt的内容:
subprojects {
afterEvaluate { subProject ->
def setupTask = createTaskInSubProject subProject, 'setup', 'Setups platform (writes configuration into local.properties, localextensions.xml)'
def buildSystemTask = createTaskInSubProject subProject, 'buildSystem', 'Builds platform'
def initializeTask = createTaskInSubProject subProject, 'initialize', 'Initializes platform fully'
def initializeJunitTask = createTaskInSubProject subProject, 'initializeJunit', 'Initializes platform JUnitTenant'
def startTask = createTaskInSubProject subProject, 'start', 'Starts platform interactively'
def startInBackgroundTask = createTaskInSubProject subProject, 'startInBackground', 'Starts platform in background'
def stopInBackgroundTask = createTaskInSubProject subProject, 'stopInBackground', 'Stops platform in background'
def testJunitTask = createTaskInSubProject subProject, 'testJunit', 'Runs JUnit tests'
def testInitializeTask = createTaskInSubProject subProject, 'testInitialize', 'Runs initialization tests'
def testServerTask = createTaskInSubProject subProject, 'testServer', 'Runs JUnit tests'
def createImageStructureTask = createTaskInSubProject subProject, 'createImagesStructure', 'Creates images structure'
def buildDockerImagesTask = createTaskInSubProject subProject, 'buildImages', 'Builds docker images'
buildDockerImagesTask.dependsOn = [createImageStructureTask]
def pushDockerImagesTask = createTaskInSubProject subProject, 'pushImages', 'Pushes docker images'
pushDockerImagesTask.dependsOn = [buildDockerImagesTask]
buildSystemTask.mustRunAfter setupTask
initializeTask.mustRunAfter buildSystemTask
initializeJunitTask.mustRunAfter buildSystemTask
startTask.mustRunAfter initializeTask
startInBackgroundTask.mustRunAfter initializeTask
stopInBackgroundTask.mustRunAfter testServerTask
testJunitTask.mustRunAfter initializeJunitTask
testInitializeTask.mustRunAfter initializeTask
testServerTask.mustRunAfter startInBackgroundTask
def performTask = createTaskInSubProject subProject, 'perform', 'Performs setup, build, initialize and start - in this order'
performTask.dependsOn = [setupTask, buildSystemTask, initializeTask, startTask]
def performTestJunitTask = createTaskInSubProject subProject, 'performTestJunit', 'Performs setup, buildSystem, initializeJunit, testJunit - in this order'
performTestJunitTask.dependsOn = [setupTask, buildSystemTask, initializeJunitTask, testJunitTask]
def performTestInitializeTask = createTaskInSubProject subProject, 'performTestInitialize', 'Performs setup, buildSystem, initialize, testInitialize - in this order'
performTestInitializeTask.dependsOn = [setupTask, buildSystemTask, initializeTask, testInitializeTask]
def performTestServerTask = createTaskInSubProject subProject, 'performTestServer', 'Performs setup, buildSystem, initialize, startInBackground, testServer - in this order'
performTestServerTask.dependsOn = [setupTask, buildSystemTask, initializeTask, startInBackgroundTask, testServerTask, stopInBackgroundTask]
}
}
创建各种task并设置依赖关系:
subprojects {
afterEvaluate { subProject ->
def setupTask = createTaskInSubProject subProject, 'setup', 'Setups platform (writes configuration into local.properties, localextensions.xml)'
def buildSystemTask = createTaskInSubProject subProject, 'buildSystem', 'Builds platform'
def initializeTask = createTaskInSubProject subProject, 'initialize', 'Initializes platform fully'
def initializeJunitTask = createTaskInSubProject subProject, 'initializeJunit', 'Initializes platform JUnitTenant'
def startTask = createTaskInSubProject subProject, 'start', 'Starts platform interactively'
def startInBackgroundTask = createTaskInSubProject subProject, 'startInBackground', 'Starts platform in background'
def stopInBackgroundTask = createTaskInSubProject subProject, 'stopInBackground', 'Stops platform in background'
def testJunitTask = createTaskInSubProject subProject, 'testJunit', 'Runs JUnit tests'
def testInitializeTask = createTaskInSubProject subProject, 'testInitialize', 'Runs initialization tests'
def testServerTask = createTaskInSubProject subProject, 'testServer', 'Runs JUnit tests'
def createImageStructureTask = createTaskInSubProject subProject, 'createImagesStructure', 'Creates images structure'
def buildDockerImagesTask = createTaskInSubProject subProject, 'buildImages', 'Builds docker images'
buildDockerImagesTask.dependsOn = [createImageStructureTask]
def pushDockerImagesTask = createTaskInSubProject subProject, 'pushImages', 'Pushes docker images'
pushDockerImagesTask.dependsOn = [buildDockerImagesTask]
buildSystemTask.mustRunAfter setupTask
initializeTask.mustRunAfter buildSystemTask
initializeJunitTask.mustRunAfter buildSystemTask
startTask.mustRunAfter initializeTask
startInBackgroundTask.mustRunAfter initializeTask
stopInBackgroundTask.mustRunAfter testServerTask
testJunitTask.mustRunAfter initializeJunitTask
testInitializeTask.mustRunAfter initializeTask
testServerTask.mustRunAfter startInBackgroundTask
def performTask = createTaskInSubProject subProject, 'perform', 'Performs setup, build, initialize and start - in this order'
performTask.dependsOn = [setupTask, buildSystemTask, initializeTask, startTask]
def performTestJunitTask = createTaskInSubProject subProject, 'performTestJunit', 'Performs setup, buildSystem, initializeJunit, testJunit - in this order'
performTestJunitTask.dependsOn = [setupTask, buildSystemTask, initializeJunitTask, testJunitTask]
def performTestInitializeTask = createTaskInSubProject subProject, 'performTestInitialize', 'Performs setup, buildSystem, initialize, testInitialize - in this order'
performTestInitializeTask.dependsOn = [setupTask, buildSystemTask, initializeTask, testInitializeTask]
def performTestServerTask = createTaskInSubProject subProject, 'performTestServer', 'Performs setup, buildSystem, initialize, startInBackground, testServer - in this order'
performTestServerTask.dependsOn = [setupTask, buildSystemTask, initializeTask, startInBackgroundTask, testServerTask, stopInBackgroundTask]
}
}
要获取更多Jerry的原创文章,请关注公众号"汪子熙":