MIFOSX-1756 Make it easy for Static Web Content such as the community-app to be served by the new standalone end-user server (not development)

This commit is contained in:
Mohammed Nafees
2014-12-17 21:41:32 +05:30
parent 2cef6cfd9a
commit 7ec1f9e808
8 changed files with 90 additions and 2 deletions
+6 -1
View File
@@ -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'
+15
View File
@@ -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.
+10
View File
@@ -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
+15
View File
@@ -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
@@ -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);
}
@@ -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,
@@ -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"));
}
}
@@ -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 {