Compare commits

...

4 Commits

Author SHA1 Message Date
Erisu
855fab238c release(android-v14.0.1): updated version and RELEASENOTES.md 2025-04-24 12:50:39 +09:00
エリス
2ffe68ab17 fix: configure gradle java.home (#1795) 2025-04-02 19:10:56 +09:00
エリス
f697ca7dec fix(windows): get gradle path with which command (#1793) 2025-03-28 20:30:40 +09:00
Erisu
1d82a3b52f chore: bump version 14.0.1-dev 2025-03-23 18:46:43 +09:00
6 changed files with 49 additions and 45 deletions

View File

@@ -20,8 +20,17 @@
-->
## Release Notes for Cordova (Android)
### 14.0.1 (Apr 24, 2025)
**Fixes:**
* [GH-1795](https://github.com/apache/cordova-android/pull/1795) fix: configure gradle `java.home`
* [GH-1793](https://github.com/apache/cordova-android/pull/1793) fix(windows): get gradle path with `which` command
### 14.0.0 (Mar 23, 2025)
**Breaking Changes:**
* [GH-1788](https://github.com/apache/cordova-android/pull/1788) dep!: bump npm packages
* nyc@17.1.0
* which@5.0.0

View File

@@ -31,7 +31,7 @@ import android.webkit.WebChromeClient.CustomViewCallback;
* are not expected to implement it.
*/
public interface CordovaWebView {
public static final String CORDOVA_VERSION = "14.0.0";
public static final String CORDOVA_VERSION = "14.0.1";
void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences);

View File

@@ -286,14 +286,49 @@ class ProjectBuilder {
prepEnv (opts) {
const self = this;
const config = this._getCordovaConfig();
const configPropertiesPath = path.join(self.root, 'tools', '.gradle', 'config.properties');
return check_reqs.check_gradle()
.then(function () {
events.emit('verbose', `Using Gradle: ${config.GRADLE_VERSION}`);
return self.installGradleWrapper(config.GRADLE_VERSION);
}).then(async function () {
try {
// Try to create "config.properties" file if missing
const fd = fs.openSync(configPropertiesPath, 'wx+', 0o600);
fs.writeFileSync(fd, '', 'utf8');
fs.closeSync(fd);
} catch {
// File already existed, nothing to do.
}
// Loads "config.properties"for editing
const configProperties = createEditor(configPropertiesPath);
/*
* File is replaced on each build. "before_build" hook scripts can inject
* custom settings before this step runs. This step will still overwrite
* the "java.home" setting. Ensure environment variables are properly
* configured if want to use custom "java.home".
*
* Sets "java.home" using the "CORDOVA_JAVA_HOME" environment variable.
* If unavailable, fallback to "JAVA_HOME".
* If neither is set, "java.home" is removed (if previously set),
* allowing Android Studio to display a warning and auto-configure
* to use its internal (bundled) Java.
*/
const javaHome = process.env.CORDOVA_JAVA_HOME || process.env.JAVA_HOME || false;
if (javaHome) {
configProperties.set('java.home', javaHome);
} else {
configProperties.unset('java.home');
}
// Saves changes
configProperties.save();
}).then(async function () {
await fsp.cp(path.join(self.root, 'tools', 'gradle'), path.join(self.root, 'gradle'), { recursive: true, force: true });
await fsp.cp(path.join(self.root, 'tools', 'gradlew'), path.join(self.root, 'gradlew'), { recursive: true, force: true });
await fsp.cp(path.join(self.root, 'tools', 'gradlew.bat'), path.join(self.root, 'gradlew.bat'), { recursive: true, force: true });
await fsp.cp(path.join(self.root, 'tools', '.gradle'), path.join(self.root, '.gradle'), { recursive: true, force: true });
}).then(function () {
return self.prepBuildFiles();
}).then(() => {

View File

@@ -17,7 +17,6 @@
under the License.
*/
const execa = require('execa');
const path = require('node:path');
const fs = require('node:fs');
const { forgivingWhichSync, isWindows, isDarwin } = require('./utils');
@@ -104,46 +103,7 @@ function getUserCompileSdkVersion (projectRoot) {
}
module.exports.get_gradle_wrapper = function () {
let androidStudioPath;
let i = 0;
let foundStudio = false;
let program_dir;
// OK, This hack only works on Windows, not on Mac OS or Linux. We will be deleting this eventually!
if (module.exports.isWindows()) {
// "shell" option enabled for CVE-2024-27980 (Windows) Mitigation
// See https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2 for more details
const result = execa.sync(path.join(__dirname, 'getASPath.bat'), { shell: true });
// console.log('result.stdout =' + result.stdout.toString());
// console.log('result.stderr =' + result.stderr.toString());
if (result.stderr.toString().length > 0) {
const androidPath = path.join(process.env.ProgramFiles, 'Android') + '/';
if (fs.existsSync(androidPath)) {
program_dir = fs.readdirSync(androidPath);
while (i < program_dir.length && !foundStudio) {
if (program_dir[i].startsWith('Android Studio')) {
foundStudio = true;
androidStudioPath = path.join(process.env.ProgramFiles, 'Android', program_dir[i], 'gradle');
} else { ++i; }
}
}
} else {
// console.log('got android studio path from registry');
// remove the (os independent) new line char at the end of stdout
// add gradle to match the above.
androidStudioPath = path.join(result.stdout.toString().split('\r\n')[0], 'gradle');
}
}
if (androidStudioPath !== null && fs.existsSync(androidStudioPath)) {
const dirs = fs.readdirSync(androidStudioPath);
if (dirs[0].split('-')[0] === 'gradle') {
return path.join(androidStudioPath, dirs[0], 'bin', 'gradle');
}
} else {
// OK, let's try to check for Gradle!
return forgivingWhichSync('gradle');
}
return forgivingWhichSync('gradle');
};
// Returns a promise. Called only by build and clean commands.

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "cordova-android",
"version": "14.0.0",
"version": "14.0.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "cordova-android",
"version": "14.0.0",
"version": "14.0.1",
"license": "Apache-2.0",
"dependencies": {
"android-versions": "^2.1.0",

View File

@@ -1,6 +1,6 @@
{
"name": "cordova-android",
"version": "14.0.0",
"version": "14.0.1",
"description": "cordova-android release",
"types": "./types/index.d.ts",
"main": "lib/Api.js",