diff --git a/generators/ci-cd/templates/travis.yml.ejs b/generators/ci-cd/templates/travis.yml.ejs
index c87b155a1b66..5e040d699ac0 100644
--- a/generators/ci-cd/templates/travis.yml.ejs
+++ b/generators/ci-cd/templates/travis.yml.ejs
@@ -18,7 +18,6 @@
-%>
os:
- linux
-dist: bionic
services:
- docker
language: node_js
@@ -44,6 +43,17 @@ env:
- JHI_DISABLE_WEBPACK_LOGS=true
- NG_CLI_ANALYTICS="false"
before_install:
+ -
+ if [[ $JHI_JDK = '11' ]]; then
+ echo '*** Using OpenJDK 11'
+ sudo add-apt-repository ppa:openjdk-r/ppa
+ sudo apt-get update
+ sudo apt-get install -y openjdk-11-jdk
+ sudo update-java-alternatives -s java-1.11.0-openjdk-amd64
+ java -version
+ else
+ echo '*** Using OpenJDK 8 by default'
+ fi
- java -version
- sudo /etc/init.d/mysql stop
- sudo /etc/init.d/postgresql stop
diff --git a/generators/gae/index.js b/generators/gae/index.js
index 5629eaa19b34..02321509bd7e 100644
--- a/generators/gae/index.js
+++ b/generators/gae/index.js
@@ -18,7 +18,6 @@
*/
const os = require('os');
const exec = require('child_process').exec;
-const spawn = require('child_process').spawn;
const execSync = require('child_process').execSync;
const chalk = require('chalk');
const _ = require('lodash');
@@ -59,23 +58,26 @@ module.exports = class extends BaseGenerator {
const done = this.async();
const component = 'app-engine-java';
- exec('gcloud components list --quiet --filter="Status=Installed" --format="value(id)"', (err, stdout, srderr) => {
- if (_.includes(stdout, component)) {
- done();
- } else {
- this.log(chalk.bold('\nInstalling App Engine Java SDK'));
- this.log(`... Running: gcloud components install ${component} --quiet`);
- const child = spawn('gcloud', ['components', 'install', component, '--quiet'], {
- stdio: [process.stdin, process.stdout, process.stderr]
- });
- child.on('exit', code => {
- if (code !== 0) {
- this.abort = true;
- }
+ exec(
+ 'gcloud components list --quiet --filter="Status=Installed OR Status=\\"Update Available\\"" --format="value(id)"',
+ (err, stdout, srderr) => {
+ if (_.includes(stdout, component)) {
done();
- });
+ } else {
+ this.log(chalk.bold('\nInstalling App Engine Java SDK'));
+ this.log(`... Running: gcloud components install ${component} --quiet`);
+ const child = exec(`gcloud components install ${component} --quiet`, {
+ stdio: [process.stdin, process.stdout, process.stderr]
+ });
+ child.on('exit', code => {
+ if (code !== 0) {
+ this.abort = true;
+ }
+ done();
+ });
+ }
}
- });
+ );
},
loadConfig() {
@@ -104,6 +106,7 @@ module.exports = class extends BaseGenerator {
this.gaeInstances = this.config.get('gaeInstances');
this.gaeMaxInstances = this.config.get('gaeMaxInstances');
this.gaeMinInstances = this.config.get('gaeMinInstances');
+ this.gaeCloudSQLInstanceNeeded = this.config.get('gaeCloudSQLInstanceNeeded');
}
};
}
@@ -244,15 +247,15 @@ module.exports = class extends BaseGenerator {
name: 'gaeInstanceClass',
message: 'Google App Engine Instance Class',
choices: [
- { value: 'F1', name: 'F1 - 600MHz, 128MB, Automatic Scaling' },
- { value: 'F2', name: 'F2 - 1.2GHz, 256MB, Automatic Scaling' },
- { value: 'F4', name: 'F4 - 2.4GHz, 512MB, Automatic Scaling' },
- { value: 'F4_1G', name: 'F4_1G - 2.4GHz, 1GB, Automatic' },
- { value: 'B1', name: 'B1 - 600MHz, 128MB, Basic or Manual Scaling' },
- { value: 'B2', name: 'B2 - 1.2GHz, 256MB, Basic or Manual Scaling' },
- { value: 'B4', name: 'B4 - 2.4GHz, 512MB, Basic or Manual Scaling' },
- { value: 'B4_1G', name: 'B4_1G - 2.4GHz, 1GB, Basic or Manual Scaling' },
- { value: 'B8', name: 'B8 - 4.8GHz, 1GB, Basic or Manual Scaling' }
+ { value: 'F1', name: 'F1 - 600MHz, 256MB, Automatic Scaling' },
+ { value: 'F2', name: 'F2 - 1.2GHz, 512MB, Automatic Scaling' },
+ { value: 'F4', name: 'F4 - 2.4GHz, 1GB, Automatic Scaling' },
+ { value: 'F4_1G', name: 'F4_1G - 2.4GHz, 2GB, Automatic' },
+ { value: 'B1', name: 'B1 - 600MHz, 256MB, Basic or Manual Scaling' },
+ { value: 'B2', name: 'B2 - 1.2GHz, 512MB, Basic or Manual Scaling' },
+ { value: 'B4', name: 'B4 - 2.4GHz, 1GB, Basic or Manual Scaling' },
+ { value: 'B4_1G', name: 'B4_1G - 2.4GHz, 2GB, Basic or Manual Scaling' },
+ { value: 'B8', name: 'B8 - 4.8GHz, 2GB, Basic or Manual Scaling' }
],
default: this.gaeInstanceClass ? this.gaeInstanceClass : 0
}
@@ -363,7 +366,32 @@ module.exports = class extends BaseGenerator {
});
},
+ askIfCloudSqlIsNeeded() {
+ if (this.abort) return;
+ const done = this.async();
+ const prompts = [];
+
+ prompts.push({
+ type: 'input',
+ name: 'gaeCloudSQLInstanceNeeded',
+ message: 'Initialize a new Cloud SQL instance (Y/N) ?',
+ default: this.gaeCloudSQLInstanceNeeded ? this.gaeCloudSQLInstanceNeeded : 'Y',
+ validate: input => {
+ if (input !== 'Y' && input !== 'N') {
+ return 'Input should be Y or N';
+ }
+ return true;
+ }
+ });
+
+ this.prompt(prompts).then(props => {
+ this.gaeCloudSQLInstanceNeeded = props.gaeCloudSQLInstanceNeeded;
+ done();
+ });
+ },
+
askForCloudSqlInstance() {
+ if (this.gaeCloudSQLInstanceNeeded === 'N') return;
if (this.abort) return;
if (this.prodDatabaseType !== 'mysql' && this.prodDatabaseType !== 'mariadb' && this.prodDatabaseType !== 'postgresql')
return;
@@ -371,9 +399,8 @@ module.exports = class extends BaseGenerator {
const done = this.async();
const cloudSqlInstances = [{ value: '', name: 'New Cloud SQL Instance' }];
-
exec(
- `gcloud sql instances list --format='value[separator=":"](project,region,name)' --project="${this.gcpProjectId}"`,
+ `gcloud sql instances list --format="value[separator=":"](project,region,name)" --project="${this.gcpProjectId}"`,
(err, stdout, stderr) => {
if (err) {
this.log.error(err);
@@ -404,6 +431,7 @@ module.exports = class extends BaseGenerator {
},
promptForCloudSqlInstanceNameIfNeeded() {
+ if (this.gaeCloudSQLInstanceNeeded === 'N') return;
if (this.abort) return;
if (this.gcpCloudSqlInstanceName) return;
@@ -426,6 +454,7 @@ module.exports = class extends BaseGenerator {
},
askForCloudSqlLogin() {
+ if (this.gaeCloudSQLInstanceNeeded === 'N') return;
if (this.abort) return;
if (!this.gcpCloudSqlInstanceName) return;
@@ -459,6 +488,7 @@ module.exports = class extends BaseGenerator {
},
askForCloudSqlDatabaseName() {
+ if (this.gaeCloudSQLInstanceNeeded === 'N') return;
if (this.abort) return;
if (!this.gcpCloudSqlInstanceNameExists) return;
@@ -498,6 +528,7 @@ module.exports = class extends BaseGenerator {
},
promptForCloudSqlDatabaseNameIfNeeded() {
+ if (this.gaeCloudSQLInstanceNeeded === 'N') return;
if (this.abort) return;
if (this.gcpCloudSqlInstanceName !== 'new' && this.gcpCloudSqlDatabaseName) return;
@@ -551,6 +582,7 @@ module.exports = class extends BaseGenerator {
},
createCloudSqlInstance() {
+ if (this.gaeCloudSQLInstanceNeeded === 'N') return;
if (this.abort) return;
if (!this.gcpCloudSqlInstanceName) return;
if (this.gcpCloudSqlInstanceNameExists) return;
@@ -584,6 +616,7 @@ module.exports = class extends BaseGenerator {
},
createCloudSqlLogin() {
+ if (this.gaeCloudSQLInstanceNeeded === 'N') return;
if (this.abort) return;
if (!this.gcpCloudSqlInstanceName) return;
const done = this.async();
@@ -615,6 +648,7 @@ module.exports = class extends BaseGenerator {
},
createCloudSqlDatabase() {
+ if (this.gaeCloudSQLInstanceNeeded === 'N') return;
if (this.abort) return;
if (!this.gcpCloudSqlInstanceName) return;
if (this.gcpCloudSqlDatabaseNameExists) return;
@@ -646,7 +680,8 @@ module.exports = class extends BaseGenerator {
gaeScalingType: this.gaeScalingType,
gaeInstances: this.gaeInstances,
gaeMinInstances: this.gaeMinInstances,
- gaeMaxInstances: this.gaeMaxInstances
+ gaeMaxInstances: this.gaeMaxInstances,
+ gaeCloudSQLInstanceNeeded: this.gaeCloudSQLInstanceNeeded
});
}
};
@@ -660,10 +695,10 @@ module.exports = class extends BaseGenerator {
const done = this.async();
this.log(chalk.bold('\nCreating Google App Engine deployment files'));
- this.template('web.xml.ejs', `${constants.CLIENT_MAIN_SRC_DIR}/WEB-INF/web.xml`);
- this.template('appengine-web.xml.ejs', `${constants.CLIENT_MAIN_SRC_DIR}/WEB-INF/appengine-web.xml`);
- this.template('logging.properties.ejs', `${constants.CLIENT_MAIN_SRC_DIR}/WEB-INF/logging.properties`);
- this.template('application-prod-gae.yml.ejs', `${constants.SERVER_MAIN_RES_DIR}/config/application-prod-gae.yml`);
+ this.template('app.yaml.ejs', `${constants.MAIN_DIR}/appengine/app.yaml`);
+ if (this.gaeCloudSQLInstanceNeeded === 'Y') {
+ this.template('application-prod-gae.yml.ejs', `${constants.SERVER_MAIN_RES_DIR}/config/application-prod-gae.yml`);
+ }
if (this.buildTool === 'gradle') {
this.template('gae.gradle.ejs', 'gradle/gae.gradle');
}
@@ -674,6 +709,7 @@ module.exports = class extends BaseGenerator {
},
addDependencies() {
+ if (this.gaeCloudSQLInstanceNeeded === 'N') return;
if (this.prodDatabaseType === 'mysql' || this.prodDatabaseType === 'mariadb') {
if (this.buildTool === 'maven') {
this.addMavenDependency('com.google.cloud.sql', 'mysql-socket-factory', '1.0.8');
@@ -692,16 +728,20 @@ module.exports = class extends BaseGenerator {
addGradlePlugin() {
if (this.buildTool === 'gradle') {
- this.addGradlePlugin('com.google.cloud.tools', 'appengine-gradle-plugin', '1.3.3');
+ if (this.gaeCloudSQLInstanceNeeded === 'Y') {
+ this.addGradlePlugin('com.google.cloud.tools', 'appengine-gradle-plugin', '1.3.3');
+ }
this.applyFromGradleScript('gradle/gae');
}
},
addMavenPlugin() {
if (this.buildTool === 'maven') {
- this.render('pom-plugin.xml.ejs', rendered => {
- this.addMavenPlugin('com.google.cloud.tools', 'appengine-maven-plugin', '1.3.2', rendered.trim());
- });
+ if (this.gaeCloudSQLInstanceNeeded === 'Y') {
+ this.render('pom-plugin.xml.ejs', rendered => {
+ this.addMavenPlugin('com.google.cloud.tools', 'appengine-maven-plugin', '1.3.2', rendered.trim());
+ });
+ }
this.render('pom-profile.xml.ejs', rendered => {
this.addMavenProfile('prod-gae', ` ${rendered.trim()}`);
});
diff --git a/generators/gae/templates/app.yaml.ejs b/generators/gae/templates/app.yaml.ejs
new file mode 100644
index 000000000000..67fd9d6b8429
--- /dev/null
+++ b/generators/gae/templates/app.yaml.ejs
@@ -0,0 +1,20 @@
+runtime: java11
+instance_class: <%= gaeInstanceClass %>
+service: <%=gaeServiceName%>
+<%_ if (gaeScalingType === 'manual') { _%>
+manual_scaling:
+ instances: <%= gaeInstances %>
+<%_ } else if (gaeScalingType === 'basic') { _%>
+basic_scaling:
+ <%_ if (gaeMaxInstances > 0) { _%>
+ max_instances: <%= gaeMaxInstances %>
+ <%_ } _%>
+<%_ } else if (gaeScalingType === 'automatic') { _%>
+automatic_scaling:
+ <%_ if (gaeMinInstances > 0) { _%>
+ min_instances: <%= gaeMinInstances %>
+ <%_ } _%>
+ <%_ if (gaeMaxInstances > 0) { _%>
+ max_instances: <%= gaeMaxInstances %>
+ <%_ } _%>
+<%_ } _%>
diff --git a/generators/gae/templates/appengine-web.xml.ejs b/generators/gae/templates/appengine-web.xml.ejs
deleted file mode 100644
index ff814a38aa78..000000000000
--- a/generators/gae/templates/appengine-web.xml.ejs
+++ /dev/null
@@ -1,41 +0,0 @@
-
- <%=gaeServiceName%>
- true
- java8
-
- <%_ if (gaeScalingType === 'manual') { _%>
-
- <%= gaeInstances %>
-
- <%_ } else if (gaeScalingType === 'basic') { _%>
-
- <%_ if (gaeMaxInstances > 0) { _%>
- <%= gaeMaxInstances %>
- <%_ } _%>
-
- <%_ } else if (gaeScalingType === 'automatic') { _%>
-
- <%_ if (gaeMinInstances > 0) { _%>
- <%= gaeMinInstances %>
- <%_ } _%>
- <%_ if (gaeMaxInstances > 0) { _%>
- <%= gaeMaxInstances %>
- <%_ } _%>
-
- <%_ } _%>
- true
- <%= gaeInstanceClass %>
- false
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/generators/gae/templates/gae.gradle.ejs b/generators/gae/templates/gae.gradle.ejs
index 94a67b242d35..401cab3dc5fe 100644
--- a/generators/gae/templates/gae.gradle.ejs
+++ b/generators/gae/templates/gae.gradle.ejs
@@ -27,9 +27,6 @@ appengine {
bootWar {
webXml = file("${project.rootDir}/<%= CLIENT_MAIN_SRC_DIR %>WEB-INF/web.xml")
- from("${project.rootDir}/<%= CLIENT_MAIN_SRC_DIR %>WEB-INF/appengine-web.xml") {
- into("WEB-INF")
- }
}
processResources {
diff --git a/generators/gae/templates/logging.properties.ejs b/generators/gae/templates/logging.properties.ejs
deleted file mode 100644
index e23a81e59d6a..000000000000
--- a/generators/gae/templates/logging.properties.ejs
+++ /dev/null
@@ -1,13 +0,0 @@
-# A default java.util.logging configuration.
-# (All App Engine logging is through java.util.logging by default).
-#
-# To use this configuration, copy it into your application's WEB-INF
-# folder and add the following to your appengine-web.xml:
-#
-#
-#
-#
-#
-
-# Set the default logging level for all loggers to INFO
-.level = INFO
diff --git a/generators/gae/templates/web.xml.ejs b/generators/gae/templates/web.xml.ejs
deleted file mode 100644
index 07d95dd4f7b8..000000000000
--- a/generators/gae/templates/web.xml.ejs
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
- html
- text/html;charset=utf-8
-
-
- json
- application/json;charset=utf-8
-
-
- js
- application/javascript;charset=utf-8
-
-
-