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

Use reflection to support both versions of Android Studio #7

Merged
merged 1 commit into from
Jan 31, 2019

Conversation

tasomaniac
Copy link
Collaborator

@tasomaniac tasomaniac commented Jan 31, 2019

Android Studio did a break change with the public task API on Android Studio 3.4.

This breaks the compatibility between Pickle and AS 3.4

If the plugin would've been in Groovy, this would be 1 line fix. Kotlin is not so dynamic :trollface:

Anyways, here is a fix to support all versions. It uses reflection utilities from Gradle to access new APIs. If they're not available, it fallbacks to original.

Fixes #4

@tasomaniac tasomaniac force-pushed the taso/support-as-3.4 branch 3 times, most recently from c0457ca to 173ea87 Compare January 31, 2019 09:11
plugin/src/main/java/com/fourlastor/pickle/PicklePlugin.kt Outdated Show resolved Hide resolved
configure(project, testVariants, extension)
}
}
is AppPlugin -> {
project.extensions.findByType(AppExtension::class.java).run {
project.extensions.findByType(AppExtension::class.java)?.run {
Copy link
Owner

Choose a reason for hiding this comment

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

why the ? here?

val mergeAssets = method(taskProvider, MergeSourceSetFolders::class.java, "get").invoke(taskProvider)
val outputDirProvider = method(mergeAssets, Provider::class.java, "getOutputDir").invoke(mergeAssets)
(outputDirProvider.get() as Directory).asFile
} catch (ignored: Exception) {
Copy link
Owner

Choose a reason for hiding this comment

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

can we have a more specific catched exception here?

@fourlastor
Copy link
Owner

Thank you @tasomaniac!

@fourlastor fourlastor merged commit a7a7125 into fourlastor:master Jan 31, 2019
@tasomaniac tasomaniac deleted the taso/support-as-3.4 branch February 1, 2019 18:23
This was referenced Feb 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

incompatibility with Gradle 5.1
2 participants