Skip to content

Commit 5dfd33f

Browse files
authored
Merge pull request #1 from 2BAB/dev
merge 0.4.1
2 parents a755445 + f2542ea commit 5dfd33f

6 files changed

Lines changed: 24 additions & 27 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ Find more Variant/Artifact API news from links below:
7474
dependencies {
7575
implementation("com.android.tools.build:gradle:7.0.3")
7676
// Core dependency
77-
implementation("me.2bab:polyfill:0.4.0")
77+
implementation("me.2bab:polyfill:0.4.1")
7878
// Add one or more artiface(s)-provider as you want ($latestVersion -> same as the core version)
79-
classpath("me.2bab:polyfill-manifest:$latestVersion")
80-
classpath("me.2bab:polyfill-res:$latestVersion")
81-
classpath("me.2bab:polyfill-arsc:$latestVersion")
79+
implementation("me.2bab:polyfill-manifest:$latestVersion")
80+
implementation("me.2bab:polyfill-res:$latestVersion")
81+
implementation("me.2bab:polyfill-arsc:$latestVersion")
8282
...
8383
}
8484

@@ -92,7 +92,7 @@ buildscript {
9292
dependencies {
9393
classpath("com.android.tools.build:gradle:7.0.3")
9494
// Core dependency
95-
classpath("me.2bab:polyfill:0.4.0")
95+
classpath("me.2bab:polyfill:0.4.1")
9696
// Add one or more artiface(s)-provider as you want ($latestVersion -> same as the core version)
9797
classpath("me.2bab:polyfill-manifest:$latestVersion")
9898
classpath("me.2bab:polyfill-res:$latestVersion")
@@ -150,7 +150,7 @@ Polyfill is only supported & tested on latest **2** Minor versions of Android Gr
150150

151151
| AGP Version | Latest Support Version |
152152
|:-----------:|:----------------------:|
153-
| 7.0.x | 0.4.0 |
153+
| 7.0.x | 0.4.1 |
154154
| 4.2.0 | 0.3.1 (MavenCentral) |
155155

156156
(The project currently compiles with the latest version of AGP 7.0, and compiles and tests against the both AGP 7.0 and

README_zh.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ Artifacts : [SingleArtifact](https://developer.android.com/reference/tools/gradl
6767
dependencies {
6868
implementation("com.android.tools.build:gradle:7.0.3")
6969
// Core dependency
70-
implementation("me.2bab:polyfill:0.4.0")
70+
implementation("me.2bab:polyfill:0.4.1")
7171
// Add one or more artiface(s)-provider as you want ($latestVersion -> same as the core version)
72-
classpath("me.2bab:polyfill-manifest:$latestVersion")
73-
classpath("me.2bab:polyfill-res:$latestVersion")
74-
classpath("me.2bab:polyfill-arsc:$latestVersion")
72+
implementation("me.2bab:polyfill-manifest:$latestVersion")
73+
implementation("me.2bab:polyfill-res:$latestVersion")
74+
implementation("me.2bab:polyfill-arsc:$latestVersion")
7575
...
7676
}
7777

@@ -85,7 +85,7 @@ buildscript {
8585
dependencies {
8686
classpath("com.android.tools.build:gradle:7.0.3")
8787
// Core dependency
88-
classpath("me.2bab:polyfill:0.4.0")
88+
classpath("me.2bab:polyfill:0.4.1")
8989
// Add one or more artiface(s)-provider as you want ($latestVersion -> same as the core version)
9090
classpath("me.2bab:polyfill-manifest:$latestVersion")
9191
classpath("me.2bab:polyfill-res:$latestVersion")
@@ -141,7 +141,7 @@ Polyfill 只支持并在最新的两个 Android Gradle Plugin 版本进行测试
141141

142142
| AGP Version | Latest Support Version |
143143
|:-----------:|:----------------------:|
144-
| 7.0.x | 0.4.0 |
144+
| 7.0.x | 0.4.1 |
145145
| 4.2.0 | 0.3.1 (MavenCentral) |
146146

147147
(目前本工程基于 AGP 7.0 的最新版本进行开发,在 CI 环境下还会同时编译&测试 7.0/7.1 版本的兼容性)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ object BuildConfig {
1212
}
1313

1414
object Versions {
15-
const val polyfillDevVersion = "0.4.0"
15+
const val polyfillDevVersion = "0.4.1"
1616

1717
val polyfillSourceCompatibilityVersion = JavaVersion.VERSION_1_8
1818
val polyfillTargetCompatibilityVersion = JavaVersion.VERSION_1_8

polyfill-agp/src/main/kotlin/me/xx2bab/polyfill/agp/provider/BuildToolProvider.kt renamed to polyfill-agp/src/main/kotlin/me/xx2bab/polyfill/agp/provider/BuildToolInfoProvider.kt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ package me.xx2bab.polyfill.agp.provider
22

33
import com.android.build.api.variant.AndroidComponentsExtension
44
import com.android.build.api.variant.Variant
5-
import com.android.build.gradle.internal.plugins.AppPlugin
6-
import com.android.build.gradle.internal.scope.GlobalScope
75
import com.android.sdklib.BuildToolInfo
6+
import me.xx2bab.polyfill.agp.tool.toGlobalScope
87
import me.xx2bab.polyfill.matrix.annotation.InitStage
98
import me.xx2bab.polyfill.matrix.annotation.ProviderConfig
109
import me.xx2bab.polyfill.matrix.base.ApplicationSelfManageableProvider
1110
import me.xx2bab.polyfill.matrix.base.LibrarySelfManageableProvider
12-
import me.xx2bab.polyfill.matrix.tool.ReflectionKit
1311
import org.gradle.api.Project
12+
import org.gradle.api.provider.Provider
1413

1514
/**
1615
* To get the BuildTool obj, which is located at sdk dir like:
@@ -25,21 +24,18 @@ import org.gradle.api.Project
2524
* @see BuildToolInfo
2625
*/
2726
@ProviderConfig(InitStage.PRE_BUILD)
28-
class BuildToolProvider : ApplicationSelfManageableProvider<BuildToolInfo>,
29-
LibrarySelfManageableProvider<BuildToolInfo> {
27+
class BuildToolInfoProvider : ApplicationSelfManageableProvider<Provider<BuildToolInfo>>,
28+
LibrarySelfManageableProvider<Provider<BuildToolInfo>> {
3029

31-
private lateinit var bti: BuildToolInfo
30+
private lateinit var bti: Provider<BuildToolInfo>
3231

3332
override fun initialize(project: Project,
3433
androidExtension: AndroidComponentsExtension<*, *, *>,
3534
variant: Variant) {
36-
val basePlugin = project.plugins.findPlugin(AppPlugin::class.java)
37-
val scope = ReflectionKit.getField(AppPlugin::class.java, basePlugin!!,
38-
"globalScope") as GlobalScope
39-
bti = scope.versionedSdkLoader.get().buildToolInfoProvider.get()
35+
bti = variant.toGlobalScope().versionedSdkLoader.flatMap { it.buildToolInfoProvider }
4036
}
4137

42-
override fun obtain(defaultValue: BuildToolInfo?): BuildToolInfo {
38+
override fun obtain(defaultValue: Provider<BuildToolInfo>?): Provider<BuildToolInfo> {
4339
return bti
4440
}
4541

polyfill-res/src/main/kotlin/me/xx2bab/polyfill/res/ResourcesBeforeMergeAction.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ class ResourcesBeforeMergeAction(private val taskProvider: TaskProvider<*>) : Ap
1616
variantCapitalizedName: String
1717
) {
1818
project.afterEvaluate {
19-
val mergeTask = variant.toTaskContainer().mergeResourcesTask.get()
20-
mergeTask.dependsOn(taskProvider)
19+
// Abuse of finalizedBy(...)
20+
val mergeTaskProvider = variant.toTaskContainer().mergeResourcesTask
21+
mergeTaskProvider.configure { it.finalizedBy(taskProvider) }
2122
}
2223
}
2324

test-plugin/src/main/kotlin/me/xx2bab/polyfill/test/TestPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TestPlugin : Plugin<Project> {
2828
+ File.separator + "functionTestOutput"
2929
)
3030
}
31-
val androidExtension = project.extensions.findByType(AndroidComponentsExtension::class.java)!!
31+
val androidExtension = project.extensions.getByType(AndroidComponentsExtension::class.java)
3232
androidExtension.onVariants { variant ->
3333

3434
// 0. Get Polyfill instance with Project instance

0 commit comments

Comments
 (0)