@bubblewrap/core 1.21.0 → 1.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/Config.js +6 -4
- package/dist/lib/FetchUtils.d.ts +2 -2
- package/dist/lib/FetchUtils.js +4 -4
- package/dist/lib/GooglePlay.d.ts +1 -1
- package/dist/lib/GooglePlay.js +3 -3
- package/dist/lib/GradleWrapper.d.ts +0 -1
- package/dist/lib/GradleWrapper.js +1 -1
- package/dist/lib/ImageHelper.js +2 -2
- package/dist/lib/ShortcutInfo.js +5 -5
- package/dist/lib/TwaGenerator.d.ts +1 -1
- package/dist/lib/TwaGenerator.js +10 -8
- package/dist/lib/TwaManifest.d.ts +6 -6
- package/dist/lib/TwaManifest.js +17 -15
- package/dist/lib/androidSdk/AndroidSdkTools.d.ts +1 -2
- package/dist/lib/androidSdk/AndroidSdkTools.js +17 -12
- package/dist/lib/errors/ValidatePathError.d.ts +1 -1
- package/dist/lib/features/AppsFlyerFeature.d.ts +1 -1
- package/dist/lib/features/LocationDelegationFeature.d.ts +1 -1
- package/dist/lib/features/PlayBillingFeature.d.ts +1 -1
- package/dist/lib/features/PlayBillingFeature.js +1 -1
- package/dist/lib/jdk/JarSigner.js +1 -1
- package/dist/lib/jdk/JdkHelper.d.ts +0 -1
- package/dist/lib/jdk/JdkHelper.js +4 -4
- package/dist/lib/jdk/KeyTool.js +12 -12
- package/dist/lib/types/WebManifest.d.ts +2 -2
- package/dist/lib/util.d.ts +0 -1
- package/dist/lib/util.js +22 -23
- package/dist/lib/wrappers/svg2img.d.ts +0 -1
- package/dist/lib/wrappers/svg2img.js +4 -4
- package/package.json +4 -4
- package/template_project/app/build.gradle +3 -2
- package/template_project/app/src/main/AndroidManifest.xml +5 -1
- package/template_project/build.gradle +1 -1
- package/template_project/gradle/wrapper/gradle-wrapper.properties +3 -1
- package/template_project/gradlew +172 -111
- package/template_project/gradlew.bat +25 -33
package/dist/lib/util.js
CHANGED
|
@@ -15,7 +15,21 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
18
|
+
exports.execute = execute;
|
|
19
|
+
exports.executeFile = executeFile;
|
|
20
|
+
exports.unzipFile = unzipFile;
|
|
21
|
+
exports.untar = untar;
|
|
22
|
+
exports.execInteractive = execInteractive;
|
|
23
|
+
exports.findSuitableIcon = findSuitableIcon;
|
|
24
|
+
exports.generatePackageId = generatePackageId;
|
|
25
|
+
exports.validateNotEmpty = validateNotEmpty;
|
|
26
|
+
exports.validatePackageId = validatePackageId;
|
|
27
|
+
exports.rmdir = rmdir;
|
|
28
|
+
exports.getWebManifest = getWebManifest;
|
|
29
|
+
exports.escapeJsonString = escapeJsonString;
|
|
30
|
+
exports.toAndroidScreenOrientation = toAndroidScreenOrientation;
|
|
31
|
+
exports.escapeGradleString = escapeGradleString;
|
|
32
|
+
exports.escapeDoubleQuotedShellString = escapeDoubleQuotedShellString;
|
|
19
33
|
const extractZip = require("extract-zip");
|
|
20
34
|
const fs = require("fs");
|
|
21
35
|
const path_1 = require("path");
|
|
@@ -23,9 +37,9 @@ const util_1 = require("util");
|
|
|
23
37
|
const child_process_1 = require("child_process");
|
|
24
38
|
const tar_1 = require("tar");
|
|
25
39
|
const FetchUtils_1 = require("./FetchUtils");
|
|
26
|
-
const execPromise = util_1.promisify(child_process_1.exec);
|
|
27
|
-
const execFilePromise = util_1.promisify(child_process_1.execFile);
|
|
28
|
-
const extractZipPromise = util_1.promisify(extractZip);
|
|
40
|
+
const execPromise = (0, util_1.promisify)(child_process_1.exec);
|
|
41
|
+
const execFilePromise = (0, util_1.promisify)(child_process_1.execFile);
|
|
42
|
+
const extractZipPromise = (0, util_1.promisify)(extractZip);
|
|
29
43
|
// Regex for disallowed characters on Android Packages, as per
|
|
30
44
|
// https://developer.android.com/guide/topics/manifest/manifest-element.html#package
|
|
31
45
|
const DISALLOWED_ANDROID_PACKAGE_CHARS_REGEX = /[^a-zA-Z0-9_\.]/g;
|
|
@@ -47,24 +61,21 @@ async function execute(cmd, env, log) {
|
|
|
47
61
|
}
|
|
48
62
|
return await execPromise(joinedCmd, { env: env });
|
|
49
63
|
}
|
|
50
|
-
exports.execute = execute;
|
|
51
64
|
async function executeFile(cmd, args, env, log, cwd) {
|
|
52
65
|
if (log) {
|
|
53
66
|
log.debug(`Executing command ${cmd} with args ${args}`);
|
|
54
67
|
}
|
|
55
|
-
return await execFilePromise(cmd, args, { env: env, cwd: cwd });
|
|
68
|
+
return await execFilePromise(cmd, args, { env: env, cwd: cwd, shell: true });
|
|
56
69
|
}
|
|
57
|
-
exports.executeFile = executeFile;
|
|
58
70
|
async function unzipFile(zipFile, destinationPath, deleteZipWhenDone = false) {
|
|
59
71
|
await extractZipPromise(zipFile, { dir: destinationPath });
|
|
60
72
|
if (deleteZipWhenDone) {
|
|
61
73
|
fs.unlinkSync(zipFile);
|
|
62
74
|
}
|
|
63
75
|
}
|
|
64
|
-
exports.unzipFile = unzipFile;
|
|
65
76
|
async function untar(tarFile, destinationPath, deleteZipWhenDone = false) {
|
|
66
77
|
console.log(`Extracting ${tarFile} to ${destinationPath}`);
|
|
67
|
-
await tar_1.x({
|
|
78
|
+
await (0, tar_1.x)({
|
|
68
79
|
file: tarFile,
|
|
69
80
|
cwd: destinationPath,
|
|
70
81
|
unlink: true,
|
|
@@ -73,9 +84,8 @@ async function untar(tarFile, destinationPath, deleteZipWhenDone = false) {
|
|
|
73
84
|
fs.unlinkSync(tarFile);
|
|
74
85
|
}
|
|
75
86
|
}
|
|
76
|
-
exports.untar = untar;
|
|
77
87
|
function execInteractive(cwd, args, env) {
|
|
78
|
-
const shell = child_process_1.spawn(`"${cwd}"`, args, {
|
|
88
|
+
const shell = (0, child_process_1.spawn)(`"${cwd}"`, args, {
|
|
79
89
|
stdio: 'inherit',
|
|
80
90
|
env: env,
|
|
81
91
|
shell: true,
|
|
@@ -91,7 +101,6 @@ function execInteractive(cwd, args, env) {
|
|
|
91
101
|
});
|
|
92
102
|
});
|
|
93
103
|
}
|
|
94
|
-
exports.execInteractive = execInteractive;
|
|
95
104
|
/**
|
|
96
105
|
* Fetches data for the largest icon from the web app manifest with a given purpose.
|
|
97
106
|
* @param {Array<WebManifestIcon>|undefined} icons List of the manifest icons.
|
|
@@ -120,7 +129,6 @@ function findSuitableIcon(icons, purpose, minSize = 0) {
|
|
|
120
129
|
largestIcon.size = largestIconSize;
|
|
121
130
|
return largestIcon;
|
|
122
131
|
}
|
|
123
|
-
exports.findSuitableIcon = findSuitableIcon;
|
|
124
132
|
/**
|
|
125
133
|
* Generates an Android Application Id / Package Name, using the reverse hostname as a base
|
|
126
134
|
* and appending `.twa` to the end.
|
|
@@ -156,7 +164,6 @@ function generatePackageId(host) {
|
|
|
156
164
|
packageId.push('twa');
|
|
157
165
|
return packageId.join('.').replace(DISALLOWED_ANDROID_PACKAGE_CHARS_REGEX, '_');
|
|
158
166
|
}
|
|
159
|
-
exports.generatePackageId = generatePackageId;
|
|
160
167
|
/**
|
|
161
168
|
* Validates if a string is not null and not empty.
|
|
162
169
|
* @param input the string to be validated
|
|
@@ -169,7 +176,6 @@ function validateNotEmpty(input, fieldName) {
|
|
|
169
176
|
}
|
|
170
177
|
return null;
|
|
171
178
|
}
|
|
172
|
-
exports.validateNotEmpty = validateNotEmpty;
|
|
173
179
|
/**
|
|
174
180
|
* Validates a Package Id, according to the documentation at:
|
|
175
181
|
* https://developer.android.com/studio/build/application-id
|
|
@@ -206,7 +212,6 @@ function validatePackageId(input) {
|
|
|
206
212
|
}
|
|
207
213
|
return null;
|
|
208
214
|
}
|
|
209
|
-
exports.validatePackageId = validatePackageId;
|
|
210
215
|
/**
|
|
211
216
|
* Removes a file or directory. If the path is a directory, recursively deletes files and
|
|
212
217
|
* directories inside it.
|
|
@@ -224,10 +229,9 @@ async function rmdir(path) {
|
|
|
224
229
|
// This is a directory. We delete files and sub directories inside it, then delete the
|
|
225
230
|
// directory itself.
|
|
226
231
|
const entries = fs.readdirSync(path);
|
|
227
|
-
await Promise.all(entries.map((entry) => rmdir(path_1.join(path, entry))));
|
|
232
|
+
await Promise.all(entries.map((entry) => rmdir((0, path_1.join)(path, entry))));
|
|
228
233
|
await fs.promises.rmdir(path);
|
|
229
234
|
}
|
|
230
|
-
exports.rmdir = rmdir;
|
|
231
235
|
;
|
|
232
236
|
/**
|
|
233
237
|
* Given a Web Manifest's URL, the function returns the web manifest as a JSON object.
|
|
@@ -243,7 +247,6 @@ async function getWebManifest(webManifestUrl) {
|
|
|
243
247
|
}
|
|
244
248
|
return await response.json();
|
|
245
249
|
}
|
|
246
|
-
exports.getWebManifest = getWebManifest;
|
|
247
250
|
/**
|
|
248
251
|
* Given a JSON string, the function returns an escaped representation of the string.
|
|
249
252
|
* eg: Turns every " instance into \\".
|
|
@@ -256,7 +259,6 @@ function escapeJsonString(stringToReplace) {
|
|
|
256
259
|
const regExp = new RegExp('\"', 'g');
|
|
257
260
|
return stringToReplace.replace(regExp, '\\\\\"');
|
|
258
261
|
}
|
|
259
|
-
exports.escapeJsonString = escapeJsonString;
|
|
260
262
|
// This is the value of the screenOrientation for the LauncherActivity which determines the
|
|
261
263
|
// orientation of the splash screen.
|
|
262
264
|
// This methods maps the Web Manifest orientation to the android screenOrientation:
|
|
@@ -287,7 +289,6 @@ function toAndroidScreenOrientation(orientation) {
|
|
|
287
289
|
default: return 'ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED';
|
|
288
290
|
}
|
|
289
291
|
}
|
|
290
|
-
exports.toAndroidScreenOrientation = toAndroidScreenOrientation;
|
|
291
292
|
/**
|
|
292
293
|
* Escapes a string that will be written to the Gradle file. The characters need to be escaped
|
|
293
294
|
* multiple times, as they also need to be escaped inside the Gradle file.
|
|
@@ -298,7 +299,6 @@ exports.toAndroidScreenOrientation = toAndroidScreenOrientation;
|
|
|
298
299
|
function escapeGradleString(input) {
|
|
299
300
|
return input.replace(/[\\']/g, '\\\\\\$&');
|
|
300
301
|
}
|
|
301
|
-
exports.escapeGradleString = escapeGradleString;
|
|
302
302
|
/**
|
|
303
303
|
* Escapes a string that will be used inside a double quoted block in the shell. The characters
|
|
304
304
|
* ", $, `, and \ need escaping even when the string is surrounded by double quotes.
|
|
@@ -306,4 +306,3 @@ exports.escapeGradleString = escapeGradleString;
|
|
|
306
306
|
function escapeDoubleQuotedShellString(input) {
|
|
307
307
|
return input.replace(/([\$"`\\])/g, '\\$1');
|
|
308
308
|
}
|
|
309
|
-
exports.escapeDoubleQuotedShellString = escapeDoubleQuotedShellString;
|
|
@@ -15,19 +15,20 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
18
|
+
exports.Format = void 0;
|
|
19
|
+
exports.svg2img = svg2img;
|
|
19
20
|
const resvg_js_1 = require("@resvg/resvg-js");
|
|
20
21
|
var Format;
|
|
21
22
|
(function (Format) {
|
|
22
23
|
Format["jpeg"] = "jpeg";
|
|
23
24
|
Format["jpg"] = "jpg";
|
|
24
25
|
Format["png"] = "png";
|
|
25
|
-
})(Format
|
|
26
|
+
})(Format || (exports.Format = Format = {}));
|
|
26
27
|
async function svg2img(svg) {
|
|
27
28
|
const opt = {
|
|
28
29
|
fitTo: {
|
|
29
30
|
mode: 'width',
|
|
30
|
-
value: 1200,
|
|
31
|
+
value: 1200, // Generate the SVG with 1200px width, for larger icons.
|
|
31
32
|
},
|
|
32
33
|
};
|
|
33
34
|
const resvg = new resvg_js_1.Resvg(svg, opt);
|
|
@@ -35,4 +36,3 @@ async function svg2img(svg) {
|
|
|
35
36
|
const pngBuffer = pngData.asPng();
|
|
36
37
|
return pngBuffer;
|
|
37
38
|
}
|
|
38
|
-
exports.svg2img = svg2img;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bubblewrap/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.2",
|
|
4
4
|
"description": "Core Library to generate, build and sign TWA projects",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=14.15.0"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@types/color": "^3.0.0",
|
|
38
38
|
"@types/extract-zip": "^1.6.2",
|
|
39
39
|
"@types/gapi.client.androidpublisher": "^3.0.0",
|
|
40
|
-
"@types/inquirer": "^
|
|
40
|
+
"@types/inquirer": "^9.0.7",
|
|
41
41
|
"@types/lodash.template": "^4.5.0",
|
|
42
42
|
"@types/mime-types": "^2.1.0",
|
|
43
43
|
"@types/node": "^12.20.1",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"extract-zip": "^1.7.0",
|
|
50
50
|
"fetch-h2": "^2.5.1",
|
|
51
51
|
"googleapis": "^81.0.0",
|
|
52
|
-
"inquirer": "^
|
|
52
|
+
"inquirer": "^9.0.7",
|
|
53
53
|
"jimp": "^0.22.7",
|
|
54
54
|
"lodash.template": "^4.5.0",
|
|
55
55
|
"mime-types": "^2.1.28",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"tar": "^6.1.0",
|
|
58
58
|
"valid-url": "^1.0.9"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "d13036a031c271bff2e187beeac21caec6ff909c"
|
|
61
61
|
}
|
|
@@ -51,11 +51,12 @@ def twaManifest = [
|
|
|
51
51
|
]
|
|
52
52
|
|
|
53
53
|
android {
|
|
54
|
-
compileSdkVersion
|
|
54
|
+
compileSdkVersion 35
|
|
55
|
+
namespace "<%= packageId %>"
|
|
55
56
|
defaultConfig {
|
|
56
57
|
applicationId "<%= packageId %>"
|
|
57
58
|
minSdkVersion <%= minSdkVersion %>
|
|
58
|
-
targetSdkVersion
|
|
59
|
+
targetSdkVersion 35
|
|
59
60
|
versionCode <%= appVersionCode %>
|
|
60
61
|
versionName "<%= appVersionName %>"
|
|
61
62
|
|
|
@@ -191,7 +191,11 @@
|
|
|
191
191
|
<category android:name="android.intent.category.DEFAULT" />
|
|
192
192
|
<category android:name="android.intent.category.BROWSABLE"/>
|
|
193
193
|
<data android:scheme="https"
|
|
194
|
-
android:host="@string/hostName"
|
|
194
|
+
android:host="@string/hostName"
|
|
195
|
+
<% if (fullScopeUrl && fullScopeUrl.pathname !== '/') { %>
|
|
196
|
+
android:pathPrefix="<%= fullScopeUrl.pathname %>"
|
|
197
|
+
<% } %>
|
|
198
|
+
/>
|
|
195
199
|
</intent-filter>
|
|
196
200
|
|
|
197
201
|
<% for (const additionalOrigin of additionalTrustedOrigins) { %>
|
|
@@ -23,7 +23,7 @@ buildscript {
|
|
|
23
23
|
jcenter()
|
|
24
24
|
}
|
|
25
25
|
dependencies {
|
|
26
|
-
classpath 'com.android.tools.build:gradle:
|
|
26
|
+
classpath 'com.android.tools.build:gradle:8.5.0'
|
|
27
27
|
|
|
28
28
|
// NOTE: Do not place your application dependencies here; they belong
|
|
29
29
|
// in the individual module build.gradle files
|
|
@@ -2,4 +2,6 @@ distributionBase=GRADLE_USER_HOME
|
|
|
2
2
|
distributionPath=wrapper/dists
|
|
3
3
|
zipStoreBase=GRADLE_USER_HOME
|
|
4
4
|
zipStorePath=wrapper/dists
|
|
5
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-
|
|
5
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
|
6
|
+
networkTimeout=10000
|
|
7
|
+
validateDistributionUrl=true
|
package/template_project/gradlew
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
#!/
|
|
1
|
+
#!/bin/sh
|
|
2
2
|
|
|
3
3
|
#
|
|
4
|
-
# Copyright 2015 the original
|
|
4
|
+
# Copyright © 2015-2021 the original authors.
|
|
5
5
|
#
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
# you may not use this file except in compliance with the License.
|
|
@@ -17,78 +17,111 @@
|
|
|
17
17
|
#
|
|
18
18
|
|
|
19
19
|
##############################################################################
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
#
|
|
21
|
+
# Gradle start up script for POSIX generated by Gradle.
|
|
22
|
+
#
|
|
23
|
+
# Important for running:
|
|
24
|
+
#
|
|
25
|
+
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
26
|
+
# noncompliant, but you have some other compliant shell such as ksh or
|
|
27
|
+
# bash, then to run this script, type that shell name before the whole
|
|
28
|
+
# command line, like:
|
|
29
|
+
#
|
|
30
|
+
# ksh Gradle
|
|
31
|
+
#
|
|
32
|
+
# Busybox and similar reduced shells will NOT work, because this script
|
|
33
|
+
# requires all of these POSIX shell features:
|
|
34
|
+
# * functions;
|
|
35
|
+
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
36
|
+
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
37
|
+
# * compound commands having a testable exit status, especially «case»;
|
|
38
|
+
# * various built-in commands including «command», «set», and «ulimit».
|
|
39
|
+
#
|
|
40
|
+
# Important for patching:
|
|
41
|
+
#
|
|
42
|
+
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
43
|
+
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
44
|
+
#
|
|
45
|
+
# The "traditional" practice of packing multiple parameters into a
|
|
46
|
+
# space-separated string is a well documented source of bugs and security
|
|
47
|
+
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
48
|
+
# options in "$@", and eventually passing that to Java.
|
|
49
|
+
#
|
|
50
|
+
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
51
|
+
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
52
|
+
# see the in-line comments for details.
|
|
53
|
+
#
|
|
54
|
+
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
55
|
+
# Darwin, MinGW, and NonStop.
|
|
56
|
+
#
|
|
57
|
+
# (3) This script is generated from the Groovy template
|
|
58
|
+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
59
|
+
# within the Gradle project.
|
|
60
|
+
#
|
|
61
|
+
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
62
|
+
#
|
|
23
63
|
##############################################################################
|
|
24
64
|
|
|
25
65
|
# Attempt to set APP_HOME
|
|
66
|
+
|
|
26
67
|
# Resolve links: $0 may be a link
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
68
|
+
app_path=$0
|
|
69
|
+
|
|
70
|
+
# Need this for daisy-chained symlinks.
|
|
71
|
+
while
|
|
72
|
+
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
|
73
|
+
[ -h "$app_path" ]
|
|
74
|
+
do
|
|
75
|
+
ls=$( ls -ld "$app_path" )
|
|
76
|
+
link=${ls#*' -> '}
|
|
77
|
+
case $link in #(
|
|
78
|
+
/*) app_path=$link ;; #(
|
|
79
|
+
*) app_path=$APP_HOME$link ;;
|
|
80
|
+
esac
|
|
37
81
|
done
|
|
38
|
-
SAVED="`pwd`"
|
|
39
|
-
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
40
|
-
APP_HOME="`pwd -P`"
|
|
41
|
-
cd "$SAVED" >/dev/null
|
|
42
82
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
#
|
|
47
|
-
|
|
83
|
+
# This is normally unused
|
|
84
|
+
# shellcheck disable=SC2034
|
|
85
|
+
APP_BASE_NAME=${0##*/}
|
|
86
|
+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
|
87
|
+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
|
48
88
|
|
|
49
89
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
50
|
-
MAX_FD=
|
|
90
|
+
MAX_FD=maximum
|
|
51
91
|
|
|
52
92
|
warn () {
|
|
53
93
|
echo "$*"
|
|
54
|
-
}
|
|
94
|
+
} >&2
|
|
55
95
|
|
|
56
96
|
die () {
|
|
57
97
|
echo
|
|
58
98
|
echo "$*"
|
|
59
99
|
echo
|
|
60
100
|
exit 1
|
|
61
|
-
}
|
|
101
|
+
} >&2
|
|
62
102
|
|
|
63
103
|
# OS specific support (must be 'true' or 'false').
|
|
64
104
|
cygwin=false
|
|
65
105
|
msys=false
|
|
66
106
|
darwin=false
|
|
67
107
|
nonstop=false
|
|
68
|
-
case "
|
|
69
|
-
CYGWIN* )
|
|
70
|
-
|
|
71
|
-
;;
|
|
72
|
-
|
|
73
|
-
darwin=true
|
|
74
|
-
;;
|
|
75
|
-
MINGW* )
|
|
76
|
-
msys=true
|
|
77
|
-
;;
|
|
78
|
-
NONSTOP* )
|
|
79
|
-
nonstop=true
|
|
80
|
-
;;
|
|
108
|
+
case "$( uname )" in #(
|
|
109
|
+
CYGWIN* ) cygwin=true ;; #(
|
|
110
|
+
Darwin* ) darwin=true ;; #(
|
|
111
|
+
MSYS* | MINGW* ) msys=true ;; #(
|
|
112
|
+
NONSTOP* ) nonstop=true ;;
|
|
81
113
|
esac
|
|
82
114
|
|
|
83
115
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
84
116
|
|
|
117
|
+
|
|
85
118
|
# Determine the Java command to use to start the JVM.
|
|
86
119
|
if [ -n "$JAVA_HOME" ] ; then
|
|
87
120
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
88
121
|
# IBM's JDK on AIX uses strange locations for the executables
|
|
89
|
-
JAVACMD
|
|
122
|
+
JAVACMD=$JAVA_HOME/jre/sh/java
|
|
90
123
|
else
|
|
91
|
-
JAVACMD
|
|
124
|
+
JAVACMD=$JAVA_HOME/bin/java
|
|
92
125
|
fi
|
|
93
126
|
if [ ! -x "$JAVACMD" ] ; then
|
|
94
127
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
@@ -97,92 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the
|
|
|
97
130
|
location of your Java installation."
|
|
98
131
|
fi
|
|
99
132
|
else
|
|
100
|
-
JAVACMD=
|
|
101
|
-
|
|
133
|
+
JAVACMD=java
|
|
134
|
+
if ! command -v java >/dev/null 2>&1
|
|
135
|
+
then
|
|
136
|
+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
102
137
|
|
|
103
138
|
Please set the JAVA_HOME variable in your environment to match the
|
|
104
139
|
location of your Java installation."
|
|
140
|
+
fi
|
|
105
141
|
fi
|
|
106
142
|
|
|
107
143
|
# Increase the maximum file descriptors if we can.
|
|
108
|
-
if
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
144
|
+
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|
145
|
+
case $MAX_FD in #(
|
|
146
|
+
max*)
|
|
147
|
+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
|
148
|
+
# shellcheck disable=SC2039,SC3045
|
|
149
|
+
MAX_FD=$( ulimit -H -n ) ||
|
|
150
|
+
warn "Could not query maximum file descriptor limit"
|
|
151
|
+
esac
|
|
152
|
+
case $MAX_FD in #(
|
|
153
|
+
'' | soft) :;; #(
|
|
154
|
+
*)
|
|
155
|
+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
|
156
|
+
# shellcheck disable=SC2039,SC3045
|
|
157
|
+
ulimit -n "$MAX_FD" ||
|
|
158
|
+
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
159
|
+
esac
|
|
121
160
|
fi
|
|
122
161
|
|
|
123
|
-
#
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
162
|
+
# Collect all arguments for the java command, stacking in reverse order:
|
|
163
|
+
# * args from the command line
|
|
164
|
+
# * the main class name
|
|
165
|
+
# * -classpath
|
|
166
|
+
# * -D...appname settings
|
|
167
|
+
# * --module-path (only if needed)
|
|
168
|
+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
127
169
|
|
|
128
170
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
129
|
-
if
|
|
130
|
-
APP_HOME
|
|
131
|
-
CLASSPATH
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
136
|
-
SEP=""
|
|
137
|
-
for dir in $ROOTDIRSRAW ; do
|
|
138
|
-
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
139
|
-
SEP="|"
|
|
140
|
-
done
|
|
141
|
-
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
142
|
-
# Add a user-defined pattern to the cygpath arguments
|
|
143
|
-
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
144
|
-
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
145
|
-
fi
|
|
171
|
+
if "$cygwin" || "$msys" ; then
|
|
172
|
+
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
|
173
|
+
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
174
|
+
|
|
175
|
+
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
|
176
|
+
|
|
146
177
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
178
|
+
for arg do
|
|
179
|
+
if
|
|
180
|
+
case $arg in #(
|
|
181
|
+
-*) false ;; # don't mess with options #(
|
|
182
|
+
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
|
183
|
+
[ -e "$t" ] ;; #(
|
|
184
|
+
*) false ;;
|
|
185
|
+
esac
|
|
186
|
+
then
|
|
187
|
+
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
156
188
|
fi
|
|
157
|
-
|
|
189
|
+
# Roll the args list around exactly as many times as the number of
|
|
190
|
+
# args, so each arg winds up back in the position where it started, but
|
|
191
|
+
# possibly modified.
|
|
192
|
+
#
|
|
193
|
+
# NB: a `for` loop captures its iteration list before it begins, so
|
|
194
|
+
# changing the positional parameters here affects neither the number of
|
|
195
|
+
# iterations, nor the values presented in `arg`.
|
|
196
|
+
shift # remove old arg
|
|
197
|
+
set -- "$@" "$arg" # push replacement arg
|
|
158
198
|
done
|
|
159
|
-
case $i in
|
|
160
|
-
(0) set -- ;;
|
|
161
|
-
(1) set -- "$args0" ;;
|
|
162
|
-
(2) set -- "$args0" "$args1" ;;
|
|
163
|
-
(3) set -- "$args0" "$args1" "$args2" ;;
|
|
164
|
-
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
165
|
-
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
166
|
-
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
167
|
-
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
168
|
-
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
169
|
-
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
170
|
-
esac
|
|
171
199
|
fi
|
|
172
200
|
|
|
173
|
-
# Escape application args
|
|
174
|
-
save () {
|
|
175
|
-
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
|
176
|
-
echo " "
|
|
177
|
-
}
|
|
178
|
-
APP_ARGS=$(save "$@")
|
|
179
201
|
|
|
180
|
-
#
|
|
181
|
-
|
|
202
|
+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
203
|
+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
182
204
|
|
|
183
|
-
#
|
|
184
|
-
|
|
185
|
-
|
|
205
|
+
# Collect all arguments for the java command:
|
|
206
|
+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
|
207
|
+
# and any embedded shellness will be escaped.
|
|
208
|
+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
209
|
+
# treated as '${Hostname}' itself on the command line.
|
|
210
|
+
|
|
211
|
+
set -- \
|
|
212
|
+
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
213
|
+
-classpath "$CLASSPATH" \
|
|
214
|
+
org.gradle.wrapper.GradleWrapperMain \
|
|
215
|
+
"$@"
|
|
216
|
+
|
|
217
|
+
# Stop when "xargs" is not available.
|
|
218
|
+
if ! command -v xargs >/dev/null 2>&1
|
|
219
|
+
then
|
|
220
|
+
die "xargs is not available"
|
|
186
221
|
fi
|
|
187
222
|
|
|
223
|
+
# Use "xargs" to parse quoted args.
|
|
224
|
+
#
|
|
225
|
+
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
226
|
+
#
|
|
227
|
+
# In Bash we could simply go:
|
|
228
|
+
#
|
|
229
|
+
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
230
|
+
# set -- "${ARGS[@]}" "$@"
|
|
231
|
+
#
|
|
232
|
+
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
233
|
+
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
234
|
+
# character that might be a shell metacharacter, then use eval to reverse
|
|
235
|
+
# that process (while maintaining the separation between arguments), and wrap
|
|
236
|
+
# the whole thing up as a single "set" statement.
|
|
237
|
+
#
|
|
238
|
+
# This will of course break if any of these variables contains a newline or
|
|
239
|
+
# an unmatched quote.
|
|
240
|
+
#
|
|
241
|
+
|
|
242
|
+
eval "set -- $(
|
|
243
|
+
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
244
|
+
xargs -n1 |
|
|
245
|
+
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
246
|
+
tr '\n' ' '
|
|
247
|
+
)" '"$@"'
|
|
248
|
+
|
|
188
249
|
exec "$JAVACMD" "$@"
|