Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Android Gradle Plugin 8.2.2 to 8.3.1 #127

Merged
merged 13 commits into from
Mar 18, 2024
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ksp = { id = "com.google.devtools.ksp", version.ref = "kotlin-ksp" }
project = "1.0"

java = "1.8"
agp = "8.2.2"
agp = "8.3.1"
# https://github.com/TWiStErRob/net.twisterrob.gradle/releases
twisterrob = "0.16"
detekt = "1.23.5"
Expand Down
Binary file modified gradle/plugins/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/plugins/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 deletions gradle/plugins/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.twisterrob.libraries.build

import com.android.build.api.dsl.AndroidSourceSet
import com.android.build.gradle.internal.lint.AndroidLintAnalysisTask
import com.android.build.gradle.internal.lint.LintModelWriterTask
import net.twisterrob.libraries.build.dsl.android
import net.twisterrob.libraries.build.dsl.autoNamespace

Expand Down Expand Up @@ -39,7 +41,13 @@ android {
" as it has no sources in ${this@androidTest.srcDirs}"
)
tasks.configureEach {
@Suppress("detekt.MaxLineLength")
if (this.name.contains("AndroidTest")) {
// Prevent:
// > Task :basics:lintReportDebug FAILED
// Lint model ...\build\intermediates\android_test_lint_model\debug\generateDebugAndroidTestLintModel does not exist.
if (this is LintModelWriterTask) return@configureEach
if (this is AndroidLintAnalysisTask) return@configureEach
this.enabled = false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import org.gradle.kotlin.dsl.get
* @see com.android.build.api.dsl.ApplicationExtension
* @see com.android.build.api.dsl.LibraryExtension
*/
internal val Project.android: CommonExtension<*, *, *, *, *>
internal val Project.android: CommonExtension<*, *, *, *, *, *>
@Suppress("UNCHECKED_CAST")
get() = this.extensions["android"] as CommonExtension<*, *, *, *, *>
get() = this.extensions["android"] as CommonExtension<*, *, *, *, *, *>

/**
* This is useful to emulate the `android` block in a convention plugin
Expand All @@ -23,6 +23,6 @@ internal val Project.android: CommonExtension<*, *, *, *, *>
* @param block the configuration for common Android things.
* Using an [Action] to take advantage of `kotlin-dsl`.
*/
internal fun Project.android(block: Action<CommonExtension<*, *, *, *, *>>) {
internal fun Project.android(block: Action<CommonExtension<*, *, *, *, *, *>>) {
block.execute(android)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ project.findProject("${project.path}-test_helpers")?.let { testHelpers ->
androidTestImplementation(testHelpers)
}
}

afterEvaluate {
configurations.named("${android.testBuildType}AndroidTestRuntimeClasspath") {
// TODEL https://issuetracker.google.com/issues/330202422
resolutionStrategy.force("com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava")
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
17 changes: 9 additions & 8 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -144,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -201,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
91 changes: 17 additions & 74 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ fun Settings.includeJava(modulePath: String) {
val module = project(modulePath)
module.projectDir = file("twister-lib-java").resolve(module.projectDir.relativeTo(rootDir))
}

fun Settings.includeAndroid(modulePath: String) {
include(modulePath)
val module = project(modulePath)
module.projectDir = file("twister-lib-android").resolve(module.projectDir.relativeTo(rootDir))
}

fun Settings.includeAndroidWithTestHelpers(modulePath: String) {
includeAndroid(modulePath)
val testHelpersModulePath = "${modulePath}-test_helpers"
Expand All @@ -92,36 +94,10 @@ fun Settings.includeAndroidWithTestHelpers(modulePath: String) {

val gradleVersion: String = GradleVersion.current().version

// TODEL Gradle sync in AS EE 2022.1.1 / AS GI 2022.3.1, maybe fixed in AS H.
// https://youtrack.jetbrains.com/issue/IDEA-306975
@Suppress("MaxLineLength")
doNotNagAbout(
"The AbstractArchiveTask.archivePath property has been deprecated. " +
"This is scheduled to be removed in Gradle 9.0. " +
"Please use the archiveFile property instead. " +
"For more information, please refer to " +
"https://docs.gradle.org/${gradleVersion}/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:archivePath" +
" in the Gradle documentation.",
"at org.jetbrains.plugins.gradle.tooling.builder.ExternalProjectBuilderImpl\$_getSourceSets_closure"
)

// TODEL Gradle sync in AS EE 2022.1.1 / AS GI 2022.3.1, maybe fixed in AS H.
// https://youtrack.jetbrains.com/issue/IDEA-306975
@Suppress("MaxLineLength")
doNotNagAbout(
"The AbstractArchiveTask.archivePath property has been deprecated. " +
"This is scheduled to be removed in Gradle 9.0. " +
"Please use the archiveFile property instead. " +
"For more information, please refer to " +
"https://docs.gradle.org/${gradleVersion}/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:archivePath" +
" in the Gradle documentation.",
"at org.jetbrains.plugins.gradle.tooling.util.SourceSetCachedFinder.createArtifactsMap"
)

// TODEL Gradle 8.2 sync in AS FL 2022.2.1 / AS GI 2022.3.1 / IDEA 2023.1, fixed in 2023.2.
// TODEL Gradle 8.2 sync in AS FL 2022.2.1 / AS GI 2022.3.1 / IDEA 2023.1 / AS HH 2023.2.1, last piece fixed in 2023.3.
// https://youtrack.jetbrains.com/issue/IDEA-320266
@Suppress("MaxLineLength")
if ((System.getProperty("idea.version") ?: "") < "2023.2") {
if ((System.getProperty("idea.version") ?: "") < "2023.3") {
doNotNagAbout(
"The org.gradle.api.plugins.JavaPluginConvention type has been deprecated. " +
"This is scheduled to be removed in Gradle 9.0. " +
Expand All @@ -143,57 +119,24 @@ if ((System.getProperty("idea.version") ?: "") < "2023.2") {
"https://docs.gradle.org/${gradleVersion}/userguide/upgrading_version_8.html#deprecated_access_to_conventions",
"at org.jetbrains.kotlin.idea.gradleTooling.KotlinTasksPropertyUtilsKt.getPureKotlinSourceRoots(KotlinTasksPropertyUtils.kt:59)"
)
} else {
val error: (String) -> Unit = if (isCI) ::error else logger::warn
error("Android Studio version changed, please review convention hack.")
}

// TODEL Gradle 8.2 sync in AS FL https://youtrack.jetbrains.com/issue/IDEA-320307
@Suppress("MaxLineLength", "StringLiteralDuplication")
if ((System.getProperty("idea.version") ?: "") < "2024.1") {
doNotNagAbout(
"The Project.getConvention() method has been deprecated. " +
"This is scheduled to be removed in Gradle 9.0. " +
"Consult the upgrading guide for further information: " +
"https://docs.gradle.org/${gradleVersion}/userguide/upgrading_version_8.html#deprecated_access_to_conventions",
"at org.jetbrains.plugins.gradle.tooling.builder.ProjectExtensionsDataBuilderImpl.buildAll(ProjectExtensionsDataBuilderImpl.groovy:4"
)
doNotNagAbout(
"The org.gradle.api.plugins.Convention type has been deprecated. " +
"This is scheduled to be removed in Gradle 9.0. " +
"Consult the upgrading guide for further information: " +
"https://docs.gradle.org/${gradleVersion}/userguide/upgrading_version_8.html#deprecated_access_to_conventions",
"at org.jetbrains.plugins.gradle.tooling.builder.ProjectExtensionsDataBuilderImpl.buildAll(ProjectExtensionsDataBuilderImpl.groovy:4"
)
doNotNagAbout(
"The org.gradle.api.plugins.JavaPluginConvention type has been deprecated. " +
"The BuildIdentifier.getName() method has been deprecated. " +
"This is scheduled to be removed in Gradle 9.0. " +
"Use getBuildPath() to get a unique identifier for the build. " +
"Consult the upgrading guide for further information: " +
"https://docs.gradle.org/${gradleVersion}/userguide/upgrading_version_8.html#java_convention_deprecation",
// at org.jetbrains.plugins.gradle.tooling.builder.ExternalProjectBuilderImpl.doBuild(ExternalProjectBuilderImpl.groovy:108)
// at org.jetbrains.plugins.gradle.tooling.builder.ExternalProjectBuilderImpl.doBuild(ExternalProjectBuilderImpl.groovy:117)
// at org.jetbrains.plugins.gradle.tooling.builder.ExternalProjectBuilderImpl.doBuild(ExternalProjectBuilderImpl.groovy:118)
"at org.jetbrains.plugins.gradle.tooling.builder.ExternalProjectBuilderImpl.doBuild(ExternalProjectBuilderImpl.groovy:1"
)
// No method and line number in stack to match all these:
// * JavaPluginUtil.getJavaPluginConvention(JavaPluginUtil.java:13)
// * JavaPluginUtil.getSourceSetContainer(JavaPluginUtil.java:18)
// * JavaPluginUtil.getSourceSetContainer(JavaPluginUtil.java:19)
doNotNagAbout(
"The org.gradle.api.plugins.JavaPluginConvention type has been deprecated. " +
"This is scheduled to be removed in Gradle 9.0. " +
"Consult the upgrading guide for further information: " +
"https://docs.gradle.org/${gradleVersion}/userguide/upgrading_version_8.html#java_convention_deprecation",
"at org.jetbrains.plugins.gradle.tooling.util.JavaPluginUtil."
)
doNotNagAbout(
"The Project.getConvention() method has been deprecated. " +
"This is scheduled to be removed in Gradle 9.0. " +
"Consult the upgrading guide for further information: " +
"https://docs.gradle.org/${gradleVersion}/userguide/upgrading_version_8.html#deprecated_access_to_conventions",
"at org.jetbrains.plugins.gradle.tooling.util.JavaPluginUtil."
)
doNotNagAbout(
"The org.gradle.api.plugins.Convention type has been deprecated. " +
"This is scheduled to be removed in Gradle 9.0. " +
"Consult the upgrading guide for further information: " +
"https://docs.gradle.org/${gradleVersion}/userguide/upgrading_version_8.html#deprecated_access_to_conventions",
"at org.jetbrains.plugins.gradle.tooling.util.JavaPluginUtil."
"https://docs.gradle.org/${gradleVersion}/userguide/upgrading_version_8.html#build_identifier_name_and_current_deprecation",
// There are multiple stack traces coming to this line, ignore them all at once.
"at org.jetbrains.plugins.gradle.tooling.util.resolve.DependencyResolverImpl.resolveDependencies(DependencyResolverImpl.java:266)"
)
} else {
val error: (String) -> Unit = if (isCI) ::error else logger::warn
error("Android Studio version changed, please review hack.")
error("Android Studio version changed, please review BuildIdentifier hack.")
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
>

<uses-permission android:name="android.permission.CAMERA" />
Expand All @@ -15,7 +16,11 @@
android:name="net.twisterrob.android.activity.CaptureImage"
android:exported="false"
android:screenOrientation="fullUser"
/>
tools:ignore="DiscouragedApi"
>
<!-- lint:DiscouragedApi REPORT false positive, fullUser does not lock fixed orientation. -->
<!-- lint:DiscouragedApi Camera activity requires full rotation control for better experience. -->
</activity>

<provider
android:name="net.twisterrob.android.content.CaptureImageFileProvider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.hamcrest.junit.MatcherAssume.assumeThat;
import static org.junit.Assert.assertThrows;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
Expand Down Expand Up @@ -146,6 +147,7 @@ private void verifyOversleepProtection(ThrowingRunnable actionThatTendsToOversle
assertThat(activity.itemClicked, is(true));
}

@SuppressLint("UseSdkSuppress") // REPORT test class has SdkSuppress, this is just extra safety.
@TargetApi(VERSION_CODES.HONEYCOMB)
@RequiresApi(VERSION_CODES.HONEYCOMB)
public static class TestActivity extends Activity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@
* @see AndroidJUnit4WithParametersRunnerFactory
*/
public class AndroidJUnit4WithParameters extends BlockJUnit4ClassRunnerWithParameters {
@SuppressLint("RestrictedApi") // Need to access internal API, because there's no public one.
private final AndroidRunnerParams mAndroidRunnerParams;

public AndroidJUnit4WithParameters(TestWithParameters test, AndroidRunnerParams runnerParams)
throws InitializationError {
public AndroidJUnit4WithParameters(
TestWithParameters test,
@SuppressLint("RestrictedApi") // Need to access internal API, because there's no public one.
AndroidRunnerParams runnerParams
) throws InitializationError {
super(test);
mAndroidRunnerParams = runnerParams;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ public class AndroidJUnit4WithParametersRunnerFactory implements ParametersRunne
public Runner createRunnerForTestWithParameters(TestWithParameters test)
throws InitializationError {
Instrumentation instr = InstrumentationRegistry.getInstrumentation();
@SuppressLint("RestrictedApi") // Need to access internal API, because there's no public one.
RunnerArgs runnerArgs = ReflectionTools.get(instr, "mRunnerArgs");

@SuppressLint("RestrictedApi")
@SuppressLint("RestrictedApi") // Need to access internal API, because there's no public one.
@SuppressWarnings("deprecation") // will probably revisit soon
AndroidRunnerParams runnerParams = new AndroidRunnerParams(
instr,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:SuppressLint("VisibleForTests") // REPORT cannot suppress on @receiver:

package com.bumptech.glide.load.engine

import android.annotation.SuppressLint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:SuppressLint("VisibleForTests") // REPORT cannot suppress on @receiver:

package com.bumptech.glide.load.engine

import android.annotation.SuppressLint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:SuppressLint("VisibleForTests") // REPORT cannot suppress on @receiver:

package com.bumptech.glide.load.engine

import android.annotation.SuppressLint
Expand Down
Loading
Loading