Bug 1724480 - Upgrade JDK to Java 17. r=glandium,ahal,calu

Differential Revision: https://phabricator.services.mozilla.com/D131972
This commit is contained in:
Agi Sferro 2022-01-11 19:16:01 +00:00
parent 10649c9480
commit 024994e801
27 changed files with 170 additions and 134 deletions

View file

@ -57,6 +57,9 @@ allprojects {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository -> gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven { maven {
url repository url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
} }
} }
} }
@ -94,15 +97,18 @@ buildscript {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository -> gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven { maven {
url repository url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
} }
} }
} }
ext.kotlin_version = '1.5.20' ext.kotlin_version = '1.5.31'
dependencies { dependencies {
classpath 'org.mozilla.apilint:apilint:0.5.1' classpath 'org.mozilla.apilint:apilint:0.5.1'
classpath 'com.android.tools.build:gradle:4.2.0' classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2' classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
classpath 'org.apache.commons:commons-exec:1.3' classpath 'org.apache.commons:commons-exec:1.3'
classpath 'com.diffplug.spotless:spotless-plugin-gradle:5.16.0' classpath 'com.diffplug.spotless:spotless-plugin-gradle:5.16.0'

View file

@ -3,6 +3,6 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip
# Bug 1596208, Android Studio has a bug that prevents us from using this # Bug 1596208, Android Studio has a bug that prevents us from using this
# distributionSha256Sum=53b71812f18cdb2777e9f1b2a0f2038683907c90bdc406bc64d8b400e1fb2c3b # distributionSha256Sum=53b71812f18cdb2777e9f1b2a0f2038683907c90bdc406bc64d8b400e1fb2c3b

View file

@ -3,9 +3,9 @@ buildDir "${topobjdir}/gradle/build/mobile/android/annotations"
apply plugin: 'java' apply plugin: 'java'
dependencies { dependencies {
implementation 'com.android.tools.lint:lint:26.2.1' implementation 'com.android.tools.lint:lint:30.0.3'
implementation 'com.android.tools.lint:lint-checks:26.2.1' implementation 'com.android.tools.lint:lint-checks:30.0.3'
} }
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_11

View file

@ -56,6 +56,7 @@ package org.mozilla.gecko.annotationProcessors;
*/ */
import com.android.tools.lint.LintCliClient; import com.android.tools.lint.LintCliClient;
import com.android.tools.lint.checks.ApiLookup; import com.android.tools.lint.checks.ApiLookup;
import com.android.tools.lint.client.api.LintClient;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -211,7 +212,7 @@ public class SDKProcessor {
sMaxSdkVersion = Integer.parseInt(args[1]); sMaxSdkVersion = Integer.parseInt(args[1]);
final String outdir = args[2]; final String outdir = args[2];
final LintCliClient lintClient = new LintCliClient(); final LintCliClient lintClient = new LintCliClient(LintClient.CLIENT_CLI);
sApiLookup = ApiLookup.get(lintClient); sApiLookup = ApiLookup.get(lintClient);
for (int argIndex = 3; argIndex < args.length; argIndex += 2) { for (int argIndex = 3; argIndex < args.length; argIndex += 2) {

View file

@ -13,6 +13,8 @@ NO_NDK=1
ac_add_options --with-gradle ac_add_options --with-gradle
# We want to use (and populate!) the local Nexus repositories. # We want to use (and populate!) the local Nexus repositories.
export GRADLE_MAVEN_REPOSITORIES="http://localhost:8081/nexus/content/repositories/mozilla/","http://localhost:8081/nexus/content/repositories/google/","http://localhost:8081/nexus/content/repositories/central/","http://localhost:8081/nexus/content/repositories/gradle-plugins/" export GRADLE_MAVEN_REPOSITORIES="http://localhost:8081/nexus/content/repositories/mozilla/","http://localhost:8081/nexus/content/repositories/google/","http://localhost:8081/nexus/content/repositories/central/","http://localhost:8081/nexus/content/repositories/gradle-plugins/"
# Nexus runs on HTTP
ac_add_options --allow-insecure-gradle-repositories
# From here on, just like ../android-arm/nightly. # From here on, just like ../android-arm/nightly.

View file

@ -23,8 +23,8 @@ You need to add or edit four stanzas inside your module's ``build.gradle`` file.
.. code-block:: groovy .. code-block:: groovy
ext { ext {
geckoviewChannel = "nightly" geckoviewChannel = <channel>
geckoviewVersion = "70.0.20190712095934" geckoviewVersion = <version>
} }
@ -39,15 +39,15 @@ You need to add or edit four stanzas inside your module's ``build.gradle`` file.
} }
**3. Java 8 required support** **3. Java 11 required support**
As GeckoView uses some Java 8 APIs, it requires these compatibility flags: As GeckoView uses some Java 11 APIs, it requires these compatibility flags:
.. code-block:: groovy .. code-block:: groovy
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_11
} }
**4. Add GeckoView Implementations** **4. Add GeckoView Implementations**

View file

@ -9,8 +9,8 @@ android {
compileSdkVersion project.ext.compileSdkVersion compileSdkVersion project.ext.compileSdkVersion
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_11
} }
dexOptions { dexOptions {
javaMaxHeapSize "32g" javaMaxHeapSize "32g"

View file

@ -9,8 +9,8 @@ android {
compileSdkVersion project.ext.compileSdkVersion compileSdkVersion project.ext.compileSdkVersion
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_11
} }
dexOptions { dexOptions {
javaMaxHeapSize "32g" javaMaxHeapSize "32g"

View file

@ -137,8 +137,8 @@ android {
project.configureProductFlavors() project.configureProductFlavors()
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_11
} }
dexOptions { dexOptions {
@ -224,6 +224,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions { kotlinOptions {
allWarningsAsErrors = true allWarningsAsErrors = true
jvmTarget = JavaVersion.VERSION_11
} }
doFirst { doFirst {
@ -279,7 +280,7 @@ dependencies {
testImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" testImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:4.3' testImplementation 'org.robolectric:robolectric:4.7.3'
testImplementation 'org.mockito:mockito-core:1.10.19' testImplementation 'org.mockito:mockito-core:1.10.19'
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
@ -328,7 +329,7 @@ android.libraryVariants.all { variant ->
def results = [] def results = []
def listener = { def listener = {
if (!it.toLowerCase().contains("warning") && !it.toLowerCase().contains("error")) { if (!it.toLowerCase().contains("warning:") && !it.toLowerCase().contains("error:")) {
// Likely not an error or a warning // Likely not an error or a warning
return return
} }
@ -366,45 +367,42 @@ android.libraryVariants.all { variant ->
variant.generateBuildConfigProvider.get().sourceOutputDir.asFile.get() + variant.generateBuildConfigProvider.get().sourceOutputDir.asFile.get() +
variant.aidlCompileProvider.get().sourceOutputDir.asFile.get() variant.aidlCompileProvider.get().sourceOutputDir.asFile.get()
) )
options.addStringOption("Xmaxwarns", "1000")
classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += variant.javaCompileProvider.get().classpath classpath += variant.javaCompileProvider.get().classpath
// javadoc 8 has a bug that requires the rt.jar file from the JRE to be
// in the bootclasspath (https://stackoverflow.com/a/30458820).
options.bootClasspath = [
file("${System.properties['java.home']}/lib/rt.jar")] + android.bootClasspath
options.memberLevel = JavadocMemberLevel.PROTECTED options.memberLevel = JavadocMemberLevel.PROTECTED
options.source = 8 options.source = 11
options.links("https://d.android.com/reference/") options.links("https://developer.android.com/reference")
options.docTitle = "GeckoView ${mozconfig.substs.MOZ_APP_VERSION} API" options.docTitle = "GeckoView ${mozconfig.substs.MOZ_APP_VERSION} API"
options.header = "GeckoView ${mozconfig.substs.MOZ_APP_VERSION} API" options.header = "GeckoView ${mozconfig.substs.MOZ_APP_VERSION} API"
options.noTimestamp = true options.noTimestamp = true
options.noIndex = true
options.noQualifiers = ['java.lang'] options.noQualifiers = ['java.lang']
options.tags = ['hide:a:'] options.tags = ['hide:a:']
} }
def javadocJar = task("javadocJar${name.capitalize()}", type: Jar, dependsOn: javadoc) { def javadocJar = task("javadocJar${name.capitalize()}", type: Jar, dependsOn: javadoc) {
classifier = 'javadoc' classifier = 'javadoc'
from javadoc.destinationDir destinationDirectory = javadoc.destinationDir
} }
// This task is used by `mach android geckoview-docs`. // This task is used by `mach android geckoview-docs`.
task("javadocCopyJar${name.capitalize()}", type: Copy) { task("javadocCopyJar${name.capitalize()}", type: Copy) {
from(javadocJar.destinationDir) { from(javadocJar.destinationDirectory) {
include 'geckoview-*-javadoc.jar' include 'geckoview-*-javadoc.jar'
rename { _ -> 'geckoview-javadoc.jar' } rename { _ -> 'geckoview-javadoc.jar' }
} }
into javadocJar.destinationDir into javadocJar.destinationDirectory
dependsOn javadocJar dependsOn javadocJar
} }
def sourcesJar = task("sourcesJar${name.capitalize()}", type: Jar) { def sourcesJar = task("sourcesJar${name.capitalize()}", type: Jar) {
classifier 'sources' classifier 'sources'
description = "Generate Javadoc for build variant $name" description = "Generate Javadoc for build variant $name"
destinationDir = new File(destinationDir, variant.baseName) destinationDirectory =
file("${topobjdir}/mobile/android/geckoview/sources/${variant.baseName}")
from files(variant.sourceSets.collect({ it.java.srcDirs }).flatten()) from files(variant.sourceSets.collect({ it.java.srcDirs }).flatten())
} }
@ -561,6 +559,7 @@ android.libraryVariants.all configureVariantDebugLevel
task("generateSDKBindings", type: JavaExec) { task("generateSDKBindings", type: JavaExec) {
classpath project(':annotations').jar.archivePath classpath project(':annotations').jar.archivePath
classpath project(':annotations').compileJava.classpath classpath project(':annotations').compileJava.classpath
classpath project(':annotations').sourceSets.main.runtimeClasspath
// To use the lint APIs: "Lint must be invoked with the System property // To use the lint APIs: "Lint must be invoked with the System property
// com.android.tools.lint.bindir pointing to the ANDROID_SDK tools // com.android.tools.lint.bindir pointing to the ANDROID_SDK tools
@ -569,7 +568,7 @@ task("generateSDKBindings", type: JavaExec) {
'com.android.tools.lint.bindir': "${android.sdkDirectory}/tools", 'com.android.tools.lint.bindir': "${android.sdkDirectory}/tools",
] ]
main = 'org.mozilla.gecko.annotationProcessors.SDKProcessor' mainClass = 'org.mozilla.gecko.annotationProcessors.SDKProcessor'
// We only want to generate bindings for the main framework JAR, // We only want to generate bindings for the main framework JAR,
// but not any of the additional android.test libraries. // but not any of the additional android.test libraries.
args android.bootClasspath.findAll { it.getName().startsWith('android.jar') } args android.bootClasspath.findAll { it.getName().startsWith('android.jar') }

View file

@ -15,6 +15,7 @@ import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
import android.util.Log; import android.util.Log;
import androidx.annotation.RequiresApi;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -31,6 +32,7 @@ import java.util.UUID;
import org.mozilla.gecko.util.ProxySelector; import org.mozilla.gecko.util.ProxySelector;
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public class GeckoMediaDrmBridgeV21 implements GeckoMediaDrm { public class GeckoMediaDrmBridgeV21 implements GeckoMediaDrm {
protected final String LOGTAG; protected final String LOGTAG;
private static final String INVALID_SESSION_ID = "Invalid"; private static final String INVALID_SESSION_ID = "Invalid";

View file

@ -6,6 +6,7 @@
package org.mozilla.geckoview; package org.mozilla.geckoview;
import android.annotation.SuppressLint;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.text.TextUtils; import android.text.TextUtils;
@ -518,7 +519,7 @@ public class ContentBlocking {
* *
* @return The categories of resources to be blocked. * @return The categories of resources to be blocked.
*/ */
public @CBAntiTracking int getSafeBrowsingCategories() { public @CBSafeBrowsing int getSafeBrowsingCategories() {
return ContentBlocking.sbMalwareToSbCat(mSbMalware.get()) return ContentBlocking.sbMalwareToSbCat(mSbMalware.get())
| ContentBlocking.sbPhishingToSbCat(mSbPhishing.get()); | ContentBlocking.sbPhishingToSbCat(mSbPhishing.get());
} }
@ -528,6 +529,7 @@ public class ContentBlocking {
* *
* @return The assigned behavior, as one of {@link CookieBehavior} flags. * @return The assigned behavior, as one of {@link CookieBehavior} flags.
*/ */
@SuppressLint("WrongConstant")
public @CBCookieBehavior int getCookieBehavior() { public @CBCookieBehavior int getCookieBehavior() {
return mCookieBehavior.get(); return mCookieBehavior.get();
} }
@ -549,6 +551,7 @@ public class ContentBlocking {
* *
* @return The assigned behavior, as one of {@link CookieBehavior} flags. * @return The assigned behavior, as one of {@link CookieBehavior} flags.
*/ */
@SuppressLint("WrongConstant")
public @CBCookieBehavior int getCookieBehaviorPrivateMode() { public @CBCookieBehavior int getCookieBehaviorPrivateMode() {
return mCookieBehaviorPrivateMode.get(); return mCookieBehaviorPrivateMode.get();
} }
@ -570,6 +573,7 @@ public class ContentBlocking {
* *
* @return The assigned lifetime, as one of {@link CookieLifetime} flags. * @return The assigned lifetime, as one of {@link CookieLifetime} flags.
*/ */
@SuppressLint("WrongConstant")
public @CBCookieLifetime int getCookieLifetime() { public @CBCookieLifetime int getCookieLifetime() {
return mCookieLifetime.get(); return mCookieLifetime.get();
} }

View file

@ -149,7 +149,7 @@ public class ContentBlockingController {
} }
protected BlockingData() { protected BlockingData() {
category = 0; category = Event.BLOCKED_TRACKING_CONTENT;
blocked = false; blocked = false;
count = 0; count = 0;
} }

View file

@ -2789,9 +2789,9 @@ public class GeckoSession {
/** Empty constructor for tests */ /** Empty constructor for tests */
protected SecurityInformation() { protected SecurityInformation() {
mixedModePassive = 0; mixedModePassive = CONTENT_UNKNOWN;
mixedModeActive = 0; mixedModeActive = CONTENT_UNKNOWN;
securityMode = 0; securityMode = SECURITY_MODE_UNKNOWN;
isSecure = false; isSecure = false;
isException = false; isException = false;
origin = ""; origin = "";
@ -3449,7 +3449,11 @@ public class GeckoSession {
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef( @IntDef(
flag = true, flag = true,
value = {SelectionActionDelegate.FLAG_IS_COLLAPSED, SelectionActionDelegate.FLAG_IS_EDITABLE}) value = {
SelectionActionDelegate.FLAG_IS_COLLAPSED,
SelectionActionDelegate.FLAG_IS_EDITABLE,
SelectionActionDelegate.FLAG_IS_PASSWORD
})
/* package */ @interface SelectionActionDelegateFlag {} /* package */ @interface SelectionActionDelegateFlag {}
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@ -3535,7 +3539,7 @@ public class GeckoSession {
protected LoadRequest() { protected LoadRequest() {
uri = ""; uri = "";
triggerUri = null; triggerUri = null;
target = 0; target = TARGET_WINDOW_NONE;
isRedirect = false; isRedirect = false;
hasUserGesture = false; hasUserGesture = false;
isDirectNavigation = false; isDirectNavigation = false;
@ -4059,7 +4063,7 @@ public class GeckoSession {
protected AuthOptions() { protected AuthOptions() {
flags = 0; flags = 0;
uri = ""; uri = "";
level = 0; level = Level.NONE;
username = ""; username = "";
password = ""; password = "";
} }
@ -5534,8 +5538,8 @@ public class GeckoSession {
id = null; id = null;
rawId = null; rawId = null;
name = null; name = null;
source = 0; source = SOURCE_CAMERA;
type = 0; type = TYPE_VIDEO;
} }
} }

View file

@ -8,9 +8,6 @@ package org.mozilla.geckoview;
import android.content.Context; import android.content.Context;
import android.graphics.BlendMode; import android.graphics.BlendMode;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Build; import android.os.Build;
import android.widget.EdgeEffect; import android.widget.EdgeEffect;
@ -75,28 +72,12 @@ public final class OverscrollEdgeEffect {
} }
private void setBlendMode(final EdgeEffect edgeEffect) { private void setBlendMode(final EdgeEffect edgeEffect) {
if (Build.VERSION.SDK_INT >= 29) { if (Build.VERSION.SDK_INT < 29) {
edgeEffect.setBlendMode(BlendMode.SRC); // setBlendMode is only supported on SDK_INT >= 29 and above.
return; return;
} }
if (sPaintField == null) { edgeEffect.setBlendMode(BlendMode.SRC);
try {
sPaintField = EdgeEffect.class.getDeclaredField("mPaint");
sPaintField.setAccessible(true);
} catch (final NoSuchFieldException e) {
// Cannot get the field, nothing we can do here
return;
}
}
try {
final Paint paint = (Paint) sPaintField.get(edgeEffect);
final PorterDuffXfermode mode = new PorterDuffXfermode(PorterDuff.Mode.SRC);
paint.setXfermode(mode);
} catch (final IllegalAccessException ex) {
// Nothing we can do
}
} }
/** /**

View file

@ -4,6 +4,7 @@
package org.mozilla.geckoview; package org.mozilla.geckoview;
import android.annotation.SuppressLint;
import android.graphics.Color; import android.graphics.Color;
import android.util.Log; import android.util.Log;
import androidx.annotation.AnyThread; import androidx.annotation.AnyThread;
@ -1398,6 +1399,9 @@ public class WebExtension {
return; return;
} }
// The .accept method will be called from the UIThread in this case because
// the GeckoResult instance was created on the UIThread
@SuppressLint("WrongThread")
final GeckoResult<GeckoSession> popup = delegate.onTogglePopup(mExtension, this); final GeckoResult<GeckoSession> popup = delegate.onTogglePopup(mExtension, this);
openPopup(popup, uri); openPopup(popup, uri);
}); });
@ -2515,7 +2519,6 @@ public class WebExtension {
} }
@NonNull @NonNull
@UiThread
/* package */ static GeckoBundle downloadInfoToBundle(final @NonNull Info data) { /* package */ static GeckoBundle downloadInfoToBundle(final @NonNull Info data) {
final GeckoBundle dataBundle = new GeckoBundle(); final GeckoBundle dataBundle = new GeckoBundle();

View file

@ -4,6 +4,7 @@
package org.mozilla.geckoview; package org.mozilla.geckoview;
import android.annotation.SuppressLint;
import android.os.Build; import android.os.Build;
import android.util.Log; import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
@ -870,6 +871,7 @@ public class WebExtensionController {
})); }));
} }
@SuppressLint("WrongThread") // for .toGeckoBundle
private void getSettings(final Message message, final WebExtension extension) { private void getSettings(final Message message, final WebExtension extension) {
final WebExtension.BrowsingDataDelegate delegate = mListener.getBrowsingDataDelegate(extension); final WebExtension.BrowsingDataDelegate delegate = mListener.getBrowsingDataDelegate(extension);
if (delegate == null) { if (delegate == null) {

View file

@ -21,8 +21,8 @@ android {
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_11
} }
dexOptions { dexOptions {

View file

@ -544,21 +544,10 @@ set_config(
) )
@dependable
def gradle_android_dependencies():
"""Gradle tasks that download all dependencies."""
# These tasks download most dependencies from each configuration, the
# notable exception is dependencies added at runtime by gradle plugins
return [
"downloadDependencies",
]
@depends( @depends(
gradle_android_api_lint_tasks, gradle_android_api_lint_tasks,
gradle_android_format_lint_check_tasks, gradle_android_format_lint_check_tasks,
gradle_android_checkstyle_tasks, gradle_android_checkstyle_tasks,
gradle_android_dependencies,
) )
@imports(_from="itertools", _import="chain") @imports(_from="itertools", _import="chain")
def gradle_android_dependencies_tasks(*tasks): def gradle_android_dependencies_tasks(*tasks):
@ -600,6 +589,17 @@ option(
help="Comma-separated URLs of Maven repositories containing Gradle dependencies.", help="Comma-separated URLs of Maven repositories containing Gradle dependencies.",
) )
option(
"--allow-insecure-gradle-repositories",
help="Gradle is allowed to connect to insecure Maven repositories.",
)
set_config(
"ALLOW_INSECURE_GRADLE_REPOSITORIES",
True,
when="--allow-insecure-gradle-repositories",
)
@depends("GRADLE_MAVEN_REPOSITORIES") @depends("GRADLE_MAVEN_REPOSITORIES")
@imports(_from="os.path", _import="isdir") @imports(_from="os.path", _import="isdir")

View file

@ -192,19 +192,22 @@ ext.configureVariantWithGeckoBinaries = { variant ->
def omnijarDir = "${topobjdir}/dist/geckoview" def omnijarDir = "${topobjdir}/dist/geckoview"
def distDir = "${topobjdir}/dist/geckoview" def distDir = "${topobjdir}/dist/geckoview"
def syncOmnijarFromDistDir = task("syncOmnijarFromDistDirFor${variant.name.capitalize()}", type: Sync) { def syncOmnijarFromDistDir
onlyIf { if (mozconfig.substs.COMPILE_ENVIRONMENT) {
if (source.empty) { syncOmnijarFromDistDir = task("syncOmnijarFromDistDirFor${variant.name.capitalize()}", type: Sync) {
throw new StopExecutionException("Required omnijar not found in ${omnijarDir}/{omni.ja,assets/omni.ja}. Have you built and packaged?") onlyIf {
if (source.empty) {
throw new StopExecutionException("Required omnijar not found in ${omnijarDir}/{omni.ja,assets/omni.ja}. Have you built and packaged?")
}
return true
} }
return true
}
into("${project.buildDir}/moz.build/src/${variant.name}/omnijar") into("${project.buildDir}/moz.build/src/${variant.name}/omnijar")
from("${omnijarDir}/omni.ja", from("${omnijarDir}/omni.ja",
"${omnijarDir}/assets/omni.ja") { "${omnijarDir}/assets/omni.ja") {
// Throw an exception if we find multiple, potentially conflicting omni.ja files. // Throw an exception if we find multiple, potentially conflicting omni.ja files.
duplicatesStrategy 'fail' duplicatesStrategy 'fail'
}
} }
} }
@ -264,31 +267,33 @@ ext.configureVariantWithGeckoBinaries = { variant ->
} }
} }
// Local (read, not 'official') builds want to reflect developer changes to if (mozconfig.substs.COMPILE_ENVIRONMENT) {
// the omnijar sources, and (when compiling) to reflect developer changes to // Local (read, not 'official') builds want to reflect developer changes to
// the native binaries. To do this, the Gradle build calls out to the // the omnijar sources, and (when compiling) to reflect developer changes to
// moz.build system, which can be re-entrant. Official builds are driven by // the native binaries. To do this, the Gradle build calls out to the
// the moz.build system and should never be re-entrant in this way. // moz.build system, which can be re-entrant. Official builds are driven by
if (!mozconfig.substs.MOZILLA_OFFICIAL) { // the moz.build system and should never be re-entrant in this way.
syncOmnijarFromDistDir.dependsOn rootProject.machStagePackage if (!mozconfig.substs.MOZILLA_OFFICIAL) {
syncLibsFromDistDir.dependsOn rootProject.machStagePackage syncOmnijarFromDistDir.dependsOn rootProject.machStagePackage
syncAssetsFromDistDir.dependsOn rootProject.machStagePackage syncLibsFromDistDir.dependsOn rootProject.machStagePackage
} syncAssetsFromDistDir.dependsOn rootProject.machStagePackage
}
def assetGenTask = tasks.findByName("generate${variant.name.capitalize()}Assets") def assetGenTask = tasks.findByName("generate${variant.name.capitalize()}Assets")
def jniLibFoldersTask = tasks.findByName("merge${variant.name.capitalize()}JniLibFolders") def jniLibFoldersTask = tasks.findByName("merge${variant.name.capitalize()}JniLibFolders")
if ((variant.productFlavors*.name).contains('withGeckoBinaries')) { if ((variant.productFlavors*.name).contains('withGeckoBinaries')) {
assetGenTask.dependsOn syncOmnijarFromDistDir assetGenTask.dependsOn syncOmnijarFromDistDir
assetGenTask.dependsOn syncAssetsFromDistDir assetGenTask.dependsOn syncAssetsFromDistDir
jniLibFoldersTask.dependsOn syncLibsFromDistDir jniLibFoldersTask.dependsOn syncLibsFromDistDir
android.sourceSets."${variant.name}".assets.srcDir syncOmnijarFromDistDir.destinationDir android.sourceSets."${variant.name}".assets.srcDir syncOmnijarFromDistDir.destinationDir
android.sourceSets."${variant.name}".assets.srcDir syncAssetsFromDistDir.destinationDir android.sourceSets."${variant.name}".assets.srcDir syncAssetsFromDistDir.destinationDir
if (!mozconfig.substs.MOZ_ANDROID_FAT_AAR_ARCHITECTURES) { if (!mozconfig.substs.MOZ_ANDROID_FAT_AAR_ARCHITECTURES) {
android.sourceSets."${variant.name}".jniLibs.srcDir syncLibsFromDistDir.destinationDir android.sourceSets."${variant.name}".jniLibs.srcDir syncLibsFromDistDir.destinationDir
} else { } else {
android.sourceSets."${variant.name}".jniLibs.srcDir "${topobjdir}/dist/fat-aar/output/jni" android.sourceSets."${variant.name}".jniLibs.srcDir "${topobjdir}/dist/fat-aar/output/jni"
}
} }
} }
} }
@ -314,11 +319,9 @@ ext.configureLibraryVariantWithJNIWrappers = { variant, module ->
// configuration-time: see above comment. // configuration-time: see above comment.
doFirst { doFirst {
classpath variant.javaCompileProvider.get().classpath classpath variant.javaCompileProvider.get().classpath
// Include android.jar.
classpath variant.javaCompileProvider.get().options.bootstrapClasspath
} }
main = 'org.mozilla.gecko.annotationProcessors.AnnotationProcessor' mainClass = 'org.mozilla.gecko.annotationProcessors.AnnotationProcessor'
args module args module
args bundleJar args bundleJar

View file

@ -21,8 +21,8 @@ android {
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_11
} }
dexOptions { dexOptions {

View file

@ -47,9 +47,9 @@ AVD_MANIFEST_ARM64 = os.path.abspath(
os.path.join(os.path.dirname(__file__), "android-avds/arm64.json") os.path.join(os.path.dirname(__file__), "android-avds/arm64.json")
) )
JAVA_VERSION_MAJOR = "8" JAVA_VERSION_MAJOR = "17"
JAVA_VERSION_MINOR = "u312" JAVA_VERSION_MINOR = "0.1"
JAVA_VERSION_PATCH = "b07" JAVA_VERSION_PATCH = "12"
ANDROID_NDK_EXISTS = """ ANDROID_NDK_EXISTS = """
Looks like you have the correct version of the Android NDK installed at: Looks like you have the correct version of the Android NDK installed at:
@ -840,8 +840,12 @@ def ensure_java(os_name, os_arch):
else: else:
os_tag = os_name os_tag = os_name
# One we migrate to Java 17 we will be able to use native arm64 binaries if os_arch == "x86_64":
arch = "x64" arch = "x64"
elif os_arch == "arm64":
arch = "aarch64"
else:
arch = os_arch
ext = "zip" if os_name == "windows" else "tar.gz" ext = "zip" if os_name == "windows" else "tar.gz"
@ -850,12 +854,12 @@ def ensure_java(os_name, os_arch):
raise NotImplementedError(f"Could not bootstrap java for {os_name}.") raise NotImplementedError(f"Could not bootstrap java for {os_name}.")
if not os.path.exists(java_path): if not os.path.exists(java_path):
# e.g. https://github.com/adoptium/temurin8-binaries/releases/ # e.g. https://github.com/adoptium/temurin17-binaries/releases/
# download/jdk8u312-b07/OpenJDK8U-jdk_x64_linux_hotspot_8u312b07.tar.gz # download/jdk-17.0.1%2B12/OpenJDK17U-jdk_x64_linux_hotspot_17.0.1_12.tar.gz
java_url = ( java_url = (
"https://github.com/adoptium/temurin{major}-binaries/releases/" "https://github.com/adoptium/temurin{major}-binaries/releases/"
"download/jdk{major}{minor}-{patch}/" "download/jdk-{major}.{minor}%2B{patch}/"
"OpenJDK{major}U-jdk_{arch}_{os}_hotspot_{major}{minor}{patch}.{ext}" "OpenJDK{major}U-jdk_{arch}_{os}_hotspot_{major}.{minor}_{patch}.{ext}"
).format( ).format(
major=JAVA_VERSION_MAJOR, major=JAVA_VERSION_MAJOR,
minor=JAVA_VERSION_MINOR, minor=JAVA_VERSION_MINOR,
@ -869,7 +873,8 @@ def ensure_java(os_name, os_arch):
def java_bin_path(os_name, toolchain_path): def java_bin_path(os_name, toolchain_path):
jdk_folder = "jdk{major}{minor}-{patch}".format( # Like jdk-17.0.1+12
jdk_folder = "jdk-{major}.{minor}+{patch}".format(
major=JAVA_VERSION_MAJOR, minor=JAVA_VERSION_MINOR, patch=JAVA_VERSION_PATCH major=JAVA_VERSION_MAJOR, minor=JAVA_VERSION_MINOR, patch=JAVA_VERSION_PATCH
) )

View file

@ -596,7 +596,7 @@ class TestChecksConfigure(unittest.TestCase):
javac = mozpath.abspath("/usr/bin/javac") javac = mozpath.abspath("/usr/bin/javac")
paths = {java: None, javac: None} paths = {java: None, javac: None}
expected_error_message = ( expected_error_message = (
"ERROR: Could not locate Java at /mozbuild/jdk/jdk8u312-b07/bin, " "ERROR: Could not locate Java at /mozbuild/jdk/jdk-17.0.1+12/bin, "
"please run ./mach bootstrap --no-system-changes\n" "please run ./mach bootstrap --no-system-changes\n"
) )

View file

@ -461,6 +461,17 @@ sonatype-nexus:
strip-components: 1 strip-components: 1
add-prefix: sonatype-nexus/ add-prefix: sonatype-nexus/
jdk-8-linux64:
description: Java 8 JDK
fetch:
type: static-url
url: https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u312-b07/OpenJDK8U-jdk_x64_linux_hotspot_8u312b07.tar.gz
sha256: 699981083983b60a7eeb511ad640fae3ae4b879de5a3980fe837e8ade9c34a08
size: 103016010
artifact-name: jdk-8.tar.zst
strip-components: 1
add-prefix: jdk-8/
makecab: makecab:
description: makecab source code description: makecab source code
fetch: fetch:

View file

@ -114,7 +114,7 @@ linux64-jdk-repack:
toolchain-artifact: project/gecko/jdk/jdk-linux.tar.zst toolchain-artifact: project/gecko/jdk/jdk-linux.tar.zst
toolchain-alias: linux64-jdk toolchain-alias: linux64-jdk
toolchain-env: toolchain-env:
JAVA_HOME: "/builds/worker/fetches/jdk/jdk8u312-b07" JAVA_HOME: "/builds/worker/fetches/jdk/jdk-17.0.1+12"
linux64-android-sdk-linux-repack: linux64-android-sdk-linux-repack:
description: "Android SDK (Linux) repack toolchain build" description: "Android SDK (Linux) repack toolchain build"
@ -194,6 +194,8 @@ linux64-android-gradle-dependencies:
fetches: fetches:
fetch: fetch:
- sonatype-nexus - sonatype-nexus
# Nexus needs Java 8
- jdk-8-linux64
toolchain: toolchain:
# Aliases aren't allowed for toolchains depending on toolchains. # Aliases aren't allowed for toolchains depending on toolchains.
- linux64-android-sdk-linux-repack - linux64-android-sdk-linux-repack
@ -222,6 +224,8 @@ linux64-android-gradle-dependencies-lite:
fetches: fetches:
fetch: fetch:
- sonatype-nexus - sonatype-nexus
# Nexus needs Java 8
- jdk-8-linux64
toolchain: toolchain:
# Aliases aren't allowed for toolchains depending on toolchains. # Aliases aren't allowed for toolchains depending on toolchains.
- linux64-android-sdk-linux-repack - linux64-android-sdk-linux-repack

View file

@ -9,12 +9,13 @@ set -v
cd $GECKO_PATH cd $GECKO_PATH
# Needed for Nexus # Needed for Nexus
export PATH=$JAVA_HOME/bin:$PATH export PATH=$MOZ_FETCHES_DIR/jdk-8/bin:$PATH
. taskcluster/scripts/misc/android-gradle-dependencies/before.sh . taskcluster/scripts/misc/android-gradle-dependencies/before.sh
export MOZCONFIG=mobile/android/config/mozconfigs/android-arm-gradle-dependencies/nightly-lite export MOZCONFIG=mobile/android/config/mozconfigs/android-arm-gradle-dependencies/nightly-lite
./mach build ./mach build
./mach gradle downloadDependencies
./mach android gradle-dependencies ./mach android gradle-dependencies
. taskcluster/scripts/misc/android-gradle-dependencies/after.sh . taskcluster/scripts/misc/android-gradle-dependencies/after.sh

View file

@ -8,13 +8,14 @@ set -v
cd $GECKO_PATH cd $GECKO_PATH
# Needed for Nexus # Nexus needs Java 8
export PATH=$JAVA_HOME/bin:$PATH export PATH=$MOZ_FETCHES_DIR/jdk-8/bin:$PATH
. taskcluster/scripts/misc/android-gradle-dependencies/before.sh . taskcluster/scripts/misc/android-gradle-dependencies/before.sh
export MOZCONFIG=mobile/android/config/mozconfigs/android-arm-gradle-dependencies/nightly export MOZCONFIG=mobile/android/config/mozconfigs/android-arm-gradle-dependencies/nightly
./mach build ./mach build
./mach gradle downloadDependencies
./mach android gradle-dependencies ./mach android gradle-dependencies
. taskcluster/scripts/misc/android-gradle-dependencies/after.sh . taskcluster/scripts/misc/android-gradle-dependencies/after.sh

View file

@ -194,7 +194,10 @@ def javadoc(config, **lintargs):
for issue in issues: for issue in issues:
issue["path"] = issue["path"].replace(lintargs["root"], "") issue["path"] = issue["path"].replace(lintargs["root"], "")
# We want warnings to be errors for linting purposes. # We want warnings to be errors for linting purposes.
issue["level"] = "error" # TODO: Bug 1316188 - resolve missing javadoc comments
issue["level"] = (
"error" if issue["message"] != ": no comment" else "warning"
)
results.append(result.from_config(config, **issue)) results.append(result.from_config(config, **issue))
return results return results
@ -229,6 +232,10 @@ def lint(config, **lintargs):
for issue in root.findall("issue"): for issue in root.findall("issue"):
location = issue[0] location = issue[0]
if "third_party" in location.get("file") or "thirdparty" in location.get(
"file"
):
continue
err = { err = {
"level": issue.get("severity").lower(), "level": issue.get("severity").lower(),
"rule": issue.get("id"), "rule": issue.get("id"),