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

Upgrade Gradle 6.7 to 7.6 #218

Merged
merged 17 commits into from
Mar 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 44 additions & 7 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,41 @@ jobs:
# EnricoMi/publish-unit-test-result-action -> https://github.com/EnricoMi/publish-unit-test-result-action#permissions
checks: write
steps:
- name: "Set up JDK 8."
- name: "Set up JDK 11."
uses: actions/setup-java@v3
with:
java-version: 8
java-version: 11
distribution: zulu

- name: "Patch Android SDK components for compatibility."
run: |
# AGP's com.android.SdkConstants.CURRENT_BUILD_TOOLS_VERSION
# https://github.com/TWiStErRob/net.twisterrob.gradle/blob/v0.15/plugin/base/src/main/kotlin/net/twisterrob/gradle/android/Versions.kt#L28
echo android --install "build-tools;32.0.0"
${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "build-tools;32.0.0"
# Patch AGP 4.x v SDK Build Tools 31/32 incompatibility: https://stackoverflow.com/a/68430992/253468
# Installed Build Tools revision 32.0.0 is corrupted. Remove and install again using the SDK Manager.
# Build-tool 32.0.0 is missing DX at /usr/local/lib/android/sdk/build-tools/32.0.0/dx
echo "Symlinking ${ANDROID_HOME}/build-tools/32.0.0/dx <- d8 and same for lib/dx.jar <- d8.jar."
test -e ${ANDROID_HOME}/build-tools/32.0.0/dx \
|| ln --symbolic --verbose d8 ${ANDROID_HOME}/build-tools/32.0.0/dx
test -e ${ANDROID_HOME}/build-tools/32.0.0/lib/dx.jar \
|| ln --symbolic --verbose d8.jar ${ANDROID_HOME}/build-tools/32.0.0/lib/dx.jar

- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v3
with:
submodules: true

- name: "Patch libraries to build ProGuard compatible Java bytecode."
run: |
cat >> libs/gradle/plugins/src/main/kotlin/net/twisterrob/libraries/net.twisterrob.libraries.java.library.gradle.kts <<EOF
java {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_8
}
EOF

- name: "Build project."
working-directory: .
run: >
Expand Down Expand Up @@ -135,12 +159,27 @@ jobs:
# A stable version for now.
- 21
steps:
- name: "Set up JDK 8."
- name: "Set up JDK 11."
uses: actions/setup-java@v3
with:
java-version: 8
java-version: 11
distribution: zulu

- name: "Patch Android SDK components for compatibility."
run: |
# AGP's com.android.SdkConstants.CURRENT_BUILD_TOOLS_VERSION
# https://github.com/TWiStErRob/net.twisterrob.gradle/blob/v0.15/plugin/base/src/main/kotlin/net/twisterrob/gradle/android/Versions.kt#L28
echo android --install "build-tools;32.0.0"
${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "build-tools;32.0.0"
# Patch AGP 4.x v SDK Build Tools 31/32 incompatibility: https://stackoverflow.com/a/68430992/253468
# Installed Build Tools revision 32.0.0 is corrupted. Remove and install again using the SDK Manager.
# Build-tool 32.0.0 is missing DX at /usr/local/lib/android/sdk/build-tools/32.0.0/dx
echo "Symlinking ${ANDROID_HOME}/build-tools/32.0.0/dx <- d8 and same for lib/dx.jar <- d8.jar."
test -e ${ANDROID_HOME}/build-tools/32.0.0/dx \
|| ln -s -v d8 ${ANDROID_HOME}/build-tools/32.0.0/dx
test -e ${ANDROID_HOME}/build-tools/32.0.0/lib/dx.jar \
|| ln -s -v d8.jar ${ANDROID_HOME}/build-tools/32.0.0/lib/dx.jar

- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v3
with:
Expand All @@ -156,9 +195,7 @@ jobs:
profile: pixel
script: |
adb devices -l
./gradlew --no-daemon --stacktrace :android:assembleDebugAndroidTest
./gradlew --no-daemon --stacktrace :android:assembleDebug
./gradlew --no-daemon --stacktrace :android:connectedCheck -x assembleDebug -x assembleRelease -x assemble -x assembleAndroidTest
./gradlew --no-daemon --stacktrace :android:connectedCheck

- name: "Upload 'Instrumentation Test Results ${{ matrix.android-api }}' artifact."
if: success() || failure()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;

import com.github.stefanbirkner.fishbowl.Statement;
import com.shazam.gwen.Gwen;

import static com.github.stefanbirkner.fishbowl.Fishbowl.*;
Expand Down Expand Up @@ -50,7 +51,11 @@ public class BackupTransactingImporterTest {
Throwable failure = new TestRuntimeException("test cannot commit");
doThrow(failure).when(db).endTransaction();

Throwable thrown = exceptionThrownBy(() -> importer.importFrom(INPUT));
Throwable thrown = exceptionThrownBy(new Statement() {
@Override public void evaluate() throws Throwable {
importer.importFrom(INPUT);
}
});

assertSame(failure, thrown);
Gwen.then(database).transacted();
Expand All @@ -62,7 +67,11 @@ public class BackupTransactingImporterTest {
Throwable innerFailure = new TestRuntimeException();
doThrow(innerFailure).when(inner).importFrom(any());

Throwable thrown = exceptionThrownBy(() -> importer.importFrom(INPUT));
Throwable thrown = exceptionThrownBy(new Statement() {
@Override public void evaluate() throws Throwable {
importer.importFrom(INPUT);
}
});

assertSame(innerFailure, thrown);
Gwen.then(database).transacted(false);
Expand All @@ -73,7 +82,11 @@ public class BackupTransactingImporterTest {
Throwable failure = new TestRuntimeException();
doThrow(failure).when(inner).importFrom(any());

Throwable thrown = exceptionThrownBy(() -> importer.importFrom(INPUT));
Throwable thrown = exceptionThrownBy(new Statement() {
@Override public void evaluate() throws Throwable {
importer.importFrom(INPUT);
}
});

assertSame(failure, thrown);
Gwen.then(database).transacted(false);
Expand All @@ -83,7 +96,11 @@ public class BackupTransactingImporterTest {
Throwable failure = new TestCheckedException();
doThrow(failure).when(inner).importFrom(any());

Throwable thrown = exceptionThrownBy(() -> importer.importFrom(INPUT));
Throwable thrown = exceptionThrownBy(new Statement() {
@Override public void evaluate() throws Throwable {
importer.importFrom(INPUT);
}
});

assertSame(failure, thrown);
Gwen.then(database).transacted(false);
Expand All @@ -93,7 +110,11 @@ public class BackupTransactingImporterTest {
Throwable failure = new TestError();
doThrow(failure).when(inner).importFrom(any());

Throwable thrown = exceptionThrownBy(() -> importer.importFrom(INPUT));
Throwable thrown = exceptionThrownBy(new Statement() {
@Override public void evaluate() throws Throwable {
importer.importFrom(INPUT);
}
});

assertSame(failure, thrown);
Gwen.then(database).transacted(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import android.content.res.Resources;

import com.diffplug.common.base.Errors;
import com.diffplug.common.base.Throwing;
import com.github.stefanbirkner.fishbowl.Statement;
import com.shazam.gwen.Gwen;

import static com.github.stefanbirkner.fishbowl.Fishbowl.*;
Expand Down Expand Up @@ -52,7 +54,12 @@ public abstract class BackupZipImporterTestBase {
protected BackupImporter importer;

@Before public void initImporter() {
Consumer<InputStream> callImport = Errors.rethrow().wrap(this::callImport);
Consumer<InputStream> callImport = Errors.rethrow().wrap(
new Throwing.Consumer<InputStream>() {
@Override public void accept(InputStream stream) throws Throwable {
BackupZipImporterTestBase.this.callImport(stream);
}
});
importer = new BackupImporter(dispatcherMock, xmlImporterMock, callImport);
}
@Before public void stubResources() {
Expand All @@ -70,7 +77,11 @@ public abstract class BackupZipImporterTestBase {
@Test public void testEmptyZip() {
Gwen.given(input);

Throwable thrown = exceptionThrownBy(() -> Gwen.when(importer).imports(input));
Throwable thrown = exceptionThrownBy(new Statement() {
@Override public void evaluate() throws Throwable {
Gwen.when(importer).imports(input);
}
});

Matcher<String> aboutMissingXML =
both(containsStringIgnoringCase("missing data")).and(containsString(Paths.BACKUP_DATA_FILENAME));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import android.content.res.Resources;

import com.github.stefanbirkner.fishbowl.Statement;
import com.shazam.gwen.Gwen;

import static com.github.stefanbirkner.fishbowl.Fishbowl.*;
Expand Down Expand Up @@ -146,8 +147,10 @@ public class ImportImageReconcilerTest {
reconciler.importImage(Type.Root, 0, "bad item", IMAGE);
reconciler.hasData();

Throwable thrown = exceptionThrownBy(() -> {
reconciler.foundImageFile(IMAGE, contents(IMAGE), ANY_TIME);
Throwable thrown = exceptionThrownBy(new Statement() {
@Override public void evaluate() throws Throwable {
reconciler.foundImageFile(IMAGE, contents(IMAGE), ANY_TIME);
}
});

assertThat(thrown, hasMessage(containsString(Type.Root.toString())));
Expand All @@ -157,8 +160,10 @@ public class ImportImageReconcilerTest {
@Test public void testDuplicateUnmatchedImageFileBefore() throws IOException {
reconciler.foundImageFile(IMAGE, contents(IMAGE), ANY_TIME);

Throwable thrown = exceptionThrownBy(() -> {
reconciler.foundImageFile(IMAGE, contents(IMAGE), ANY_TIME);
Throwable thrown = exceptionThrownBy(new Statement() {
@Override public void evaluate() throws Throwable {
reconciler.foundImageFile(IMAGE, contents(IMAGE), ANY_TIME);
}
});

assertDuplicate(IMAGE, thrown);
Expand All @@ -177,8 +182,10 @@ public class ImportImageReconcilerTest {
reconciler.foundImageFile(IMAGE, contents(IMAGE), ANY_TIME);
reconciler.hasData();

Throwable thrown = exceptionThrownBy(() -> {
reconciler.foundImageFile(IMAGE, contents(IMAGE), ANY_TIME);
Throwable thrown = exceptionThrownBy(new Statement() {
@Override public void evaluate() throws Throwable {
reconciler.foundImageFile(IMAGE, contents(IMAGE), ANY_TIME);
}
});

assertDuplicate(IMAGE, thrown);
Expand Down Expand Up @@ -208,8 +215,10 @@ public class ImportImageReconcilerTest {
@Test public void testDuplicateReference() throws IOException {
reconciler.importImage(Item, ITEM_ID, ITEM_NAME, IMAGE);

Throwable thrown = exceptionThrownBy(() -> {
reconciler.importImage(Item, OTHER_ITEM_ID, OTHER_ITEM_NAME, IMAGE);
Throwable thrown = exceptionThrownBy(new Statement() {
@Override public void evaluate() throws Throwable {
reconciler.importImage(Item, OTHER_ITEM_ID, OTHER_ITEM_NAME, IMAGE);
}
});

assertDuplicate(IMAGE, thrown);
Expand Down
37 changes: 33 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ apply plugin: 'net.twisterrob.android-app'
apply plugin: "net.twisterrob.inventory.mapping"
apply plugin: "net.twisterrob.inventory.androidTest"

repositories {
maven { // jcenter() deprecated
name = "jcenter"
setUrl("https://jcenter.bintray.com/")
content {
// Can't update flexbox yet to its 3.x version, because it ships with Java 9 bytecode.
includeModule("com.google.android", "flexbox")
}
}
}
dependencies {
implementation project(':android:base')
implementation project(':android:database')
Expand Down Expand Up @@ -90,11 +100,19 @@ android {
}

allprojects { project ->
project.afterEvaluate {
project.android.lintOptions.checkReleaseBuilds false
project.android.lintOptions.baseline rootProject.file("config/lint/lint-baseline-${project.name}.xml")
project.android.lintOptions.lintConfig = rootProject.file("config/lint/lint.xml")
def androidConfig = {
project.android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_8
}
lintOptions.checkReleaseBuilds false
lintOptions.baseline rootProject.file("config/lint/lint-baseline-${project.name}.xml")
lintOptions.lintConfig = rootProject.file("config/lint/lint.xml")
}
}
plugins.withId('com.android.library', androidConfig)
plugins.withId('com.android.application', androidConfig)
}

subprojects { project ->
Expand Down Expand Up @@ -123,3 +141,14 @@ tasks.register("generateHtmlReportFromXml", net.twisterrob.gradle.android.tasks.
output = new File(rootDir, 'temp/tests_results')
outputs.upToDateWhen { false }
}

dependencies.components {
withModule("io.takari.junit:takari-cpsuite") {
withVariant("runtime") { variant ->
def field = org.gradle.api.internal.artifacts.repositories.resolver.VariantMetadataAdapter.class.getDeclaredField("metadata")
field.setAccessible(true)
def metadata = field.get(variant) as org.gradle.internal.component.external.model.maven.DefaultMutableMavenModuleResolveMetadata
metadata.setPackaging("jar")
}
}
}
6 changes: 6 additions & 0 deletions android/data/svg/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ android {
multiDexKeepProguard project(":android").file("src/androidTest/multidex.pro")
}
}
android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_8
}
}
}
5 changes: 5 additions & 0 deletions android/src/main/proguard.pro
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@
# Note: net.twisterrob.java.utils.CollectionTools accesses a declared field '*' dynamically
-dontnote net.twisterrob.java.utils.CollectionTools

# DialogTools.pickColor is not used in Inventory. It's fine to ignore these.
# Warning: net.twisterrob.android.utils.tools.DialogTools: can't find referenced class com.rarepebble.colorpicker.ColorPickerView
# Warning: net.twisterrob.android.utils.tools.DialogTools$14: can't find referenced class com.rarepebble.colorpicker.ColorPickerView
-dontwarn com.rarepebble.colorpicker.ColorPickerView


# Remove Logging for now
# FIXME use isLoggable in AndroidLogger and runtime control over TAGs
Expand Down
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ apply plugin: 'idea'
allprojects {
repositories {
google()
jcenter()
maven { name = "TWiStErRob Local"; url = "http://localhost/maven"; allowInsecureProtocol = true }
mavenCentral()
//maven { name = 'sonatype'; url = 'http://oss.sonatype.org/content/repositories/snapshots' }
//maven { name = 'idescout'; url = 'http://www.idescout.com/maven/repo/' }
}
Expand Down
14 changes: 10 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ dependencies {
testImplementation("junit:junit:${VERSION_JUNIT}")
}

tasks.withType<GroovyCompile> {
groovyOptions.configurationScript = file("../gradle/groovyc.groovy")
configurations.all {
resolutionStrategy {
dependencySubstitution {
substitute(module("net.sf.proguard:proguard-gradle"))
.using(module("com.guardsquare:proguard-gradle:7.3.1"))
.because("Latest ProGuard is 7.3.1 which supports Java 11-19, Kotlin 1.8")
}
}
}

kotlinDslPluginOptions {
experimentalWarning.set(false)
tasks.withType<GroovyCompile> {
groovyOptions.configurationScript = file("../gradle/groovyc.groovy")
}

gradlePlugin {
Expand Down
Binary file modified buildSrc/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion buildSrc/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading