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

Provide instructions on local build for Gradle Kotlin DSL in README #6339

Open
turastory opened this issue Aug 26, 2019 · 4 comments
Open

Provide instructions on local build for Gradle Kotlin DSL in README #6339

turastory opened this issue Aug 26, 2019 · 4 comments
Assignees

Comments

@turastory
Copy link

@turastory turastory commented Aug 26, 2019

[REQUIRED] Use case description

Gradle provides both way to write build script - Groovy, and Kotlin.
While both languages are perfectly fine to write typical build logic, they have different APIs in some cases.

To build locally in Kotlin, one should use gradle.extra - ExtraPropertiesExtension, which is not defined in the class definition of Gradle.

// ExtraPropertiesExtensions.kt
val ExtensionAware.extra: ExtraPropertiesExtension
    get() = extensions.extraProperties
// Gradle.java
public interface Gradle extends PluginAware

But Gradle instance is ExtensionAware, as the following code shows.

gradle is ExtensionAware == true

Guess it is because duck-typing is possible in Groovy - runtime implementation of traits?
So for those who use Kotlin DSL, appropriate instructions are needed.

Proposed solution

In settings.gradle.kts:

if (gradle is ExtensionAware) {
    val extension = gradle as ExtensionAware
    extension.extra["exoplayerRoot"] = "path/to/exoplayer"
    extension.extra["exoplayerModulePrefix"] = "exoplayer-"
    apply(from = File(extension.extra["exoplayerRoot"].toString(), "core_settings.gradle"))
}
@marcbaechinger
Copy link
Contributor

@marcbaechinger marcbaechinger commented Aug 29, 2019

Where would you expect developers using a Kotlin build script to look for this information?

@google-oss-bot
Copy link
Collaborator

@google-oss-bot google-oss-bot commented Sep 13, 2019

Hey @turastory. We need more information to resolve this issue but there hasn't been an update in 14 days. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@turastory
Copy link
Author

@turastory turastory commented Sep 16, 2019

If you're saying where to put this information, then it should be README, of course.

Other stuff are not quite different than Groovy's so those are not a big deal, but translating gradle.ext into Kotlin can be hard.

I suggest put this information below the Locally section in README.

@ojw28
Copy link
Contributor

@ojw28 ojw28 commented Dec 3, 2019

All of our documentation assumes Groovy. Admittedly other parts are easier to convert (e.g. implementation 'dependency:version' to implementation("dependency:version")), but it would seem a bit strange to document both just for this specific case. To document both everywhere would be quite noisy. As of writing, Android Studio's documentation also only references Groovy.

For the time-being I think it's reasonable that if someone wants to use Kotlin DSL, they can figure out how to do the conversion. The good news is that there's plenty of information available, including information for resolving this specific issue (e.g. by searching for things like "kotlin DSL gradle.ext").

I will keep this issue open, but mark it as low priority for now. We will revisit it as and when there's a clearer demand for Kotlin DSL specific instructions.

@ojw28 ojw28 added low priority and removed needs triage labels Dec 3, 2019
@ojw28 ojw28 assigned ojw28 and unassigned marcbaechinger Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants