From ac75cc9ba6a10c818c90a2e209f3ec9e79c35a39 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Tue, 10 Mar 2015 12:51:13 +0100 Subject: [PATCH] MIFOSX-1758 Make the dist ZIP include the community-app in apps/ via Git submodule Root build.sh, for both back-end and front-end Added -Penv=dev to incl. MariaDBj4 Include apps/**/* in ZIP, fixed UI URL in launcher, some doc Set submodule Git rev to one that actually exists on remote Don't use 'git submodule update --remote' but foreach .. build-cloudbees.sh makes npm available Better logging, and trying dev and prod dist UI --- .gitmodules | 4 ++ apps/README.md | 14 +++++ apps/community-app | 1 + build-cloudbees.sh | 8 +++ build.sh | 19 ++++++ mifosng-provider/build.gradle | 2 +- .../src/main/dist/How to run MifosX.txt | 9 ++- .../ServerWithMariaDB4jApplication.java | 59 +++++++++++++++---- 8 files changed, 102 insertions(+), 14 deletions(-) create mode 100644 .gitmodules create mode 160000 apps/community-app create mode 100755 build-cloudbees.sh create mode 100755 build.sh diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..49a6a2d60 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "apps/community-app"] + path = apps/community-app + url = https://github.com/openMF/community-app.git + branch = develop diff --git a/apps/README.md b/apps/README.md index 41a5abe34..138ceafaa 100644 --- a/apps/README.md +++ b/apps/README.md @@ -3,6 +3,20 @@ Mifos Platform Apps Community created apps built on top of mifosplatform are stored in source control repository @ https://github.com/openMF/ +To get the Git sub modules from here, use "--recursive" in your original git clone, or, if already cloned, do: + + git submodule update --init --recursive; git submodule status + +Later to update both this main repo but also get the latest from the submodule(s), do: + + git pull; git submodule update --remote + +Here is how a new Git submodule can (was originally) added here: + + git submodule add -b develop https://github.com/openMF/community-app.git + git submodule init + + The Community App (AngularJS-based) =============== https://github.com/openMF/community-app diff --git a/apps/community-app b/apps/community-app new file mode 160000 index 000000000..e4cf52eb7 --- /dev/null +++ b/apps/community-app @@ -0,0 +1 @@ +Subproject commit e4cf52eb74ab29ff34eca9191dec26351fa09aea diff --git a/build-cloudbees.sh b/build-cloudbees.sh new file mode 100755 index 000000000..c608ea16d --- /dev/null +++ b/build-cloudbees.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +# https://developer.cloudbees.com/bin/view/DEV/Node+Builds +curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node +NODE_VERSION=0.11.12 . ./use-node + +./build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 000000000..23da352fc --- /dev/null +++ b/build.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Exit the script if any command returns a non-true return value (http://www.davidpashley.com/articles/writing-robust-shell-scripts/) +set -e + +git --version +# TODO UNCOMMENT THIS once https://github.com/openMF/mifosx/pull/1291 is merged! +# git pull +# This does NOT get the most recent revision from the submodule repository. +# Instead, it only gets the revision of the submodule that is recorded in the revision of the main repository. +## NOT git submodule update --remote +# The following is very important, because even if the main (API) repo is latest, +# the sub-module initially will be a fixed old rev. and only this grabs real latest: +git submodule foreach 'git checkout develop && git pull --ff-only origin develop' + +cd apps/community-app +./build.sh +cd ../../mifosng-provider/ +./gradlew -Penv=dev clean dist diff --git a/mifosng-provider/build.gradle b/mifosng-provider/build.gradle index b8986a907..f4f2aaaf1 100644 --- a/mifosng-provider/build.gradle +++ b/mifosng-provider/build.gradle @@ -78,7 +78,7 @@ task dist(type:Zip){ } from('../apps') { fileMode = 0755 - include '*.md' + include '**/*' into('apps') } from('src/main/pentahoReports/') { diff --git a/mifosng-provider/src/main/dist/How to run MifosX.txt b/mifosng-provider/src/main/dist/How to run MifosX.txt index 00c26c824..a95f0edda 100644 --- a/mifosng-provider/src/main/dist/How to run MifosX.txt +++ b/mifosng-provider/src/main/dist/How to run MifosX.txt @@ -11,7 +11,7 @@ along with all the other source files inside a (sub-folder of) the "apps" folder directory from where runmifosx.bat/.sh is launched. The web UI front-end is then accessible under mifosng-provider/apps - for example: - https://localhost:8443/mifosng-provider/apps/community-app/index.html + https://localhost:8443/mifosng-provider/apps/community-app/dist/community-app/index.html?baseApiUrl=https://localhost:8443&tenantIdentifier=default#/home We hope you'll have an amazing experience working with MifosX! @@ -21,3 +21,10 @@ the Mifos X distribution ZIP package will (currently) have to be built using the Gradle 'dev' environment profile - e.g. using this command: ./gradlew -Penv=dev clean war dist + +We now also have a script which convenently prepares both the +UI front-end and the API back-end together into a ZIP: + + git clone --recursive https://github.com/openMF/mifosx/ + git submodule update --init --recursive; git submodule status + ./build.sh diff --git a/mifosng-provider/src/main/java/org/mifosplatform/ServerWithMariaDB4jApplication.java b/mifosng-provider/src/main/java/org/mifosplatform/ServerWithMariaDB4jApplication.java index e0d9f3a34..3ec619347 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/ServerWithMariaDB4jApplication.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/ServerWithMariaDB4jApplication.java @@ -5,19 +5,21 @@ */ package org.mifosplatform; +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; + import org.mifosplatform.infrastructure.core.boot.AbstractApplicationConfiguration; import org.mifosplatform.infrastructure.core.boot.ApplicationExitUtil; import org.mifosplatform.infrastructure.core.boot.EmbeddedTomcatWithSSLConfiguration; import org.mifosplatform.infrastructure.core.boot.db.MariaDB4jDataSourceConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Import; import org.springframework.core.io.Resource; -import java.awt.Desktop; -import java.io.IOException; -import java.net.URI; - /** * Mifos main() application which launches Mifos X in an embedded Tomcat HTTP * server (using Spring Boot), as well as an embedded database (using @@ -32,26 +34,59 @@ import java.net.URI; * @see ServerApplication for the same without the embedded MariaDB4j database */ public class ServerWithMariaDB4jApplication { + private final static Logger logger = LoggerFactory.getLogger(ServerWithMariaDB4jApplication.class); @Import({ MariaDB4jDataSourceConfiguration.class, EmbeddedTomcatWithSSLConfiguration.class }) public static class Configuration extends AbstractApplicationConfiguration { } public static void main(String[] args) throws Exception { ConfigurableApplicationContext ctx = SpringApplication.run(Configuration.class, args); - if (Desktop.isDesktopSupported()) { - Resource resource = ctx.getResource("file:" + System.getProperty("user.dir") + + if (!Desktop.isDesktopSupported()) { + logger.info("Not going to open UI homepage in local web browser, because !Desktop.isDesktopSupported()"); + + } else { + // apps/community-app/dist/community-app/index.html + Resource distResource = ctx.getResource("file:" + System.getProperty("user.dir") + System.getProperty("file.separator") + "apps" + System.getProperty("file.separator") + "community-app" + + System.getProperty("file.separator") + "dist" + + System.getProperty("file.separator") + "community-app" + System.getProperty("file.separator") + "index.html"); - if (resource.exists()) { - try { - Desktop.getDesktop().browse(URI.create("https://localhost:8443/mifosng-provider" + - "/apps/community-app/index.html?baseApiUrl=https://localhost:8443" + - "&tenantIdentifier=default#/")); - } catch (IOException e) {} + URI distURI = URI.create("https://localhost:8443/mifosng-provider" + + "/apps/community-app/dist/community-app/index.html?baseApiUrl=https://localhost:8443" + + "&tenantIdentifier=default#/"); + + // apps/community-app/app/index.html + Resource devResource = ctx.getResource("file:" + System.getProperty("user.dir") + + System.getProperty("file.separator") + "apps" + + System.getProperty("file.separator") + "community-app" + + System.getProperty("file.separator") + "app" + + System.getProperty("file.separator") + "index.html"); + URI devURI = URI.create("https://localhost:8443/mifosng-provider" + + "/apps/community-app/app/index.html?baseApiUrl=https://localhost:8443" + + "&tenantIdentifier=default#/"); + + if (distResource.exists()) { + openWebBrowser(distURI); + } else if (devResource.exists()) { + openWebBrowser(devURI); + } else { + logger.error("Cannot open Mifos X UI in browser; not found: " + distResource.toString()); } } + + // TODO Tray Icon stuff; dig out my very own old @see https://github.com/mifos/head/tree/hudsonBuild-MIFOS-5157_Launch4j-EXE_NewDist-squash1/server-jetty/src/main/java/org/mifos/server/tray + ApplicationExitUtil.waitForKeyPressToCleanlyExit(ctx); } + private static void openWebBrowser(URI uri) { + try { + logger.info("Opening Mifos X UI in browser: " + uri.toString()); + Desktop.getDesktop().browse(uri); + } catch (IOException e) { + logger.error("IOException when opening Mifos X UI in browser: " + uri.toString(), e); + } + } + }