(Set<String> hotModules, String projectName, String solutionName)
| 60 | } |
| 61 | |
| 62 | public void pack(Set<String> hotModules, |
| 63 | String projectName, |
| 64 | String solutionName) throws Exception { |
| 65 | this.hotModules = hotModules; |
| 66 | this.projectName = projectName; |
| 67 | |
| 68 | var packages = new ArrayList<Package>(); |
| 69 | packages.add(new Package(classesHome.toFile())); |
| 70 | pack(classesHome, packages); |
| 71 | assert packages.size() == 1; |
| 72 | packages.get(0).pack(); |
| 73 | |
| 74 | if (null != projectJar) { |
| 75 | projectJar.close(); |
| 76 | projectJar = null; |
| 77 | } |
| 78 | |
| 79 | var schemasManifest = new Manifest(); |
| 80 | var schemasJarFile = Path.of(workingDir, HotManager.SchemasPrefix + solutionName + HotManager.SchemasSuffix).toFile(); |
| 81 | try (var schemasJar = new JarOutputStream(new FileOutputStream(schemasJarFile), schemasManifest)) { |
| 82 | var schemasFile = Path.of(classesDir, solutionName, "Schemas.class"); |
| 83 | var entry = new ZipEntry(solutionName + "/Schemas.class"); |
| 84 | entry.setTime(schemasFile.toFile().lastModified()); |
| 85 | schemasJar.putNextEntry(entry); |
| 86 | var bytes = Files.readAllBytes(schemasFile); |
| 87 | schemasJar.write(bytes); |
| 88 | } |
| 89 | |
| 90 | if (!providerModuleBinds.isEmpty() && !configXml.isEmpty()) { |
| 91 | var config = Config.load(configXml); |
| 92 | if (new File(config.getHotWorkingDir()).exists()) { |
| 93 | var appBase = (AppBase)Class.forName(solutionName + ".App") |
| 94 | .getConstructor((Class<?>[])null).newInstance((Object[])null); |
| 95 | appBase.createZeze(config); |
| 96 | appBase.createService(); |
| 97 | var providerApp = new ProviderApp(appBase.getZeze()); |
| 98 | appBase.createModules(); |
| 99 | providerApp.buildProviderModuleBinds(ProviderModuleBinds.load(providerModuleBinds), appBase.getModules()); |
| 100 | // 打包配置到module.jar里面,前面的关闭需要移到后面。 |
| 101 | providerApp.modules.foreach((key, value) -> packModuleConfig(findModule(appBase, key), value)); |
| 102 | } else |
| 103 | System.out.println("hotWorkingDir not exist, please prepare and re-run distribute."); |
| 104 | } else |
| 105 | System.out.println("-providerModuleBinds or -config not present, skip module config."); |
| 106 | |
| 107 | for (var e : hotModuleJars.entrySet()) { |
| 108 | //System.out.println(e.getKey() + " ---- close"); |
| 109 | e.getValue().close(); |
| 110 | } |
| 111 | hotModuleJars.clear(); |
| 112 | |
| 113 | var hotAgents = new ArrayList<HotAgent>(); |
| 114 | for (var hotManager : hotManagers) { |
| 115 | hotAgents.add(new HotAgent(hotManager)); |
| 116 | } |
| 117 | // 开始发布准备阶段。 |
| 118 | var distributeId = 817123; // 使用魔数。发布流程不并发,不需要动态多值,当然提供动态多值更加完善。 |
| 119 | for (var hotAgent : hotAgents) { |
no test coverage detected