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

Support Task Configuration Avoidance #1445

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ buildscript {
'compileSdk': 28,

'androidTools': '26.2.0',
'kotlin': '1.2.71',

'kotlin': '1.3.11',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this version of kotlin is not the latest, but it is recommended in AS 3.3.0 that goes with AGP 3.3.0

'release': '8.8.1',
]

ext.deps = [
android: [
'runtime': 'com.google.android:android:4.1.1.4',
'gradlePlugin': "com.android.tools.build:gradle:3.1.4",
'gradlePlugin': "com.android.tools.build:gradle:3.3.0",
],
'androidx': [
'core': "androidx.core:core:1.0.0",
Expand Down Expand Up @@ -57,7 +56,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.android.tools.build:gradle:3.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.16'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,26 @@ class ButterKnifePlugin : Plugin<Project> {
val rPackage = getPackageName(variant)
val once = AtomicBoolean()
variant.outputs.all { output ->
val processResources = output.processResources
val processResources = output.processResourcesProvider

// Though there might be multiple outputs, their R files are all the same. Thus, we only
// need to configure the task once with the R.java input and action.
if (once.compareAndSet(false, true)) {
// TODO: switch to better API once exists in AGP (https://issuetracker.google.com/118668005)
val rFile =
project.files(
when (processResources) {
is GenerateLibraryRFileTask -> processResources.textSymbolOutputFile
is LinkApplicationAndroidResourcesTask -> processResources.textSymbolOutputFile
else -> throw RuntimeException(
"Minimum supported Android Gradle Plugin is 3.1.0")
})
.builtBy(processResources)
project.tasks.create("generate${variant.name.capitalize()}R2", R2Generator::class.java) {
val processResourcesTask = processResources.get()
it.outputDir = outputDir
it.rFile = rFile
// TODO: switch to better API once exists in AGP (https://issuetracker.google.com/118668005)
it.rFile = project.files(
when (processResourcesTask) {
is GenerateLibraryRFileTask -> processResourcesTask.textSymbolOutputFile
is LinkApplicationAndroidResourcesTask -> processResourcesTask.textSymbolOutputFile
else -> throw RuntimeException(
"Minimum supported Android Gradle Plugin is 3.3.0")
})
.builtBy(processResourcesTask)
it.packageName = rPackage
it.className = "R2"
// TODO: switch to as task provider when AGP supports it: (https://issuetracker.google.com/issues/123655659)
variant.registerJavaGeneratingTask(it, outputDir)
}
}
Expand Down
3 changes: 1 addition & 2 deletions butterknife/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="butterknife"/>
<manifest package="butterknife.core"/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a side effect of upgrading the AGP version, it looks like single word package names are not allowed anymore. But I don't think it has any impact.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the impact of the change of the manifest ?