SAP Hybris Commerce installer目录下的build.gradle

文件位置:

SAP Hybris Commerce installer目录下的build.gradle_第1张图片

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文件夹的绝对路径:

SAP Hybris Commerce installer目录下的build.gradle_第2张图片

getSuiteHome:获得整个Hybris目录路径,比如C:\Code\hybris670

SAP Hybris Commerce installer目录下的build.gradle_第3张图片

给每个subproject添加libs文件夹内的.jar依赖:

project.subprojects.each { subProject ->
    subProject.buildscript.dependencies {
        delegate.classpath(fileTree(dir: "${rootProject.projectDir}/libs", include: '*.jar'))
    }
}

SAP Hybris Commerce installer目录下的build.gradle_第4张图片

将标准和错误输出记录到logs文件夹下面的日志文件去:

SAP Hybris Commerce installer目录下的build.gradle_第5张图片

printRecipeDescription: 打印recipes文件夹下的子文件夹比如b2b_acc内的readme.txt的内容:

SAP Hybris Commerce installer目录下的build.gradle_第6张图片

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的原创文章,请关注公众号"汪子熙":

你可能感兴趣的:(Jerry,Wang的原创SAP技术文章,Gradle,Hybris)