From 7b3372525a42997ef9d169969cbe7b0f3196a9c4 Mon Sep 17 00:00:00 2001 From: ulrich <undisclosed> Date: Tue, 21 Mar 2017 09:58:38 +0000 Subject: [PATCH] Build app --- web/ui/index.html | 1 + src/java/de/uhilger/filecms/api/CompileService.java | 32 ++++++++++++++++++++++++++++++++ web/ui/ui.js | 15 +++++++++++++++ 3 files changed, 48 insertions(+), 0 deletions(-) diff --git a/src/java/de/uhilger/filecms/api/CompileService.java b/src/java/de/uhilger/filecms/api/CompileService.java index 2aaf5aa..dc914c2 100644 --- a/src/java/de/uhilger/filecms/api/CompileService.java +++ b/src/java/de/uhilger/filecms/api/CompileService.java @@ -42,6 +42,38 @@ public class CompileService extends Api { private static final Logger logger = Logger.getLogger(CompileService.class.getName()); + + /** + * Annahme: relPath zeigt auf einen Ordner, in dem ein build-Ordner die + * fertigen Klassen und ein web-Ordner die Struktur mit WEB-INF + * enthaelt. + * + * @param relPath der relative Pfad, der auf den App-Ordner verweist + * @return + */ + public String buildApp(String relPath) { + String result = "ok"; + try { + File targetDir = getTargetDir(relPath); // App-Ordner + File classesDir = new File(targetDir, "web/WEB-INF/classes"); + if(classesDir.exists()) { + FileUtils.deleteDirectory(classesDir); + } + classesDir.mkdirs(); + File buildDir = new File(targetDir, "build/"); + File[] files = buildDir.listFiles(); + for(int i = 0; i < files.length; i++) { + if(files[i].isDirectory()) { + FileUtils.copyDirectoryToDirectory(files[i], classesDir); + } else { + FileUtils.copyFileToDirectory(files[i], classesDir); + } + } + } catch(Exception ex) { + logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); + } + return result; + } public List<CompilerIssue> compileAll(String relPath) { logger.fine(relPath); diff --git a/web/ui/index.html b/web/ui/index.html index 5e15fc2..30ad3ad 100644 --- a/web/ui/index.html +++ b/web/ui/index.html @@ -120,6 +120,7 @@ <a id="m-test-2" class="dropdown-item" href="#">Compile</a> <a id="m-test-3" class="dropdown-item" href="#">Compile all</a> <a id="m-compile-results" class="dropdown-item" href="#">Compile results</a> + <a id="m-build-app" class="dropdown-item" href="#">Build app</a> <div class="dropdown-divider"></div> <a id="logout" class="dropdown-item" href="#">Abmelden</a> </div> diff --git a/web/ui/ui.js b/web/ui/ui.js index 3deda97..4e7edbd 100644 --- a/web/ui/ui.js +++ b/web/ui/ui.js @@ -65,6 +65,7 @@ $('#m-test-2').on('click', fm_menu_compile); $('#m-test-3').on('click', fm_menu_compile_all); $('#m-compile-results').on('click', fm_fusszeile_zeigen); + $('#m-build-app').on('click', fm_menu_build_app); $('#saveModal').on('hidden.bs.modal', function (e) { $('#modal_ok').attr('onclick','').unbind('click'); }); @@ -334,6 +335,10 @@ fm_compile_all(); } +function fm_menu_build_app() { + fm_build_app(); +} + function fm_mark_compile_results_in_editor(resp) { cm.clearGutter("breakpoints"); @@ -361,6 +366,16 @@ } } +function fm_build_app() { + var m = '?c=de.uhilger.filecms.api.CompileService&m=buildApp&p=' + pfad; + var u = '../svc' + m; + fm_get(u, "text", function(resp) { + $('.system-out').empty(); + $('.system-out').append('Ergebnis von Build app: ' + resp); + fm_fusszeile_zeigen(); + }); +} + function fm_compile_all() { var m = '?c=de.uhilger.filecms.api.CompileService&m=compileAll&p=' + pfad; var u = '../svc' + m; -- Gitblit v1.9.3