|
|
@@ -1,29 +1,34 @@
|
|
|
package cn.reghao.autodop.dmaster.app.service.build;
|
|
|
|
|
|
-import cn.reghao.autodop.dmaster.app.service.build.tools.compiler.*;
|
|
|
-import cn.reghao.autodop.dmaster.app.service.build.tools.packer.*;
|
|
|
+import cn.reghao.autodop.dmaster.app.pojo.build.AppBuild;
|
|
|
+import cn.reghao.autodop.dmaster.app.pojo.build.compile.AppCompile;
|
|
|
+import cn.reghao.autodop.dmaster.app.pojo.build.pack.AppPack;
|
|
|
+import cn.reghao.autodop.dmaster.app.pojo.constant.CompilerType;
|
|
|
+import cn.reghao.autodop.dmaster.app.pojo.constant.PackerType;
|
|
|
+import cn.reghao.autodop.dmaster.app.pojo.deploy.AppDeploy;
|
|
|
+import cn.reghao.autodop.dmaster.app.pojo.orchestration.AppOrchestration;
|
|
|
+import cn.reghao.autodop.dmaster.app.service.tools.compiler.*;
|
|
|
+import cn.reghao.autodop.dmaster.app.service.tools.packer.*;
|
|
|
+import cn.reghao.autodop.dmaster.app.service.tools.updater.CodeUpdater;
|
|
|
import cn.reghao.autodop.dmaster.orchestrate.pojo.SysConfig;
|
|
|
-import cn.reghao.autodop.dmaster.orchestrate.pojo.build.AppBuild;
|
|
|
-import cn.reghao.autodop.dmaster.orchestrate.pojo.tools.AppPacker;
|
|
|
-import cn.reghao.autodop.dmaster.orchestrate.pojo.tools.CodeCompiler;
|
|
|
-import cn.reghao.autodop.dmaster.orchestrate.pojo.orchestration.AppOrchestration;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
/**
|
|
|
- * 应用集成,根据 AppOrchestration 中的值完成编译,打包的配置
|
|
|
+ * 应用构建部署,根据 AppOrchestration 的值完成应用构建和部署的配置
|
|
|
*
|
|
|
* @author reghao
|
|
|
* @date 2019-10-09 10:54:43
|
|
|
*/
|
|
|
@Slf4j
|
|
|
-public class AppIntegrate {
|
|
|
+public class AppBuildDeploy {
|
|
|
private final String packDir = SysConfig.packDir;
|
|
|
private AppOrchestration app;
|
|
|
+ private CodeUpdater codeUpdater;
|
|
|
private PreCompile preCompile;
|
|
|
- private CompileCode compileCode;
|
|
|
- private PackApp packApp;
|
|
|
+ private CodeCompiler codeCompiler;
|
|
|
+ private CodePacker codePacker;
|
|
|
|
|
|
- public AppIntegrate() {
|
|
|
+ public AppBuildDeploy() {
|
|
|
}
|
|
|
|
|
|
public void setApp(AppOrchestration app) {
|
|
|
@@ -31,45 +36,45 @@ public class AppIntegrate {
|
|
|
init();
|
|
|
}
|
|
|
|
|
|
- public AppIntegrate(AppOrchestration app) {
|
|
|
+ public AppBuildDeploy(AppOrchestration app) {
|
|
|
this.app = app;
|
|
|
init();
|
|
|
}
|
|
|
|
|
|
private void init() {
|
|
|
- AppBuild appBuild = app.getBuild();
|
|
|
- // 编译初始化
|
|
|
- CodeCompiler compiler = appBuild.getCodeCompiler();
|
|
|
- if ("dotnet".equals(compiler.getCompilerType())) {
|
|
|
+ AppBuild appBuild = app.getAppBuild();
|
|
|
+ // 初始化编译配置
|
|
|
+ AppCompile appCompile = appBuild.getAppCompile();
|
|
|
+ if (appCompile.getCompilerType().equals(CompilerType.dotnet.name())) {
|
|
|
preCompile = new DotnetPreCompile();
|
|
|
- compileCode = new ShellCompile(compiler.getScript());
|
|
|
- } else if ("maven".equals(compiler.getCompilerType())) {
|
|
|
- compileCode = new Maven();
|
|
|
- } else if ("static".equals(compiler.getCompilerType())) {
|
|
|
- compileCode = new DefaultCompile();
|
|
|
- log.warn("静态应用,不需要编译器");
|
|
|
- } else {
|
|
|
- //throw new Exception("");
|
|
|
- log.error("没有编译器");
|
|
|
+ codeCompiler = new ShellCompiler(appCompile.getScript());
|
|
|
+ } else if (appCompile.getCompilerType().equals(CompilerType.maven.name())) {
|
|
|
+ codeCompiler = new MavenCompiler("");
|
|
|
+ } else if (appCompile.getCompilerType().equals(CompilerType.none.name())) {
|
|
|
+ // 静态应用,不需要编译器
|
|
|
+ codeCompiler = new DefaultCompiler();
|
|
|
}
|
|
|
|
|
|
- // 打包初始化
|
|
|
- AppPacker packer = appBuild.getAppPacker();
|
|
|
- if ("docker".equals(packer.getPackerType())) {
|
|
|
- packApp = new DockerPack(packer);
|
|
|
- } else if ("maven".equals(packer.getPackerType())) {
|
|
|
-
|
|
|
- } else if ("zip".equals(packer.getPackerType())) {
|
|
|
- packApp = new ZipPack(packDir);
|
|
|
- } else if ("zip-remote".equals(packer.getPackerType())) {
|
|
|
- packApp = new ZipRemotePack(packDir);
|
|
|
+ // 初始化打包配置
|
|
|
+ AppPack appPack = appBuild.getAppPack();
|
|
|
+ if (appPack.getPackerType().equals(PackerType.docker.name())) {
|
|
|
+ codePacker = new DockerPack(appPack.getAppRootPath());
|
|
|
+ } else if (appPack.getPackerType().equals(PackerType.maven.name())) {
|
|
|
+ codePacker = null;
|
|
|
+ } else if (appPack.getPackerType().equals(PackerType.zip.name())) {
|
|
|
+ codePacker = new ZipPack(packDir);
|
|
|
+ } else if (appPack.getPackerType().equals(PackerType.dotnetBinary.name())) {
|
|
|
+ codePacker = null;
|
|
|
}
|
|
|
|
|
|
// TODO 特定于 dnkt-mgr 项目的处理
|
|
|
- if (app.getIdentifier().startsWith("dnkt-mgr")) {
|
|
|
+ if (app.getAppId().startsWith("dnkt-mgr")) {
|
|
|
preCompile = new DnktMgrPreCompile();
|
|
|
- packApp = new DnktMgrZipPack(packer);
|
|
|
+ codePacker = new DnktMgrZipPack(appPack.getAppRootPath());
|
|
|
}
|
|
|
+
|
|
|
+ // 初始化部署配置
|
|
|
+ AppDeploy appDeploy = app.getAppDeploy();
|
|
|
}
|
|
|
|
|
|
public boolean needPreCompile() {
|
|
|
@@ -85,25 +90,16 @@ public class AppIntegrate {
|
|
|
preCompile.preCompile(app, appEntryDir);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 编译源码
|
|
|
- * TODO 多线程时会阻塞
|
|
|
- *
|
|
|
- * @param dir 源码目录
|
|
|
- * @date 2019-11-07 下午2:02
|
|
|
- */
|
|
|
- public void compile(String dir) throws Exception {
|
|
|
- compileCode.compile(dir);
|
|
|
+ public void update() {
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 打包应用
|
|
|
- *
|
|
|
- * @param
|
|
|
- * @return
|
|
|
- * @date 2019-11-07 下午2:03
|
|
|
- */
|
|
|
- public void pack(String appId, String version, String appEntryDir) throws Exception {
|
|
|
- packApp.pack(appId, version, appEntryDir);
|
|
|
+ public void compile() {
|
|
|
+ }
|
|
|
+
|
|
|
+ public void pack() {
|
|
|
+ }
|
|
|
+
|
|
|
+ public void deploy() {
|
|
|
}
|
|
|
}
|