Skip to content

Commit 2f6eb14

Browse files
committed
update: Gradle 8.1.1, AGP 8.1.2, KT 1.9.10, andTool 31.1.2
Fixed all incompatible issues - Changed the task fetch approach of resource merge - Deprecated the ALL_JAVA_RES to ALL_JAVA_RES_OF_SUB_PROJECTS and ALL_JAVA_RES_OF_EXT_PROJECTS due to the artifact type change of sub project (local android lib) from Regular File to Directory - Remove all patches since they are not used anymore - Simplify the impl of ApplicationVariant.getArtifactsImpl(), ApplicationVariant.getTaskContainer(), add a new function ApplicationVariant.getVariantDependenciesImpl()
1 parent f93b039 commit 2f6eb14

31 files changed

+438
-298
lines changed

android-arsc-parser/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ java {
2323
withSourcesJar()
2424
sourceCompatibility = Versions.polyfillSourceCompatibilityVersion
2525
targetCompatibility = Versions.polyfillTargetCompatibilityVersion
26-
}
26+
}

buildSrc/src/main/kotlin/me/xx2bab/polyfill/buildscript/BuildConfig.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ object BuildConfig {
1212
}
1313

1414
object Versions {
15-
const val polyfillDevVersion = "0.8.1"
15+
const val polyfillDevVersion = "0.8.1.13-SNAPSHOT"
1616

17-
val polyfillSourceCompatibilityVersion = JavaVersion.VERSION_1_8
18-
val polyfillTargetCompatibilityVersion = JavaVersion.VERSION_1_8
17+
val polyfillSourceCompatibilityVersion = JavaVersion.VERSION_11
18+
val polyfillTargetCompatibilityVersion = JavaVersion.VERSION_17
1919
}
2020

2121
}

buildSrc/src/main/kotlin/me/xx2bab/polyfill/buildscript/functional-test-setup.gradle.kts

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010
val versionCatalog = extensions.getByType<VersionCatalogsExtension>().named("deps")
1111
val defaultAGPVer = versionCatalog.findVersion("agpVer").get().requiredVersion
12-
val defaultAGP = versionCatalog.findDependency("android-gradle-plugin").get()
12+
val defaultAGP = versionCatalog.findLibrary("android-gradle-plugin").get()
1313

1414
val fixtureClasspath: Configuration by configurations.creating
1515
tasks.pluginUnderTestMetadata {
@@ -61,11 +61,9 @@ val test by tasks.getting(Test::class) {
6161
}
6262
}
6363

64-
@Suppress("UnstableApiUsage")
6564
val fixtureAgpVersion: String = providers
6665
.environmentVariable("AGP_VERSION")
67-
.forUseAtConfigurationTime()
68-
.orElse(providers.gradleProperty("agpVersion").forUseAtConfigurationTime())
66+
.orElse(providers.gradleProperty("agpVersion"))
6967
.getOrElse(defaultAGPVer)
7068

7169

buildSrc/src/main/kotlin/me/xx2bab/polyfill/buildscript/maven-central-publish.gradle.kts

+57-37
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package me.xx2bab.polyfill.buildscript
22

3-
plugins{
3+
plugins {
44
`maven-publish`
55
signing
66
}
77

8+
val publishType = (project.properties["me.2bab.maven.publish.type"] as String) ?: "jar"
89

910
// Stub secrets to let the project sync and build without the publication values set up
1011
ext["signing.keyId"] = null
@@ -31,9 +32,9 @@ if (secretPropsFile.exists()) {
3132
ext["ossrh.username"] = System.getenv("OSSRH_USERNAME")
3233
ext["ossrh.password"] = System.getenv("OSSRH_PASSWORD")
3334
}
34-
val javadocJar by tasks.registering(Jar::class) {
35-
archiveClassifier.set("javadoc")
36-
}
35+
//val javadocJar by tasks.registering(Jar::class) {
36+
// archiveClassifier.set("javadoc")
37+
//}
3738
fun getExtraString(name: String) = ext[name]?.toString()
3839

3940

@@ -52,44 +53,61 @@ val inception = "2018"
5253

5354
val username = "2BAB"
5455

56+
fun MavenPublication.configMetadata(publishType: String) {
57+
// artifact(javadocJar.get())
58+
if (publishType != "plugin") {
59+
from(components["java"])
60+
}
61+
pom {
62+
// Description
63+
name.set(projectName)
64+
description.set(mavenDesc)
65+
url.set(siteUrl)
66+
67+
// Archive
68+
groupId = groupName
69+
artifactId = project.name
70+
version = BuildConfig.Versions.polyfillDevVersion
71+
72+
// License
73+
inceptionYear.set(inception)
74+
licenses {
75+
licenseNames.forEachIndexed { ln, li ->
76+
license {
77+
name.set(li)
78+
url.set(licenseUrls[ln])
79+
}
80+
}
81+
}
82+
developers {
83+
developer {
84+
name.set(username)
85+
}
86+
}
87+
scm {
88+
connection.set(gitUrl)
89+
developerConnection.set(gitUrl)
90+
url.set(siteUrl)
91+
}
92+
}
93+
}
5594

56-
publishing {
5795

96+
publishing {
5897
publications {
59-
create<MavenPublication>("PolyfillArtifact") {
60-
artifact(javadocJar.get())
61-
from(components["java"])
62-
pom {
63-
// Description
64-
name.set(projectName)
65-
description.set(mavenDesc)
66-
url.set(siteUrl)
67-
68-
// Archive
69-
groupId = groupName
70-
artifactId = project.name
71-
version = BuildConfig.Versions.polyfillDevVersion
72-
73-
// License
74-
inceptionYear.set(inception)
75-
licenses {
76-
licenseNames.forEachIndexed { ln, li ->
77-
license {
78-
name.set(li)
79-
url.set(licenseUrls[ln])
80-
}
98+
afterEvaluate {
99+
when (publishType) {
100+
"jar" -> {
101+
create<MavenPublication>("PolyfillArtifact") {
102+
configMetadata(publishType)
81103
}
82104
}
83-
developers {
84-
developer {
85-
name.set(username)
105+
106+
"plugin" -> {
107+
named<MavenPublication>("pluginMaven") {
108+
configMetadata(publishType)
86109
}
87110
}
88-
scm {
89-
connection.set(gitUrl)
90-
developerConnection.set(gitUrl)
91-
url.set(siteUrl)
92-
}
93111
}
94112
}
95113
}
@@ -115,6 +133,8 @@ publishing {
115133
}
116134
}
117135

118-
signing {
119-
sign(publishing.publications)
136+
afterEvaluate {
137+
signing {
138+
sign(publishing.publications)
139+
}
120140
}

deps.versions.toml

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
[versions]
2-
kotlinVer = "1.6.21"
2+
kotlinVer = "1.9.10"
33
buildConfigVer = "3.0.3"
44

5-
agpVer = "7.2.2"
6-
agpPatchIgnoredVer = "7.2.0" # To be used by backport version matching
7-
agpBackportVer = "7.1.3"
8-
agpBackportPatchIgnoredVer = "7.1.0" # To be used by backport version matching, e.g. apply backport patches when (7.1.0 <= ver < 7.2.0)
9-
agpNextBetaVer = "7.3.0-beta01"
5+
agpVer = "8.1.2"
6+
agpPatchIgnoredVer = "8.1.0" # To be used by backport version matching
7+
agpBackportVer = "8.0.1"
8+
agpBackportPatchIgnoredVer = "8.0.1" # To be used by backport version matching, e.g. apply backport patches when (7.1.0 <= ver < 7.2.0)
9+
agpNextBetaVer = "8.2.0-beta06"
1010

11-
# 30.2.0-beta03
12-
androidToolVer = "30.2.0"
11+
# Please refer to https://mvnrepository.com/artifact/com.android.tools/sdk-common?repo=google
12+
# The minor and patch version are synced with agpVer
13+
androidToolVer = "31.1.2"
1314
mockitoVer = "3.9.0"
1415

1516
[libraries]
@@ -20,11 +21,9 @@ android-tools-common = { module = "com.android.tools:common", version.ref = "and
2021
android-tools-sdklib = { module = "com.android.tools:sdklib", version.ref = "androidToolVer" }
2122
kotlin-std = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlinVer" }
2223
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlinVer" }
23-
kotlin-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.3.2" }
24-
kotlin-coroutine = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", version = "1.6.0" }
24+
kotlin-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.5.1" }
2525
guava = { module = "com.google.guava:guava", version = "30.1.1-jre" }
2626
fastJson = { module = "com.alibaba:fastjson", version = "1.2.73" }
27-
zip4j = { module = "net.lingala.zip4j:zip4j", version = "2.6.2" }
2827
hamcrest = { module = "org.hamcrest:hamcrest-library", version = "2.2" }
2928
junit = { module = "junit:junit", version = "4.12" }
3029
mockito = { module = "org.mockito:mockito-core", version.ref = "mockitoVer" }

functional-test/build.gradle.kts

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@ group = "me.2bab"
77

88
java {
99
withSourcesJar()
10-
sourceCompatibility = JavaVersion.VERSION_1_8
11-
targetCompatibility = JavaVersion.VERSION_1_8
10+
sourceCompatibility = JavaVersion.VERSION_11
11+
targetCompatibility = JavaVersion.VERSION_17
1212
}
1313

14-
dependencies {
15-
implementation(deps.kotlin.std)
16-
}
1714

1815
testing {
1916
suites {
@@ -22,15 +19,18 @@ testing {
2219
testType.set(TestSuiteType.FUNCTIONAL_TEST)
2320
dependencies {
2421
implementation(deps.hamcrest)
25-
implementation("dev.gradleplugins:gradle-test-kit:7.4.1")
26-
implementation(deps.kotlin.coroutine)
2722
implementation(deps.kotlin.serialization)
2823
implementation(deps.fastJson)
2924
}
3025
}
3126
}
3227
}
3328

29+
dependencies {
30+
implementation(deps.kotlin.std)
31+
"functionalTestImplementation"(gradleTestKit())
32+
}
33+
3434
tasks.named("check") {
3535
dependsOn(testing.suites.named("functionalTest"))
3636
}

functional-test/src/functionalTest/kotlin/me/xx2bab/koncat/SampleProjectTest.kt

+53-13
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class SampleProjectTest {
7070
GradleRunner.create().apply {
7171
forwardOutput()
7272
withProjectDir(targetProject)
73-
withGradleVersion("7.4.2")
73+
withGradleVersion("8.1.1")
7474
withArguments("clean", "assembleDebug", "--stacktrace")
7575
// Ensure this value is true when `--debug-jvm` is passed to Gradle, and false otherwise
7676
withDebug(
@@ -107,7 +107,6 @@ class SampleProjectTest {
107107
}
108108

109109

110-
111110
@ParameterizedTest
112111
@MethodSource("agpVerProvider")
113112
fun buildToolInfoTest_getAAPT2Successfully(agpVer: String) {
@@ -136,43 +135,84 @@ class SampleProjectTest {
136135
fun manifestMergePreHookConfigureActionTest_GetSuccessfully(agpVer: String) {
137136
val fileFromGetMethod =
138137
File("./build/test-app-for-$agpVer/${testProjectJsonOutputPath}/all-manifests-by-getAllInputManifestsForDebug.json")
139-
assertThat("all-manifests-by-getAllInputManifestsForDebug.json does not exist", fileFromGetMethod.exists())
140-
val getTaskDeps =
141-
File("./build/test-app-for-$agpVer/${testProjectJsonOutputPath}/get-all-input-manifests-for-debug-task-deps.txt")
142-
assertThat(getTaskDeps.readText(), Matchers.equalTo("processDebugManifest"))
138+
assertThat(
139+
"all-manifests-by-getAllInputManifestsForDebug.json does not exist",
140+
fileFromGetMethod.exists()
141+
)
142+
// val getTaskDeps =
143+
// File("./build/test-app-for-$agpVer/${testProjectJsonOutputPath}/get-all-input-manifests-for-debug-task-deps.txt")
144+
// assertThat(getTaskDeps.readText(), Matchers.equalTo("processDebugManifest"))
143145
}
144146

145147
@ParameterizedTest
146148
@MethodSource("agpVerProvider")
147149
fun generateAllResourcesBeforeMergeTest_FetchSuccessfully(agpVer: String) {
148-
val out = File("./build/test-app-for-$agpVer/${testProjectJsonOutputPath}/all-resources.json")
150+
val out =
151+
File("./build/test-app-for-$agpVer/${testProjectJsonOutputPath}/all-resources.json")
149152
assertThat("all-resources.json does not exist", out.exists())
150153
assertThat(out.readText(), StringContains("appcompat"))
151154
}
152155

153156
@ParameterizedTest
154157
@MethodSource("agpVerProvider")
155158
fun getResourceMergeDirTest_FetchSuccessfully(agpVer: String) {
156-
val out = File("./build/test-app-for-$agpVer/${testProjectJsonOutputPath}/merged-resource-dir.txt")
159+
val out =
160+
File("./build/test-app-for-$agpVer/${testProjectJsonOutputPath}/merged-resource-dir.txt")
157161
assertThat("merged-resource-dir.txt does not exist", out.exists())
158162
assertThat(out.readText(), StringContains("app/build/intermediates/merged_res/debug"))
159163
}
160164

161165
@ParameterizedTest
162166
@MethodSource("agpVerProvider")
163167
fun javaResourceMergePreHookConfigureAction_TransformSuccessfully(agpVer: String) {
164-
val out =
165-
File("./build/test-app-for-$agpVer/${testProjectJsonOutputPath}/all-java-res-by-preUpdateJavaResTaskAction.json")
168+
val out = File(
169+
"./build/test-app-for-$agpVer/${testProjectJsonOutputPath}/" +
170+
"all-java-res-by-preUpdateJavaResTaskAction.json"
171+
)
166172
assertThat("all-java-res-by-preUpdateJavaResTaskAction.json does not exist", out.exists())
167-
assertThat(out.readText(), StringContains("android-lib/build/intermediates/library_java_res/debug/res.jar"))
173+
// The legacy ALL_JAVA_RES artifact
174+
if (agpVer == "8.0.1") {
175+
assertThat(
176+
out.readText(),
177+
StringContains("android-lib/build/intermediates/library_java_res/debug/res.jar")
178+
)
179+
}
168180
}
169181

170182
@ParameterizedTest
171183
@MethodSource("agpVerProvider")
172184
fun javaResourceMergePreHookConfigureAction_GetSuccessfully(agpVer: String) {
173-
val out =
174-
File("./build/test-app-for-$agpVer/${testProjectJsonOutputPath}/all-java-res-by-getAllInputJavaResForDebug.json")
185+
val out = File(
186+
"./build/test-app-for-$agpVer/${testProjectJsonOutputPath}/" +
187+
"all-java-res-by-getAllInputJavaResForDebug.json"
188+
)
175189
assertThat("all-java-res-by-getAllInputJavaResForDebug.json does not exist", out.exists())
190+
191+
// The new JAVA_RES_FOR_SUB_PROJECTS
192+
val outForSubProjects = File(
193+
"./build/test-app-for-$agpVer/${testProjectJsonOutputPath}/" +
194+
"all-java-res-of-sub-projects-by-getAllInputJavaResForDebug.json"
195+
)
196+
assertThat(
197+
"all-java-res-of-sub-projects-by-getAllInputJavaResForDebug.json does not exist",
198+
outForSubProjects.exists()
199+
)
200+
if (agpVer != "8.0.1") {
201+
assertThat(
202+
outForSubProjects.readText(),
203+
StringContains("android-lib/build/intermediates/java_res/debug/out")
204+
)
205+
}
206+
207+
// The new JAVA_RES_FOR_EXT_PROJECTS
208+
val outForExtProjects = File(
209+
"./build/test-app-for-$agpVer/${testProjectJsonOutputPath}/" +
210+
"all-java-res-of-ext-projects-by-getAllInputJavaResForDebug.json"
211+
)
212+
assertThat(
213+
"all-java-res-of-ext-projects-by-getAllInputJavaResForDebug.json does not exist",
214+
outForSubProjects.exists()
215+
)
176216
}
177217

178218
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
44
zipStoreBase=GRADLE_USER_HOME
5-
zipStorePath=wrapper/dists
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)