Fixes in the polygene generator, steps closer to make it work.
Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/2ac40125 Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/2ac40125 Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/2ac40125 Branch: refs/heads/es-jooq Commit: 2ac401253a3d550ab8bcf08063ac1ef056cfed4c Parents: c9d8c24 Author: niclas <[email protected]> Authored: Sun Jul 9 09:50:08 2017 +0800 Committer: niclas <[email protected]> Committed: Sun Jul 9 09:50:08 2017 +0800 ---------------------------------------------------------------------- tools/generator-polygene/app/index.js | 3 + .../HttpServerModule/bootstrap.tmpl | 10 +- .../DomainLayer/DomainModule/module.js | 4 +- .../StorageModule/bootstrap.tmpl | 4 +- .../InfrastructureLayer/StorageModule/module.js | 2 - .../storage/es-cassandra.properties | 37 ++-- .../RestAPIApplication/Launcher.java.tmpl | 12 +- .../app/templates/RestAPIApplication/SETUP.tmpl | 41 +++++ .../app/templates/RestAPIApplication/app.js | 14 ++ .../customUnixStartScript.txt | 175 +++++++++++++++++++ .../customWindowsStartScript.txt | 89 ++++++++++ .../app/templates/buildtool/gradle-app.tmpl | 35 ++-- 12 files changed, 386 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2ac40125/tools/generator-polygene/app/index.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/index.js b/tools/generator-polygene/app/index.js index a20b3eb..434e74e 100644 --- a/tools/generator-polygene/app/index.js +++ b/tools/generator-polygene/app/index.js @@ -290,6 +290,9 @@ function assignFunctions(polygene) { polygene.copyTemplate(ctx, from, 'app/src/dist/config/production/' + toName); + polygene.copyTemplate(ctx, + from, + 'app/src/test/resources/' + toName); }; polygene.copyTemplate = function (ctx, from, to) { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2ac40125/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/bootstrap.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/bootstrap.tmpl index d30c1f3..98fc77a 100644 --- a/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/bootstrap.tmpl +++ b/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/bootstrap.tmpl @@ -47,10 +47,10 @@ public class HttpServerModule {<% if( hasFeature('security') ) { %> private static final int DEFAULT_PORT = 8443; public static final String KS_PASSWORD = "1234"; // TODO: Secure the key stores - public static final String SERVER_KEYSTORE_FILENAME = "security/<%= polygene.name.toLowerCase() %>-app.key"; - public static final String SERVER_KEYSTORE_TYPE = "JCEKS"; - public static final String TRUSTSTORE_FILENAME = "security/<%= polygene.name.toLowerCase() %>-app.key"; - public static final String TRUSTSTORE_TYPE = "JCEKS"; + public static final String SERVER_KEYSTORE_FILENAME = "security/<%= polygene.name.toLowerCase() %>-app.p12"; + public static final String SERVER_KEYSTORE_TYPE = "PKCS12"; + public static final String TRUSTSTORE_FILENAME = "security/<%= polygene.name.toLowerCase() %>-app.p12"; + public static final String TRUSTSTORE_TYPE = "PKCS12"; <% } else { %> protected static final int DEFAULT_PORT = 8080; <% } %> @@ -70,7 +70,7 @@ public class HttpServerModule .assemble( module ); SecureJettyConfiguration defaults = module.forMixin( SecureJettyConfiguration.class ).declareDefaults(); defaults.keystorePath().set( new File( SERVER_KEYSTORE_FILENAME ).getAbsolutePath() ); - defaults.keystoreType().set( "JCEKS" ); + defaults.keystoreType().set( SERVER_KEYSTORE_TYPE ); defaults.keystorePassword().set( KS_PASSWORD ); defaults.truststorePath().set( new File( TRUSTSTORE_FILENAME ).getAbsolutePath() ); defaults.truststoreType().set( TRUSTSTORE_TYPE ); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2ac40125/tools/generator-polygene/app/templates/DomainLayer/DomainModule/module.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/module.js b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/module.js index f511c0f..4051cf7 100644 --- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/module.js +++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/module.js @@ -76,7 +76,9 @@ function copyConfigurationPropertiesFile(p, composites) { if (composites.hasOwnProperty(idx)) { p.current.clazz = composites[idx]; p.prepareClazz(p.current); - p.copyToConfig(p.ctx,'DomainLayer/DomainModule/config.properties.tmpl', p.current.clazz.name + '.properties'); + var configurationFile = 'DomainLayer/DomainModule/config.properties.tmpl'; + var destFileName = p.current.clazz.name + '.properties'; + p.copyToConfig(p.ctx,configurationFile, destFileName); } } } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2ac40125/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/bootstrap.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/bootstrap.tmpl index 4220bd9..8a990c8 100644 --- a/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/bootstrap.tmpl +++ b/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/bootstrap.tmpl @@ -87,9 +87,7 @@ if( polygene.entitystore.indexOf( 'SQL' ) >= 0 ) { .assemble( module ); <% if( polygene.entitystore === 'Cassandra' ) { -%> configModule.forMixin( CassandraEntityStoreConfiguration.class ) - .declareDefaults() - .createIfMissing().set( true ); +%> configModule.forMixin( CassandraEntityStoreConfiguration.class ); <% } %> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2ac40125/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/module.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/module.js b/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/module.js index c61466f..f1373f3 100644 --- a/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/module.js +++ b/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/module.js @@ -37,12 +37,10 @@ module.exports = { } else { var esSqlFileName = 'InfrastructureLayer/StorageModule/storage/es-sql.properties'; p.copyToConfig(p.ctx, esSqlFileName, esFileName); - p.copyTemplate(p.ctx, esSqlFileName, 'app/src/test/resources/' + esFileName ); var dsFileName = 'ds-es-' + p.entitystore.toLowerCase() + '.properties'; var datasourceFile = 'InfrastructureLayer/StorageModule/storage/' + dsFileName; p.copyToConfig(p.ctx, datasourceFile, dsFileName); - p.copyTemplate(p.ctx, datasourceFile, 'app/src/test/resources/' + dsFileName) } } }; http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2ac40125/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/storage/es-cassandra.properties ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/storage/es-cassandra.properties b/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/storage/es-cassandra.properties index 5ad0cab..5a68236 100644 --- a/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/storage/es-cassandra.properties +++ b/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/storage/es-cassandra.properties @@ -24,27 +24,34 @@ # Also not that Cassandra refuse to bind to all interfaces on a host, so you # need to know which hostname corresponds to the interface that Cassandra is # bound to. This may not include 'localhost'. -# Defaults: null -# hostnames= +# Defaults: null +# hostnames= + # The name of the cluster to connect to. -# Defaults: polygene-cluster -# clusterName=polygene-cluster +# Defaults: polygene-cluster +# clusterName=polygene-cluster + # The replication factor to be used, if a KEYSPACE is created. -# Defaults: 3 -# replicationFactor=3 +# Defaults: 3 +# replicationFactor=3 + # The Cassandra client uses the CQL interface, and typically needs a username # and password. -# Defaults: no user name will be attempted. -# username= -# password= +# Defaults: no user name will be attempted. +# username= +# password= + # The name of the KEYSPACE to be used. -# Defaults:polygene -# keySpace=polygene +# Defaults:polygene +# keySpace=polygene + # The name of the entity TABLE to be used. # All entities are stored in the same table, with one entity per row. -# Defaults: entitystore -# entityTableName=entitystore +# Defaults: entitystore +# entityTableName=entitystore + # Defines whether a KEYSPACE and entity TABLE should be created if not already # present in the Cassandra cluster. -# Defaults: false -# createIfMissing=false \ No newline at end of file +# Defaults: false +# createIfMissing=false +createIfMissing=true http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2ac40125/tools/generator-polygene/app/templates/RestAPIApplication/Launcher.java.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/Launcher.java.tmpl b/tools/generator-polygene/app/templates/RestAPIApplication/Launcher.java.tmpl index 2acdca1..40d3dfd 100644 --- a/tools/generator-polygene/app/templates/RestAPIApplication/Launcher.java.tmpl +++ b/tools/generator-polygene/app/templates/RestAPIApplication/Launcher.java.tmpl @@ -32,7 +32,7 @@ public class <%= polygene.name %>Launcher extends PolygeneRestApplicationLaunche { private static final String name = "<%= polygene.name %>"; private static final String version = "0.1"; - private Application.Mode mode = Application.Mode.development; + private Application.Mode mode = getApplicationMode(); public static void main( String[] args ) throws Exception @@ -69,4 +69,14 @@ public class <%= polygene.name %>Launcher extends PolygeneRestApplicationLaunche { return RestApiModule.NAME; } + + private Application.Mode getApplicationMode() + { + String mode = System.getenv( "APP_MODE" ); + if( mode == null ) + { + return Application.Mode.development; + } + return Application.Mode.valueOf( mode ); + } } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2ac40125/tools/generator-polygene/app/templates/RestAPIApplication/SETUP.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/SETUP.tmpl b/tools/generator-polygene/app/templates/RestAPIApplication/SETUP.tmpl new file mode 100644 index 0000000..d5d95ad --- /dev/null +++ b/tools/generator-polygene/app/templates/RestAPIApplication/SETUP.tmpl @@ -0,0 +1,41 @@ +<% +if( polygene.entitystore == 'PostgreSQL' || polygene.indexing == 'SQL' ) { +%> +Start Postgres in Docker +========================= + docker run -p 5432:5432 --name polygene-postgres -d postgres + +Connect to Postgres via Docker +============================== + docker run -it --rm --link polygene-postgres:postgres postgres psql -h postgres -U postgres + +Setting up Postgresql database +============================== +In the psql command shell, execute the following commands (must have elevated +permissions, such as user 'postgres' + + CREATE USER polygene WITH PASSWORD 'ThisIsGreat!'; + CREATE DATABASE <%= polygene.name.toLowerCase() %>; + GRANT ALL ON DATABASE <%= polygene.name.toLowerCase() %> TO polygene; + \connect <%= polygene.name.toLowerCase() %> + CREATE EXTENSION ltree; + \q +<% +} +%> +<% +if( polygene.entitystore == 'Cassandra' ) { +%> +Start Cassandra in Docker +========================= + docker run -d -p 7000:7000 -p 7001:7001 -p 7199:7199 -p 9042:9042 -p 9160:9160 --name polygene-cassandra cassandra + docker logs -f polygene-cassandra + +and wait for the following log message to appear. + + Starting listening for CQL clients on /0.0.0.0:9042 (unencrypted)... + +after that you can Ctrl-C back to command line. +<% +} +%> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2ac40125/tools/generator-polygene/app/templates/RestAPIApplication/app.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/app.js b/tools/generator-polygene/app/templates/RestAPIApplication/app.js index ceed39e..610b9af 100644 --- a/tools/generator-polygene/app/templates/RestAPIApplication/app.js +++ b/tools/generator-polygene/app/templates/RestAPIApplication/app.js @@ -46,6 +46,20 @@ module.exports = { p.copyTemplate(p.ctx, 'RestAPIApplication/bootstrap.tmpl', 'bootstrap/src/main/java/' + p.javaPackageDir + '/bootstrap/' + p.name + 'ApplicationAssembler.java'); + + p.copyTemplate(p.ctx, + 'RestAPIApplication/SETUP.tmpl', + 'SETUP.txt'); + + p.ctx.fs.copy( + p.ctx.templatePath('RestAPIApplication/customUnixStartScript.txt'), + p.ctx.destinationPath('app/src/scripts/customUnixStartScript.txt') + ); + + p.ctx.fs.copy( + p.ctx.templatePath('RestAPIApplication/customWindowsStartScript.txt'), + p.ctx.destinationPath('app/src/scripts/customWindowsStartScript.txt') + ); } }; http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2ac40125/tools/generator-polygene/app/templates/RestAPIApplication/customUnixStartScript.txt ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/customUnixStartScript.txt b/tools/generator-polygene/app/templates/RestAPIApplication/customUnixStartScript.txt new file mode 100644 index 0000000..fd23f57 --- /dev/null +++ b/tools/generator-polygene/app/templates/RestAPIApplication/customUnixStartScript.txt @@ -0,0 +1,175 @@ +#!/usr/bin/env sh + +############################################################################## +## +## ${applicationName} start up script for UN*X +## +############################################################################## + +# default to 'development' mode +if [ -z \$APP_MODE ] ; then + export APP_MODE=development +fi + +# Attempt to set APP_HOME +# Resolve links: \$0 may be a link +PRG="\$0" +# Need this for relative symlinks. +while [ -h "\$PRG" ] ; do + ls=`ls -ld "\$PRG"` + link=`expr "\$ls" : '.*-> \\(.*\\)\$'` + if expr "\$link" : '/.*' > /dev/null; then + PRG="\$link" + else + PRG=`dirname "\$PRG"`"/\$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"\$PRG\"`/${appHomeRelativePath}" >/dev/null +APP_HOME="`pwd -P`" +cd "\$SAVED" >/dev/null + +APP_NAME="${applicationName}" +APP_BASE_NAME=`basename "\$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and ${optsEnvironmentVar} to pass JVM options to this script. +DEFAULT_JVM_OPTS=${defaultJvmOpts} + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "\$*" +} + +die () { + echo + echo "\$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=\$APP_HOME/config/\$APP_MODE:$classpath + +# Determine the Java command to use to start the JVM. +if [ -n "\$JAVA_HOME" ] ; then + if [ -x "\$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="\$JAVA_HOME/jre/sh/java" + else + JAVACMD="\$JAVA_HOME/bin/java" + fi + if [ ! -x "\$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: \$JAVA_HOME +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "\$cygwin" = "false" -a "\$darwin" = "false" -a "\$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ \$? -eq 0 ] ; then + if [ "\$MAX_FD" = "maximum" -o "\$MAX_FD" = "max" ] ; then + MAX_FD="\$MAX_FD_LIMIT" + fi + ulimit -n \$MAX_FD + if [ \$? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: \$MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: \$MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if \$darwin; then + GRADLE_OPTS="\$GRADLE_OPTS \\"-Xdock:name=\$APP_NAME\\" \\"-Xdock:icon=\$APP_HOME/media/gradle.icns\\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if \$cygwin ; then + APP_HOME=`cygpath --path --mixed "\$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "\$CLASSPATH"` + JAVACMD=`cygpath --unix "\$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in \$ROOTDIRSRAW ; do + ROOTDIRS="\$ROOTDIRS\$SEP\$dir" + SEP="|" + done + OURCYGPATTERN="(^(\$ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "\$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="\$OURCYGPATTERN|(\$GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "\$@" ; do + CHECK=`echo "\$arg"|egrep -c "\$OURCYGPATTERN" -` + CHECK2=`echo "\$arg"|egrep -c "^-"` ### Determine if an option + + if [ \$CHECK -ne 0 ] && [ \$CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args\$i`=`cygpath --path --ignore --mixed "\$arg"` + else + eval `echo args\$i`="\"\$arg\"" + fi + i=\$((i+1)) + done + case \$i in + (0) set -- ;; + (1) set -- "\$args0" ;; + (2) set -- "\$args0" "\$args1" ;; + (3) set -- "\$args0" "\$args1" "\$args2" ;; + (4) set -- "\$args0" "\$args1" "\$args2" "\$args3" ;; + (5) set -- "\$args0" "\$args1" "\$args2" "\$args3" "\$args4" ;; + (6) set -- "\$args0" "\$args1" "\$args2" "\$args3" "\$args4" "\$args5" ;; + (7) set -- "\$args0" "\$args1" "\$args2" "\$args3" "\$args4" "\$args5" "\$args6" ;; + (8) set -- "\$args0" "\$args1" "\$args2" "\$args3" "\$args4" "\$args5" "\$args6" "\$args7" ;; + (9) set -- "\$args0" "\$args1" "\$args2" "\$args3" "\$args4" "\$args5" "\$args6" "\$args7" "\$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\\\n "\$i" | sed "s/'/'\\\\\\\\''/g;1s/^/'/;\\\$s/\\\$/' \\\\\\\\/" ; done + echo " " +} +APP_ARGS=\$(save "\$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- \$DEFAULT_JVM_OPTS \$JAVA_OPTS \$${optsEnvironmentVar} <% if ( appNameSystemProperty ) { %>"\"-D${appNameSystemProperty}=\$APP_BASE_NAME\"" <% } %>-classpath "\"\$CLASSPATH\"" ${mainClassName} "\$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "\$(uname)" = "Darwin" ] && [ "\$HOME" = "\$PWD" ]; then + cd "\$(dirname "\$0")" +fi + +exec "\$JAVACMD" "\$@" http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2ac40125/tools/generator-polygene/app/templates/RestAPIApplication/customWindowsStartScript.txt ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/customWindowsStartScript.txt b/tools/generator-polygene/app/templates/RestAPIApplication/customWindowsStartScript.txt new file mode 100644 index 0000000..e891013 --- /dev/null +++ b/tools/generator-polygene/app/templates/RestAPIApplication/customWindowsStartScript.txt @@ -0,0 +1,89 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem ${applicationName} startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=.\ + +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME%${appHomeRelativePath} + +@rem Add default JVM options here. You can also use JAVA_OPTS and ${optsEnvironmentVar} to pass JVM options to this script. +set DEFAULT_JVM_OPTS=${defaultJvmOpts} + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto setmode + +set CMD_LINE_ARGS=%* + +:setmode +if "x%APP_MODE%" <> "x" goto execute +set APP_MODE=development + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\\config\\%APP_MODE%;$classpath + +@rem Execute ${applicationName} +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %${optsEnvironmentVar}% <% if ( appNameSystemProperty ) { %>"-D${appNameSystemProperty}=%APP_BASE_NAME%"<% } %> -classpath "%CLASSPATH%" ${mainClassName} %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable ${exitEnvironmentVar} if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%${exitEnvironmentVar}%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega http://git-wip-us.apache.org/repos/asf/polygene-java/blob/2ac40125/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl b/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl index 441cdec..22cd161 100644 --- a/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl +++ b/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl @@ -17,24 +17,29 @@ * * -%> - - apply plugin: 'application' mainClassName="<%= polygene.packageName %>.app.<%= polygene.name %>Launcher" -applicationDefaultJvmArgs=[] -// GC Tuning strategies, see https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/ -// Strict memory bound -// applicationDefaultJvmArgs << "-Xmx512M -Xms512M" -// -// Goal oriented, "throughput" and "max pause" -// applicationDefaultJvmArgs << "-XX:MaxGCPauseMillis=300 -XX:GCTimeRatio=19" -// -// Garbage Collector -// OneOf; -XX:+UseG1GC, -XX:+UseConcMarkSweepGC, -XX:-UseParallelOldGC, -XX:+UseSerialGC -applicationDefaultJvmArgs << "-XX:+UseG1GC" +startScripts { + applicationName = "<%= polygene.name %>" + optsEnvironmentVar = "<%= polygene.name.toUpperCase() %>_OPTS" + + // GC Tuning strategies, see https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/ + // Strict memory bound + // defaultJvmOpts << "-Xmx512M -Xms512M" + + // Goal oriented, "throughput" and "max pause" + // defaultJvmOpts << "-XX:MaxGCPauseMillis=300 -XX:GCTimeRatio=19" + // Garbage Collector + // OneOf; -XX:+UseG1GC, -XX:+UseConcMarkSweepGC, -XX:-UseParallelOldGC, -XX:+UseSerialGC + defaultJvmOpts << "-XX:+UseG1GC" + + // Custom start scripts + unixStartScriptGenerator.template = resources.text.fromFile('src/scripts/customUnixStartScript.txt') + windowsStartScriptGenerator.template = resources.text.fromFile('src/scripts/customWindowsStartScript.txt') +} dependencies { implementation project( ":bootstrap" ) @@ -104,3 +109,7 @@ if( polygene.entitystore == 'SQLite' ) { testImplementation "org.apache.polygene.core:org.apache.polygene.core.testsupport:$polygeneVersion" testImplementation "com.github.tdomzal:junit-docker-rule:0.3" } + +tasks.withType(Tar){ + compression = Compression.GZIP +}
