diff --git a/mifosng-provider/build.gradle b/mifosng-provider/build.gradle index 33add0473..6bdd2a81e 100644 --- a/mifosng-provider/build.gradle +++ b/mifosng-provider/build.gradle @@ -65,12 +65,17 @@ if (project.hasProperty('env') && project.getProperty('env') == 'dev') { } task dist(type:Zip){ - baseName= 'mifosplatform' + baseName = 'mifosplatform' version = qualifyVersionIfNecessary(releaseVersion) + includeEmptyDirs = true from('../') { fileMode = 0755 include '*.md' } + from('src/main/dist') { + fileMode = 0755 + include '*' + } from('../apps') { fileMode = 0755 include '*.md' diff --git a/mifosng-provider/src/main/dist/How to run MifosX.txt b/mifosng-provider/src/main/dist/How to run MifosX.txt new file mode 100644 index 000000000..1546ce34f --- /dev/null +++ b/mifosng-provider/src/main/dist/How to run MifosX.txt @@ -0,0 +1,15 @@ +Welcome to the Mifos community! +=============================== + +Depending on the OS you're running, you should have "runmifosx.sh" (for Linux and Mac) and +"runmifosx.bat" (for Windows) in this directory. These are small scripts that allow you to +run MifosX on your computer locally. To be able to run MifosX, just double-click on the script, +that is, "runmifosx.sh" if you are on Linux or Mac, or "runmifosx.bat" if you are on Windows. + +Note +==== +If you have a web front-end that you want to use along with the backend server, put your index.html +inside the "web" folder along with all the other source files. +P.S.: the index.html should be in the "web" folder itself + +We hope you'll have an amazing experience working with MifosX. diff --git a/mifosng-provider/src/main/dist/runmifosx.bat b/mifosng-provider/src/main/dist/runmifosx.bat new file mode 100644 index 000000000..5bcdb5890 --- /dev/null +++ b/mifosng-provider/src/main/dist/runmifosx.bat @@ -0,0 +1,10 @@ +java -version >nul 2>&1 && ( + echo "Found Java." +) || ( + echo "Java should be installed to run MifosX." + exit +) + +echo "Starting MifosX ..... " + +java -Djava.awt.headless=false -jar mifosng-provider.war diff --git a/mifosng-provider/src/main/dist/runmifosx.sh b/mifosng-provider/src/main/dist/runmifosx.sh new file mode 100755 index 000000000..05c97aaeb --- /dev/null +++ b/mifosng-provider/src/main/dist/runmifosx.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# First of all, check if Java is installed on this computer + +if hash java; then + echo "Found Java:" + echo $(java -version) +else + echo "Java should be installed to run MifosX." + exit +fi + +echo "Starting MifosX ..... " + +java -Djava.awt.headless=false -jar mifosng-provider.war diff --git a/mifosng-provider/src/main/java/org/mifosplatform/ServerWithMariaDB4jApplication.java b/mifosng-provider/src/main/java/org/mifosplatform/ServerWithMariaDB4jApplication.java index c489ac974..8c3f8d179 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/ServerWithMariaDB4jApplication.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/ServerWithMariaDB4jApplication.java @@ -12,6 +12,11 @@ import org.mifosplatform.infrastructure.core.boot.db.MariaDB4jDataSourceConfigur 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 @@ -33,6 +38,18 @@ public class ServerWithMariaDB4jApplication { 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") + + System.getProperty("file.separator") + "web" + + System.getProperty("file.separator") + "index.html"); + if (resource.exists()) { + try { + Desktop.getDesktop().browse(URI.create("https://localhost:8443/mifosng-provider" + + "/web/index.html?baseApiUrl=https://localhost:8443" + + "&tenantIdentifier=default#/")); + } catch (IOException e) {} + } + } ApplicationExitUtil.waitForKeyPressToCleanlyExit(ctx); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/boot/AbstractApplicationConfiguration.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/boot/AbstractApplicationConfiguration.java index 3c95fa989..5c210dc39 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/boot/AbstractApplicationConfiguration.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/boot/AbstractApplicationConfiguration.java @@ -26,7 +26,7 @@ import org.springframework.context.annotation.ImportResource; * and MariaDB4j (because those differ in the subclasses). */ @Configuration -@Import({ WebXmlConfiguration.class }) +@Import({ WebXmlConfiguration.class, WebFrontEndConfiguration.class }) @ImportResource({ "classpath*:META-INF/spring/appContext.xml" }) @EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class, diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/boot/WebFrontEndConfiguration.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/boot/WebFrontEndConfiguration.java new file mode 100644 index 000000000..5c82d2b61 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/boot/WebFrontEndConfiguration.java @@ -0,0 +1,24 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.infrastructure.core.boot; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@EnableWebMvc +@Configuration +public class WebFrontEndConfiguration extends WebMvcConfigurerAdapter { + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/web/**").addResourceLocations("file:" + + System.getProperty("user.dir") + System.getProperty("file.separator") + + "web" + System.getProperty("file.separator")); + } + +} diff --git a/mifosng-provider/src/test/java/org/mifosplatform/infrastructure/configuration/spring/SpringConfigurationTest.java b/mifosng-provider/src/test/java/org/mifosplatform/infrastructure/configuration/spring/SpringConfigurationTest.java index 86bffef4a..e926d21f5 100644 --- a/mifosng-provider/src/test/java/org/mifosplatform/infrastructure/configuration/spring/SpringConfigurationTest.java +++ b/mifosng-provider/src/test/java/org/mifosplatform/infrastructure/configuration/spring/SpringConfigurationTest.java @@ -9,6 +9,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; /** * This integration test ensure that the "production" Spring XML configuration @@ -23,6 +24,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * AbstractApplicationConfiguration). */ @RunWith(SpringJUnit4ClassRunner.class) +@WebAppConfiguration @ContextConfiguration(classes = TestsWithoutDatabaseAndNoJobsConfiguration.class) public class SpringConfigurationTest {