Skip to content

[plugin] support android compile targets #1231

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

Merged
merged 4 commits into from
Jul 28, 2021

Conversation

dariuszkuc
Copy link
Collaborator

@dariuszkuc dariuszkuc commented Jul 27, 2021

📝 Description

Default (JVM) build use compileKotlin/compileTestKotlin tasks. Android builds use variants which has their own targets (e.g. compileDebugKotlin). Since our tasks were finalized by the compile tasks we couldn't apply it on android builds as default JVM tasks don't exist.

Cleaned up plugin logic for the default JVM builds by removing unnecessary finalizeBy clauses as adding client generating task OutputDirectory to the main/test sources automatically configures the necessary dependencies. Unfortunately same logic cannot be applied on Android projects as Android plugin is eagerly configured so configuring additional sources happens after this resolution. Until Android plugin is updated to support lazy configuration, we need to explicitly configure compile tasks to depend on our client generation tasks.

🔗 Related Issues

Resolves: #1203

@dariuszkuc dariuszkuc added changes: patch Changes require a patch version module: plugin Issue affects the plugins code labels Jul 27, 2021
Dariusz Kuc added 3 commits July 27, 2021 12:53
Default (JVM) build use `compileKotlin`/`compileTestKotlin` tasks. Android builds use variants which has their own targets (e.g. `compileDebugKotlin`). Since our tasks are finalized by the compile tasks we cannot apply it on android builds as default JVM tasks dont exist.
Gradle scans all decorated plugin/tasks/extensions classes to find all the injection points, apply validations etc. This means that we cannot have any method signatures in the plugin code that references compile only dependencies. Simple fix is to move the affected code to a separate file. See: gradle/gradle#8411 for details.
@dariuszkuc dariuszkuc marked this pull request as ready for review July 28, 2021 16:10

@ParameterizedTest
@MethodSource("pluginTests")
@EnabledIfEnvironmentVariable(named = "ANDROID_SDK_ROOT", matches = ".+")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

While Github Actions runners come preconfigured with Android setup, this ensures it will only execute if ANDROID_SDK_ROOT is set (so devs not touching this code don't have to setup Android env).

@smyrick smyrick merged commit 3832f7f into ExpediaGroup:master Jul 28, 2021
@dariuszkuc dariuszkuc deleted the android_build branch September 3, 2021 17:55
dariuszkuc added a commit to dariuszkuc/graphql-kotlin that referenced this pull request Aug 5, 2022
* [plugin] support android compile targets

Default (JVM) build use `compileKotlin`/`compileTestKotlin` tasks. Android builds use variants which has their own targets (e.g. `compileDebugKotlin`). Since our tasks are finalized by the compile tasks we cannot apply it on android builds as default JVM tasks dont exist.

* fix compile dependency

Gradle scans all decorated plugin/tasks/extensions classes to find all the injection points, apply validations etc. This means that we cannot have any method signatures in the plugin code that references compile only dependencies. Simple fix is to move the affected code to a separate file. See: gradle/gradle#8411 for details.

* fix android build dependency

* parameterize android plugin version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes: patch Changes require a patch version module: plugin Issue affects the plugins code
Development

Successfully merging this pull request may close these issues.

Plugin [id: 'com.expediagroup.graphql'] was not found in any of the following sources
2 participants