소스 검색

根据 CompileType 来选择编译器

reghao 2 년 전
부모
커밋
d7f592ed7b
1개의 변경된 파일9개의 추가작업 그리고 3개의 파일을 삭제
  1. 9 3
      common/src/main/java/cn/reghao/devops/common/build/chain/impl/CompileHandler.java

+ 9 - 3
common/src/main/java/cn/reghao/devops/common/build/chain/impl/CompileHandler.java

@@ -3,7 +3,9 @@ package cn.reghao.devops.common.build.chain.impl;
 import cn.reghao.devops.common.build.chain.BuildTools;
 import cn.reghao.devops.common.build.chain.Handler;
 import cn.reghao.devops.common.build.model.AppDto;
+import cn.reghao.devops.common.build.model.CompilerDto;
 import cn.reghao.devops.common.build.model.LocalBuildDir;
+import cn.reghao.devops.common.build.model.constant.CompileType;
 import cn.reghao.devops.common.build.tool.compiler.CodeCompiler;
 import lombok.extern.slf4j.Slf4j;
 
@@ -25,14 +27,18 @@ public class CompileHandler extends Handler<BuildChainParam, BuildChainResult> {
         String appCompileDir = LocalBuildDir.compileDir + File.separator + appId;
         String compileDir = appCompileDir + File.separator + appDto.getProjDirname();
         long start = System.currentTimeMillis();
-        if (appDto.getAppType().equals("maven")) {
+        CompilerDto compilerDto = appDto.getBuildConfigDto().getCompilerDto();
+        String compileType = compilerDto.getType();
+        if (compileType.equals(CompileType.maven.getName())) {
             codeCompiler.compile(appId, compileDir, appDto.getEnv(), appDto.getAppRootPath());
-        } else {
+        } else if (compileType.equals(CompileType.shell.getName())) {
             codeCompiler.compile(appId, compileDir);
+        } else {
+            String errMsg = String.format("unknown compile type %s with app %s", compileType, appId);
+            throw new Exception(errMsg);
         }
 
         buildResult.getBuildConsumedDto().setCompileConsumed(System.currentTimeMillis()-start);
-
         if (next != null) {
             next.handle(buildParam, buildResult);
         }