Jelajahi Sumber

milestone dmaster 测试环境版本

不使用 compileDir, 直接在 localRepo 目录构建代码
调整 ShellCompiler, 使之可执行多条命令
reghao 4 tahun lalu
induk
melakukan
e44e6ae58b

+ 2 - 0
.gitignore

@@ -34,3 +34,5 @@ common/target/
 dagent/target/
 
 dmaster/target/
+
+*.jar

+ 3 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/AppBuilder.java

@@ -77,7 +77,8 @@ public class AppBuilder {
 
     private void initLocalDir() {
         appLocalRepo = LocalBuildDir.localRepo + File.separator + app.getAppId();
-        appCompileDir = LocalBuildDir.compileDir + File.separator + app.getAppId();
+        //appCompileDir = LocalBuildDir.compileDir + File.separator + app.getAppId();
+        appCompileDir = LocalBuildDir.localRepo + File.separator + app.getAppId();
         appPackDir = LocalBuildDir.packDir + File.separator + app.getAppId();
     }
 
@@ -152,7 +153,7 @@ public class AppBuilder {
         if (updateStatus.isUpdated) {
             latestCommitInfo = updateStatus.getLatestCommitInfo();
             // 将代码由本地仓库复制到编译目录
-            BuilderUtil.copyToCompileDir(local, app);
+            //BuilderUtil.copyToCompileDir(local, app);
         }
 
         return latestCommitInfo;

+ 8 - 5
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/util/buildtool/compiler/ShellCompiler.java

@@ -13,18 +13,21 @@ import cn.reghao.autodop.dmaster.app.model.po.config.build.CompilerConfig;
  */
 public class ShellCompiler implements CodeCompiler {
     private final ShellExecutor shell;
-    private final String[] compileCmd;
+    private final String[] compileCmds;
 
     public ShellCompiler(CompilerConfig compilerConfig) {
-        this.compileCmd = compilerConfig.getCompileCmd().split("\\s+");
+        this.compileCmds = compilerConfig.getCompileCmd().split(" && ");
         this.shell = new ShellExecutor();
     }
 
     @Override
     public void compile(String appId, String appCompileHome) throws Exception {
-        ShellResult result = shell.exec(appCompileHome, compileCmd);
-        if (!result.isSuccess()) {
-            throw new Exception(JsonConverter.objectToJson(result.getResult()));
+        ShellResult result;
+        for (String compileCmd : compileCmds) {
+            result = shell.exec(appCompileHome, compileCmd.split("\\s+"));
+            if (!result.isSuccess()) {
+                throw new Exception(JsonConverter.objectToJson(result.getResult()));
+            }
         }
     }
 }