SAPHybris使用recipe進(jìn)行安裝時(shí),是如何執(zhí)行ant命令的?

打開Hybris安裝文件夾下的recipes,隨便打開一個(gè)recipe的build.gradle文件,發(fā)現(xiàn)使用了installer-platform-plugin和installer-addon-plugin這兩個(gè)plugin. Groovy setup任務(wù)的邏輯,也就是使用這兩個(gè)plugin里的實(shí)現(xiàn),根據(jù)config實(shí)例化platform對(duì)象,然后調(diào)用其setup方法和executeAntTarget方法。

創(chuàng)新互聯(lián)專注于鹽山網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠為您提供鹽山營(yíng)銷型網(wǎng)站建設(shè),鹽山網(wǎng)站制作、鹽山網(wǎng)頁設(shè)計(jì)、鹽山網(wǎng)站官網(wǎng)定制、重慶小程序開發(fā)服務(wù),打造鹽山網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供鹽山網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。

SAP Hybris使用recipe進(jìn)行安裝時(shí),是如何執(zhí)行ant命令的?

這兩個(gè)方法的實(shí)現(xiàn)源代碼在哪里?這就是本文所要描述的內(nèi)容。

去docs文件夾里可以找到插件的實(shí)現(xiàn)源代碼:

SAP Hybris使用recipe進(jìn)行安裝時(shí),是如何執(zhí)行ant命令的?

到源代碼里根據(jù)executeAntTarget進(jìn)行搜索:

SAP Hybris使用recipe進(jìn)行安裝時(shí),是如何執(zhí)行ant命令的?

在AbstractPlatform.groovy里找到了executeAntTarget的實(shí)現(xiàn)邏輯,發(fā)現(xiàn)其delegate到了成員屬性antExecutor里:

SAP Hybris使用recipe進(jìn)行安裝時(shí),是如何執(zhí)行ant命令的?

這個(gè)antExecutor的類型是HybrisAntExecutor:

SAP Hybris使用recipe進(jìn)行安裝時(shí),是如何執(zhí)行ant命令的?

找到HybrisAntExcutor,發(fā)現(xiàn)其只不過是調(diào)用類HybrisPluginUtils的靜態(tài)方法:

SAP Hybris使用recipe進(jìn)行安裝時(shí),是如何執(zhí)行ant命令的?

靜態(tài)方法之一:runProcess

實(shí)現(xiàn)核心:

private static void runExternalProcess(String workDir, String[] command, Closure closure) {
        def builder = new DefaultExecHandleBuilder()
        builder.setWorkingDir((new File(workDir)).absolutePath)
        builder.setCommandLine(command)
        if (closure) closure.call(builder)
        def handle = builder.build()
        handle.start()
        def result = handle.waitForFinish()
        if (result.getExitValue() != 0) {
            throw new IllegalStateException("external process returned non-zero exit code, command: ${command}")
        }
    }

運(yùn)行外部程序的方法,使用的是Groovy SDK提供的import org.gradle.process.internal.DefaultExecHandleBuilder.

靜態(tài)方法之二:isWindowsOs

import org.apache.tools.ant.taskdefs.condition.Os

SAP Hybris使用recipe進(jìn)行安裝時(shí),是如何執(zhí)行ant命令的?

HybrisAntExcutor方法之一:getWindowsAntCmd

private String[] getWindowsAntCmd(String antArgs, String antOpts) {
        def antPreCommand = "set \"ANT_OPTS=${antOpts}\""
        antPreCommand += " & set \"PLATFORM_HOME=${platformHome}\""
        antPreCommand += " & set \"ANT_HOME=${platformHome}\\apache-ant-1.9.1\""
        antPreCommand += " & set \"PATH=${platformHome}\\apache-ant-1.9.1\\bin;%PATH%\""
        String antCommand = "${antPreCommand} & ant ${antArgs}"
        ['cmd', '/c', antCommand]
    }

要獲取更多Jerry的原創(chuàng)文章,請(qǐng)關(guān)注公眾號(hào)"汪子熙":

SAP Hybris使用recipe進(jìn)行安裝時(shí),是如何執(zhí)行ant命令的?

本文名稱:SAPHybris使用recipe進(jìn)行安裝時(shí),是如何執(zhí)行ant命令的?
網(wǎng)頁地址:http://bm7419.com/article14/goeide.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗(yàn)、網(wǎng)站改版、面包屑導(dǎo)航、品牌網(wǎng)站建設(shè)網(wǎng)站排名、標(biāo)簽優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

營(yíng)銷型網(wǎng)站建設(shè)