mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 02:12:58 +08:00
Moving Android Manifest finding to the Gradle and Studio builders.
This commit is contained in:
parent
d88df59c32
commit
23d8d99925
@ -125,9 +125,10 @@ function writeProjectProperties(projectPath, target_api) {
|
|||||||
fs.writeFileSync(dstPath, data);
|
fs.writeFileSync(dstPath, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This makes no sense, what if you're building with a different build system?
|
||||||
function prepBuildFiles(projectPath) {
|
function prepBuildFiles(projectPath) {
|
||||||
var buildModule = require(path.resolve(projectPath, 'cordova/lib/builders/builders'));
|
var buildModule = require(path.resolve(projectPath, 'cordova/lib/builders/builders'));
|
||||||
buildModule.getBuilder('gradle').prepBuildFiles();
|
buildModule.getBuilder('studio').prepBuildFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyBuildRules(projectPath) {
|
function copyBuildRules(projectPath) {
|
||||||
|
@ -27,7 +27,6 @@ var CordovaError = require('cordova-common').CordovaError;
|
|||||||
function GenericBuilder (projectDir) {
|
function GenericBuilder (projectDir) {
|
||||||
this.root = projectDir || path.resolve(__dirname, '../../..');
|
this.root = projectDir || path.resolve(__dirname, '../../..');
|
||||||
this.binDirs = {
|
this.binDirs = {
|
||||||
ant: path.join(this.root, hasCustomRules(this.root) ? 'ant-build' : 'bin'),
|
|
||||||
gradle: path.join(this.root, 'build', 'outputs', 'apk')
|
gradle: path.join(this.root, 'build', 'outputs', 'apk')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -59,37 +58,6 @@ GenericBuilder.prototype.findOutputApks = function(build_type, arch) {
|
|||||||
.sort(apkSorter);
|
.sort(apkSorter);
|
||||||
};
|
};
|
||||||
|
|
||||||
GenericBuilder.prototype.readProjectProperties = function () {
|
|
||||||
function findAllUniq(data, r) {
|
|
||||||
var s = {};
|
|
||||||
var m;
|
|
||||||
while ((m = r.exec(data))) {
|
|
||||||
s[m[1]] = 1;
|
|
||||||
}
|
|
||||||
return Object.keys(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = fs.readFileSync(path.join(this.root, 'project.properties'), 'utf8');
|
|
||||||
return {
|
|
||||||
libs: findAllUniq(data, /^\s*android\.library\.reference\.\d+=(.*)(?:\s|$)/mg),
|
|
||||||
gradleIncludes: findAllUniq(data, /^\s*cordova\.gradle\.include\.\d+=(.*)(?:\s|$)/mg),
|
|
||||||
systemLibs: findAllUniq(data, /^\s*cordova\.system\.library\.\d+=(.*)(?:\s|$)/mg)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
GenericBuilder.prototype.extractRealProjectNameFromManifest = function () {
|
|
||||||
var manifestPath = path.join(this.root, 'AndroidManifest.xml');
|
|
||||||
var manifestData = fs.readFileSync(manifestPath, 'utf8');
|
|
||||||
var m = /<manifest[\s\S]*?package\s*=\s*"(.*?)"/i.exec(manifestData);
|
|
||||||
if (!m) {
|
|
||||||
throw new CordovaError('Could not find package name in ' + manifestPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
var packageName=m[1];
|
|
||||||
var lastDotIndex = packageName.lastIndexOf('.');
|
|
||||||
return packageName.substring(lastDotIndex + 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = GenericBuilder;
|
module.exports = GenericBuilder;
|
||||||
|
|
||||||
function apkSorter(fileA, fileB) {
|
function apkSorter(fileA, fileB) {
|
||||||
|
@ -79,6 +79,37 @@ GradleBuilder.prototype.runGradleWrapper = function(gradle_cmd) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GradleBuilder.prototype.readProjectProperties = function () {
|
||||||
|
function findAllUniq(data, r) {
|
||||||
|
var s = {};
|
||||||
|
var m;
|
||||||
|
while ((m = r.exec(data))) {
|
||||||
|
s[m[1]] = 1;
|
||||||
|
}
|
||||||
|
return Object.keys(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = fs.readFileSync(path.join(this.root, 'project.properties'), 'utf8');
|
||||||
|
return {
|
||||||
|
libs: findAllUniq(data, /^\s*android\.library\.reference\.\d+=(.*)(?:\s|$)/mg),
|
||||||
|
gradleIncludes: findAllUniq(data, /^\s*cordova\.gradle\.include\.\d+=(.*)(?:\s|$)/mg),
|
||||||
|
systemLibs: findAllUniq(data, /^\s*cordova\.system\.library\.\d+=(.*)(?:\s|$)/mg)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
GradleBuilder.prototype.extractRealProjectNameFromManifest = function () {
|
||||||
|
var manifestPath = path.join(this.root, 'AndroidManifest.xml');
|
||||||
|
var manifestData = fs.readFileSync(manifestPath, 'utf8');
|
||||||
|
var m = /<manifest[\s\S]*?package\s*=\s*"(.*?)"/i.exec(manifestData);
|
||||||
|
if (!m) {
|
||||||
|
throw new CordovaError('Could not find package name in ' + manifestPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
var packageName=m[1];
|
||||||
|
var lastDotIndex = packageName.lastIndexOf('.');
|
||||||
|
return packageName.substring(lastDotIndex + 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Makes the project buildable, minus the gradle wrapper.
|
// Makes the project buildable, minus the gradle wrapper.
|
||||||
GradleBuilder.prototype.prepBuildFiles = function() {
|
GradleBuilder.prototype.prepBuildFiles = function() {
|
||||||
|
@ -80,6 +80,39 @@ StudioBuilder.prototype.runGradleWrapper = function(gradle_cmd) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
StudioBuilder.prototype.readProjectProperties = function () {
|
||||||
|
function findAllUniq(data, r) {
|
||||||
|
var s = {};
|
||||||
|
var m;
|
||||||
|
while ((m = r.exec(data))) {
|
||||||
|
s[m[1]] = 1;
|
||||||
|
}
|
||||||
|
return Object.keys(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = fs.readFileSync(path.join(this.root, 'project.properties'), 'utf8');
|
||||||
|
return {
|
||||||
|
libs: findAllUniq(data, /^\s*android\.library\.reference\.\d+=(.*)(?:\s|$)/mg),
|
||||||
|
gradleIncludes: findAllUniq(data, /^\s*cordova\.gradle\.include\.\d+=(.*)(?:\s|$)/mg),
|
||||||
|
systemLibs: findAllUniq(data, /^\s*cordova\.system\.library\.\d+=(.*)(?:\s|$)/mg)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
StudioBuilder.prototype.extractRealProjectNameFromManifest = function () {
|
||||||
|
var manifestPath = path.join(this.root, 'app', 'src', 'main', 'AndroidManifest.xml');
|
||||||
|
var manifestData = fs.readFileSync(manifestPath, 'utf8');
|
||||||
|
var m = /<manifest[\s\S]*?package\s*=\s*"(.*?)"/i.exec(manifestData);
|
||||||
|
if (!m) {
|
||||||
|
throw new CordovaError('Could not find package name in ' + manifestPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
var packageName=m[1];
|
||||||
|
var lastDotIndex = packageName.lastIndexOf('.');
|
||||||
|
return packageName.substring(lastDotIndex + 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Makes the project buildable, minus the gradle wrapper.
|
// Makes the project buildable, minus the gradle wrapper.
|
||||||
StudioBuilder.prototype.prepBuildFiles = function() {
|
StudioBuilder.prototype.prepBuildFiles = function() {
|
||||||
// Update the version of build.gradle in each dependent library.
|
// Update the version of build.gradle in each dependent library.
|
||||||
|
Loading…
Reference in New Issue
Block a user