mirror of
https://github.com/apache/cordova-android.git
synced 2026-02-10 00:03:01 +08:00
Compare commits
12 Commits
10.0.1
...
ci/connect
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c9e7fc96a | ||
|
|
5e52b7ee77 | ||
|
|
f3e98c8651 | ||
|
|
bbc9bcae14 | ||
|
|
cd49902ca3 | ||
|
|
f4a0e1ec78 | ||
|
|
b6c5db3e37 | ||
|
|
cba3410b17 | ||
|
|
565ac9c7b1 | ||
|
|
1636d70f25 | ||
|
|
4e5892c5ed | ||
|
|
e69ab6a687 |
@@ -29,7 +29,13 @@ buildscript {
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply from: 'repositories.gradle'
|
||||
def hasRepositoriesGradle = file('repositories.gradle').exists()
|
||||
if (hasRepositoriesGradle) {
|
||||
apply from: 'repositories.gradle'
|
||||
} else {
|
||||
apply from: "${project.rootDir}/repositories.gradle"
|
||||
}
|
||||
|
||||
repositories repos
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
"GRADLE_VERSION": "7.1.1",
|
||||
"MIN_BUILD_TOOLS_VERSION": "30.0.3",
|
||||
"AGP_VERSION": "4.2.2",
|
||||
"KOTLIN_VERSION": "1.5.20",
|
||||
"KOTLIN_VERSION": "1.5.21",
|
||||
"ANDROIDX_APP_COMPAT_VERSION": "1.3.0",
|
||||
"ANDROIDX_WEBKIT_VERSION": "1.4.0",
|
||||
"GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION": "4.3.5",
|
||||
"GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION": "4.3.8",
|
||||
"IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED": false,
|
||||
"IS_GRADLE_PLUGIN_KOTLIN_ENABLED": false
|
||||
}
|
||||
|
||||
@@ -24,16 +24,19 @@ import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class ConfigXmlParser {
|
||||
private static String TAG = "ConfigXmlParser";
|
||||
|
||||
private String launchUrl = null;
|
||||
private static String SCHEME_HTTP = "http";
|
||||
private static String SCHEME_HTTPS = "https";
|
||||
private static String DEFAULT_HOSTNAME = "localhost";
|
||||
|
||||
private String launchUrl;
|
||||
private String contentSrc;
|
||||
private CordovaPreferences prefs = new CordovaPreferences();
|
||||
private ArrayList<PluginEntry> pluginEntries = new ArrayList<PluginEntry>(20);
|
||||
|
||||
@@ -47,11 +50,7 @@ public class ConfigXmlParser {
|
||||
|
||||
public String getLaunchUrl() {
|
||||
if (launchUrl == null) {
|
||||
launchUrl = "https://" + this.prefs.getString("hostname", "localhost");
|
||||
}
|
||||
|
||||
if (this.prefs.getBoolean("AndroidInsecureFileModeEnabled", false)) {
|
||||
launchUrl = "file:///android_asset/www/index.html";
|
||||
setStartUrl(contentSrc);
|
||||
}
|
||||
|
||||
return launchUrl;
|
||||
@@ -130,7 +129,10 @@ public class ConfigXmlParser {
|
||||
else if (strNode.equals("content")) {
|
||||
String src = xml.getAttributeValue(null, "src");
|
||||
if (src != null) {
|
||||
setStartUrl(src);
|
||||
contentSrc = src;
|
||||
} else {
|
||||
// Default
|
||||
contentSrc = "index.html";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,20 +149,40 @@ public class ConfigXmlParser {
|
||||
}
|
||||
}
|
||||
|
||||
private String getLaunchUrlPrefix() {
|
||||
if (prefs.getBoolean("AndroidInsecureFileModeEnabled", false)) {
|
||||
return "file:///android_asset/www/";
|
||||
} else {
|
||||
String scheme = prefs.getString("scheme", SCHEME_HTTPS).toLowerCase();
|
||||
String hostname = prefs.getString("hostname", DEFAULT_HOSTNAME);
|
||||
|
||||
if (!scheme.contentEquals(SCHEME_HTTP) && !scheme.contentEquals(SCHEME_HTTPS)) {
|
||||
LOG.d(TAG, "The provided scheme \"" + scheme + "\" is not valid. " +
|
||||
"Defaulting to \"" + SCHEME_HTTPS + "\". " +
|
||||
"(Valid Options=" + SCHEME_HTTP + "," + SCHEME_HTTPS + ")");
|
||||
|
||||
scheme = SCHEME_HTTPS;
|
||||
}
|
||||
|
||||
return scheme + "://" + hostname + '/';
|
||||
}
|
||||
}
|
||||
|
||||
private void setStartUrl(String src) {
|
||||
Pattern schemeRegex = Pattern.compile("^[a-z-]+://");
|
||||
Matcher matcher = schemeRegex.matcher(src);
|
||||
|
||||
if (matcher.find()) {
|
||||
launchUrl = src;
|
||||
} else {
|
||||
String launchUrlPrefix = getLaunchUrlPrefix();
|
||||
|
||||
// remove leading slash, "/", from content src if existing,
|
||||
if (src.charAt(0) == '/') {
|
||||
src = src.substring(1);
|
||||
}
|
||||
if (this.prefs.getBoolean("AndroidInsecureFileModeEnabled", false)) {
|
||||
launchUrl = "file:///android_asset/www/" + src;
|
||||
} else {
|
||||
launchUrl = "https://" + this.prefs.getString("hostname", "localhost") + "/" + src;
|
||||
}
|
||||
|
||||
launchUrl = launchUrlPrefix + src;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import android.webkit.WebChromeClient.CustomViewCallback;
|
||||
* are not expected to implement it.
|
||||
*/
|
||||
public interface CordovaWebView {
|
||||
public static final String CORDOVA_VERSION = "10.0.1";
|
||||
public static final String CORDOVA_VERSION = "10.1.0-dev";
|
||||
|
||||
void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences);
|
||||
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cordova-android",
|
||||
"version": "10.0.1",
|
||||
"version": "10.1.0-dev",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cordova-android",
|
||||
"version": "10.0.1",
|
||||
"version": "10.1.0-dev",
|
||||
"description": "cordova-android release",
|
||||
"main": "lib/Api.js",
|
||||
"repository": "github:apache/cordova-android",
|
||||
@@ -12,13 +12,13 @@
|
||||
],
|
||||
"scripts": {
|
||||
"prepare": "cordova-js build > templates/project/assets/www/cordova.js",
|
||||
"test": "npm run lint && npm run cover && npm run java-unit-tests",
|
||||
"test": "npm run lint && npm run cover && npm run java-tests",
|
||||
"lint": "eslint lib spec test \"templates/cordova/**/!(*.*)\"",
|
||||
"unit-tests": "jasmine --config=spec/unit/jasmine.json",
|
||||
"cover": "nyc jasmine --config=spec/coverage.json",
|
||||
"e2e-tests": "jasmine --config=spec/e2e/jasmine.json",
|
||||
"java-unit-tests": "node test/run_java_unit_tests.js",
|
||||
"clean:java-unit-tests": "node test/clean.js"
|
||||
"java-tests": "node test/java_test_runner.js",
|
||||
"clean:java-tests": "node test/clean.js"
|
||||
},
|
||||
"author": "Apache Software Foundation",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -60,7 +60,13 @@ buildscript {
|
||||
|
||||
// Allow plugins to declare Maven dependencies via build-extras.gradle.
|
||||
allprojects {
|
||||
apply from: 'repositories.gradle'
|
||||
def hasRepositoriesGradle = file('repositories.gradle').exists()
|
||||
if (hasRepositoriesGradle) {
|
||||
apply from: 'repositories.gradle'
|
||||
} else {
|
||||
apply from: "${project.rootDir}/repositories.gradle"
|
||||
}
|
||||
|
||||
repositories repos
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,13 @@ buildscript {
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply from: 'repositories.gradle'
|
||||
def hasRepositoriesGradle = file('repositories.gradle').exists()
|
||||
if (hasRepositoriesGradle) {
|
||||
apply from: 'repositories.gradle'
|
||||
} else {
|
||||
apply from: "${project.rootDir}/repositories.gradle"
|
||||
}
|
||||
|
||||
repositories repos
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ dependencies {
|
||||
androidTestImplementation('androidx.test.espresso:espresso-web:3.1.1', {
|
||||
exclude group: 'androidx.test.espresso', module: 'androidx.annotation'
|
||||
})
|
||||
|
||||
androidTestImplementation 'androidx.test:rules:1.4.0'
|
||||
}
|
||||
repositories {
|
||||
google()
|
||||
|
||||
@@ -158,7 +158,7 @@ public class BackButtonMultipageTest {
|
||||
assertEquals(START_URL, mActivity.onPageFinishedUrl.take());
|
||||
}
|
||||
|
||||
private void assertPageSample(String url) {
|
||||
private void assertPageSample(String url) throws Throwable {
|
||||
assertEquals(url, mActivity.onPageFinishedUrl.take());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
|
||||
/**
|
||||
* This script is to be run manually (e.g. by npm run clean:java-unit-tests) if
|
||||
* This script is to be run manually (e.g. by npm run clean:java-tests) if
|
||||
* you want to upgrade gradlew or test its proper generation.
|
||||
*/
|
||||
|
||||
|
||||
@@ -46,9 +46,13 @@ class AndroidTestRunner {
|
||||
return new ProjectBuilder(this.projectDir).runGradleWrapper('gradle');
|
||||
}
|
||||
|
||||
_log (...args) {
|
||||
console.log(...[`[${this.testTitle}]`, ...args]);
|
||||
}
|
||||
|
||||
run () {
|
||||
return Promise.resolve()
|
||||
.then(_ => console.log(`[${this.testTitle}] Preparing Gradle wrapper for Java unit tests.`))
|
||||
.then(_ => this._log('Staging Project Files'))
|
||||
.then(_ => {
|
||||
// TODO we should probably not only copy these files, but instead create a new project from scratch
|
||||
fs.copyFileSync(path.resolve(this.projectDir, '../../framework/cdv-gradle-config-defaults.json'), path.resolve(this.projectDir, 'cdv-gradle-config.json'));
|
||||
@@ -57,26 +61,35 @@ class AndroidTestRunner {
|
||||
path.join(this.projectDir, 'app/src/main/assets/www/cordova.js')
|
||||
);
|
||||
})
|
||||
|
||||
.then(_ => this._log('Creating Gradle Wrapper'))
|
||||
.then(_ => this._createProjectBuilder())
|
||||
|
||||
.then(_ => this._log('Getting Gradle Wrapper Version Info'))
|
||||
.then(_ => this._gradlew('--version'))
|
||||
.then(_ => console.log(`[${this.testTitle}] Gradle wrapper is ready. Running tests now.`))
|
||||
|
||||
.then(_ => this._log('Running Java Unit Tests'))
|
||||
.then(_ => this._gradlew('test'))
|
||||
.then(_ => console.log(`[${this.testTitle}] Java unit tests completed successfully`));
|
||||
.then(_ => this._log('Finished Java Unit Test'))
|
||||
|
||||
.then(_ => this._log('Running Java Instrumentation Tests'))
|
||||
.then(_ => this._gradlew('connectedAndroidTest'))
|
||||
.then(_ => this._log('Finished Java Instrumentation Tests'));
|
||||
}
|
||||
}
|
||||
|
||||
Promise.resolve()
|
||||
.then(_ => console.log('Starting to run all android platform tests'))
|
||||
.then(_ => console.log('Starting Android Platform Java Tests'))
|
||||
|
||||
// AndroidX Test
|
||||
.then(_ => new AndroidTestRunner('AndroidX Project', path.resolve(__dirname, 'androidx')))
|
||||
.then(test => test.run())
|
||||
|
||||
.then(_ => console.log('Finished running all android platform tests'));
|
||||
.then(_ => console.log('Finished Running Android Platform Java Tests'));
|
||||
|
||||
process.on('unhandledRejection', err => {
|
||||
// If err has a stderr property, we have seen the message already
|
||||
if (!('stderr' in err)) console.error(err.message);
|
||||
console.error('JAVA UNIT TESTS FAILED!');
|
||||
console.error('JAVA TESTS FAILED!');
|
||||
process.exitCode = err.code || 1;
|
||||
});
|
||||
Reference in New Issue
Block a user