Skip to content

Commit

Permalink
Merge pull request #1 from 2BAB/dev
Browse files Browse the repository at this point in the history
merge 0.4.1
  • Loading branch information
2BAB committed Dec 12, 2021
2 parents a755445 + f2542ea commit 5dfd33f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 27 deletions.
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -74,11 +74,11 @@ Find more Variant/Artifact API news from links below:
dependencies {
implementation("com.android.tools.build:gradle:7.0.3")
// Core dependency
implementation("me.2bab:polyfill:0.4.0")
implementation("me.2bab:polyfill:0.4.1")
// Add one or more artiface(s)-provider as you want ($latestVersion -> same as the core version)
classpath("me.2bab:polyfill-manifest:$latestVersion")
classpath("me.2bab:polyfill-res:$latestVersion")
classpath("me.2bab:polyfill-arsc:$latestVersion")
implementation("me.2bab:polyfill-manifest:$latestVersion")
implementation("me.2bab:polyfill-res:$latestVersion")
implementation("me.2bab:polyfill-arsc:$latestVersion")
...
}

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

| AGP Version | Latest Support Version |
|:-----------:|:----------------------:|
| 7.0.x | 0.4.0 |
| 7.0.x | 0.4.1 |
| 4.2.0 | 0.3.1 (MavenCentral) |

(The project currently compiles with the latest version of AGP 7.0, and compiles and tests against the both AGP 7.0 and
Expand Down
12 changes: 6 additions & 6 deletions README_zh.md
Expand Up @@ -67,11 +67,11 @@ Artifacts : [SingleArtifact](https://developer.android.com/reference/tools/gradl
dependencies {
implementation("com.android.tools.build:gradle:7.0.3")
// Core dependency
implementation("me.2bab:polyfill:0.4.0")
implementation("me.2bab:polyfill:0.4.1")
// Add one or more artiface(s)-provider as you want ($latestVersion -> same as the core version)
classpath("me.2bab:polyfill-manifest:$latestVersion")
classpath("me.2bab:polyfill-res:$latestVersion")
classpath("me.2bab:polyfill-arsc:$latestVersion")
implementation("me.2bab:polyfill-manifest:$latestVersion")
implementation("me.2bab:polyfill-res:$latestVersion")
implementation("me.2bab:polyfill-arsc:$latestVersion")
...
}

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

| AGP Version | Latest Support Version |
|:-----------:|:----------------------:|
| 7.0.x | 0.4.0 |
| 7.0.x | 0.4.1 |
| 4.2.0 | 0.3.1 (MavenCentral) |

(目前本工程基于 AGP 7.0 的最新版本进行开发,在 CI 环境下还会同时编译&测试 7.0/7.1 版本的兼容性)
Expand Down
Expand Up @@ -12,7 +12,7 @@ object BuildConfig {
}

object Versions {
const val polyfillDevVersion = "0.4.0"
const val polyfillDevVersion = "0.4.1"

val polyfillSourceCompatibilityVersion = JavaVersion.VERSION_1_8
val polyfillTargetCompatibilityVersion = JavaVersion.VERSION_1_8
Expand Down
Expand Up @@ -2,15 +2,14 @@ package me.xx2bab.polyfill.agp.provider

import com.android.build.api.variant.AndroidComponentsExtension
import com.android.build.api.variant.Variant
import com.android.build.gradle.internal.plugins.AppPlugin
import com.android.build.gradle.internal.scope.GlobalScope
import com.android.sdklib.BuildToolInfo
import me.xx2bab.polyfill.agp.tool.toGlobalScope
import me.xx2bab.polyfill.matrix.annotation.InitStage
import me.xx2bab.polyfill.matrix.annotation.ProviderConfig
import me.xx2bab.polyfill.matrix.base.ApplicationSelfManageableProvider
import me.xx2bab.polyfill.matrix.base.LibrarySelfManageableProvider
import me.xx2bab.polyfill.matrix.tool.ReflectionKit
import org.gradle.api.Project
import org.gradle.api.provider.Provider

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

private lateinit var bti: BuildToolInfo
private lateinit var bti: Provider<BuildToolInfo>

override fun initialize(project: Project,
androidExtension: AndroidComponentsExtension<*, *, *>,
variant: Variant) {
val basePlugin = project.plugins.findPlugin(AppPlugin::class.java)
val scope = ReflectionKit.getField(AppPlugin::class.java, basePlugin!!,
"globalScope") as GlobalScope
bti = scope.versionedSdkLoader.get().buildToolInfoProvider.get()
bti = variant.toGlobalScope().versionedSdkLoader.flatMap { it.buildToolInfoProvider }
}

override fun obtain(defaultValue: BuildToolInfo?): BuildToolInfo {
override fun obtain(defaultValue: Provider<BuildToolInfo>?): Provider<BuildToolInfo> {
return bti
}

Expand Down
Expand Up @@ -16,8 +16,9 @@ class ResourcesBeforeMergeAction(private val taskProvider: TaskProvider<*>) : Ap
variantCapitalizedName: String
) {
project.afterEvaluate {
val mergeTask = variant.toTaskContainer().mergeResourcesTask.get()
mergeTask.dependsOn(taskProvider)
// Abuse of finalizedBy(...)
val mergeTaskProvider = variant.toTaskContainer().mergeResourcesTask
mergeTaskProvider.configure { it.finalizedBy(taskProvider) }
}
}

Expand Down
Expand Up @@ -28,7 +28,7 @@ class TestPlugin : Plugin<Project> {
+ File.separator + "functionTestOutput"
)
}
val androidExtension = project.extensions.findByType(AndroidComponentsExtension::class.java)!!
val androidExtension = project.extensions.getByType(AndroidComponentsExtension::class.java)
androidExtension.onVariants { variant ->

// 0. Get Polyfill instance with Project instance
Expand Down

0 comments on commit 5dfd33f

Please sign in to comment.