Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Java11 in GAE #10216

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6284f3d
Explicitly use Java11 in travis deployment
SudharakaP Aug 11, 2019
f6bd8d0
Convert the existing appengine-web.xml.ejs to app.yaml.ejs for gae ja…
SudharakaP Aug 11, 2019
18b0874
Remove unnecessary logging file as per; https://cloud.google.com/appe…
SudharakaP Aug 11, 2019
cc93334
Modify gradle bootWar task to exclude appengine-web.xml file
SudharakaP Aug 11, 2019
5de9edf
Remove web.xml as java11 in gae runs as a jar file not on jetty
SudharakaP Aug 11, 2019
c0b1151
Fix issues with the GAE generator (Java 8)
SudharakaP Aug 11, 2019
2e1ed62
Merge branch 'fix-gae-bugs' into java11-gae-upgrade
SudharakaP Aug 12, 2019
643687b
Add support to give the user a choice in choosing Cloud SQL
SudharakaP Aug 12, 2019
1d388a4
Change the app engine values to reflect the second generation runtime…
SudharakaP Aug 12, 2019
bcd8689
Fix minor bug where I didn't record whether Cloud SQL instance is needed
SudharakaP Aug 12, 2019
51b33af
Fix minor bug where I didn't record whether Cloud SQL instance is needed
SudharakaP Aug 12, 2019
a51d4ec
Fix some bugs and add support for choosing Cloud SQL
SudharakaP Aug 13, 2019
cba421c
Revert the change to install openjdk through install-jdk scripts as p…
SudharakaP Aug 16, 2019
131d960
Update google cloud plugins
SudharakaP Aug 17, 2019
1f45417
Merge branch 'master' into java11-gae-upgrade
SudharakaP Aug 17, 2019
13eca1d
Update google cloud plugins; mistake with versions
SudharakaP Aug 17, 2019
013cb94
Merge branch 'master' into java11-gae-upgrade
SudharakaP Aug 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion generators/ci-cd/templates/travis.yml.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
-%>
os:
- linux
dist: bionic
services:
- docker
language: node_js
Expand All @@ -44,6 +43,8 @@ env:
- JHI_DISABLE_WEBPACK_LOGS=true
- NG_CLI_ANALYTICS="false"
before_install:
- wget https://github.com/sormuras/bach/raw/master/install-jdk.sh
- source install-jdk.sh --feature 11
SudharakaP marked this conversation as resolved.
Show resolved Hide resolved
- java -version
- sudo /etc/init.d/mysql stop
- sudo /etc/init.d/postgresql stop
Expand Down
112 changes: 76 additions & 36 deletions generators/gae/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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');
}
};
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -363,17 +366,41 @@ 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;

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);
Expand Down Expand Up @@ -404,6 +431,7 @@ module.exports = class extends BaseGenerator {
},

promptForCloudSqlInstanceNameIfNeeded() {
if (this.gaeCloudSQLInstanceNeeded === 'N') return;
if (this.abort) return;
if (this.gcpCloudSqlInstanceName) return;

Expand All @@ -426,6 +454,7 @@ module.exports = class extends BaseGenerator {
},

askForCloudSqlLogin() {
if (this.gaeCloudSQLInstanceNeeded === 'N') return;
if (this.abort) return;
if (!this.gcpCloudSqlInstanceName) return;

Expand Down Expand Up @@ -459,6 +488,7 @@ module.exports = class extends BaseGenerator {
},

askForCloudSqlDatabaseName() {
if (this.gaeCloudSQLInstanceNeeded === 'N') return;
if (this.abort) return;
if (!this.gcpCloudSqlInstanceNameExists) return;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
});
}
};
Expand All @@ -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');
}
Expand All @@ -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');
Expand All @@ -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()}`);
});
Expand Down
20 changes: 20 additions & 0 deletions generators/gae/templates/app.yaml.ejs
Original file line number Diff line number Diff line change
@@ -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 %>
<%_ } _%>
<%_ } _%>
41 changes: 0 additions & 41 deletions generators/gae/templates/appengine-web.xml.ejs

This file was deleted.

3 changes: 0 additions & 3 deletions generators/gae/templates/gae.gradle.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 0 additions & 13 deletions generators/gae/templates/logging.properties.ejs

This file was deleted.

19 changes: 0 additions & 19 deletions generators/gae/templates/web.xml.ejs

This file was deleted.