mirror of
https://github.com/apache/cordova-android.git
synced 2026-01-30 00:05:28 +08:00
feat!: bump Gradle 7.6 & AGP 7.4.2 (#1539)
* feat: bump gradle 7.6 * feat: bump android gradle plugin 7.3.1 * feat: bump android gradle plugin 7.4.2 * fix!: move android package name to build.gradle namespace * fix!: remove deprecated package name from AndroidManifest * fix: package name * fix: rename CordovaGradleConfigParser's _save to write * test: fix CordovaGradleConfigParser related specs * fix: test refactoring for gradle namespace * fix: accidental variable naming mixing --------- Co-authored-by: Norman Breau <norman@nbsolutions.ca>
This commit is contained in:
71
lib/config/CordovaGradleConfigParser.js
Normal file
71
lib/config/CordovaGradleConfigParser.js
Normal file
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const events = require('cordova-common').events;
|
||||
|
||||
class CordovaGradleConfigParser {
|
||||
/**
|
||||
* Loads and Edits Gradle Properties File.
|
||||
*
|
||||
* Do not construct this directly. Use CordovaGradleConfigParserFactory instead.
|
||||
*
|
||||
* @param {String} platformDir is the path of the Android platform directory
|
||||
*/
|
||||
constructor (platformDir) {
|
||||
this._cdvGradleConfigFilePath = path.join(platformDir, 'cdv-gradle-config.json');
|
||||
this._cdvGradleConfig = this._readConfig(this._cdvGradleConfigFilePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and parses the configuration JSON file
|
||||
*
|
||||
* @param {String} configPath
|
||||
* @returns {Record<any, any>} The parsed JSON object representing the gradle config.
|
||||
*/
|
||||
_readConfig (configPath) {
|
||||
return fs.readJSONSync(configPath, 'utf-8');
|
||||
}
|
||||
|
||||
setPackageName (packageName) {
|
||||
events.emit('verbose', '[Cordova Gradle Config] Setting "PACKAGE_NAMESPACE" to ' + packageName);
|
||||
this._cdvGradleConfig.PACKAGE_NAMESPACE = packageName;
|
||||
return this;
|
||||
}
|
||||
|
||||
getPackageName () {
|
||||
return this._cdvGradleConfig.PACKAGE_NAMESPACE;
|
||||
}
|
||||
|
||||
getProjectNameFromPackageName () {
|
||||
const packageName = this._cdvGradleConfig.PACKAGE_NAMESPACE;
|
||||
return packageName.substring(packageName.lastIndexOf('.') + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves any changes that has been made to the properties file.
|
||||
*/
|
||||
write () {
|
||||
events.emit('verbose', '[Cordova Gradle Config] Saving File');
|
||||
fs.writeJSONSync(this._cdvGradleConfigFilePath, this._cdvGradleConfig, 'utf-8');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CordovaGradleConfigParser;
|
||||
35
lib/config/CordovaGradleConfigParserFactory.js
Normal file
35
lib/config/CordovaGradleConfigParserFactory.js
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
/**
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
const CordovaGradleConfigParser = require('./CordovaGradleConfigParser');
|
||||
|
||||
/**
|
||||
* Builds new gradle config parsers
|
||||
*/
|
||||
module.exports = class CordovaGradleConfigParserFactory {
|
||||
/**
|
||||
* Loads and Edits Gradle Properties File.
|
||||
*
|
||||
* @param {String} platformDir is the path of the Android platform directory
|
||||
*/
|
||||
static create (platformDir) {
|
||||
return new CordovaGradleConfigParser(platformDir);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user