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

Kotlin DSL #7

Open
larten opened this issue Jul 2, 2020 · 6 comments
Open

Kotlin DSL #7

larten opened this issue Jul 2, 2020 · 6 comments

Comments

@larten
Copy link

larten commented Jul 2, 2020

Hi,

Is it possible to use with kotlin dsl in android project?
Android Studio 3.6.2 can't resolve git {} in the gradle.kts file, but it can clone the repo. Just get an error after clone.
Has anybody idea?

settings.gradle.kts

plugins {
    id("com.alexvasilkov.git-dependencies") version "2.0.1"
}

build.gradle.kts

git {
    implementation("git@github.com:JakeWharton/timber.git") {
        name("timbermy")
        branch("master")
        projectPath("timber")
    }
}

Error

e: /.../app/build.gradle.kts:54:5: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
public fun ArtifactHandler.implementation(artifactNotation: Any): PublishArtifact defined in org.gradle.kotlin.dsl
public fun ArtifactHandler.implementation(artifactNotation: Any, configureAction: Action<ConfigurablePublishArtifact>): PublishArtifact defined in org.gradle.kotlin.dsl
public fun DependencyConstraintHandler.implementation(constraintNotation: Any): DependencyConstraint? defined in org.gradle.kotlin.dsl
public fun DependencyConstraintHandler.implementation(constraintNotation: Any, block: Action<DependencyConstraint>): DependencyConstraint defined in org.gradle.kotlin.dsl
public fun <T : Dependency> DependencyHandler.implementation(dependency: TypeVariable(T), action: Action<TypeVariable(T)>): TypeVariable(T) defined in org.gradle.kotlin.dsl
public fun DependencyHandler.implementation(dependencyNotation: Any): Dependency? defined in org.gradle.kotlin.dsl
public fun DependencyHandler.implementation(group: String, name: String, version: String? = ..., configuration: String? = ..., classifier: String? = ..., ext: String? = ..., dependencyConfiguration: Action<ExternalModuleDependency>? = ...): ExternalModuleDependency defined in org.gradle.kotlin.dsl
public fun DependencyHandler.implementation(dependencyNotation: String, dependencyConfiguration: Action<ExternalModuleDependency>): ExternalModuleDependency defined in org.gradle.kotlin.dsl
@alexvasilkov
Copy link
Owner

Sorry, the plugin does not support Kotlin DSL at the moment, it should be explcitly mentioned in readme, I'll fix this.

There are no plans for Kotlin support yet because it requires a pretty tricky logic that is hard to implement with Kotlin comparing to Groovy.

I would appreciate if somebody can help with Kotlin support.

@alexvasilkov alexvasilkov changed the title Kotlin dsl Kotlin DSL Jul 3, 2020
@larten
Copy link
Author

larten commented Jul 3, 2020

There are no plans for Kotlin support yet because it requires a pretty tricky logic that is hard to implement with Kotlin comparing to Groovy.

Which part is tricky?

I'll figure out how I have time, but I would like to solve DSL support, because I would like to use :)

@alexvasilkov
Copy link
Owner

Stracktrace you posted is caused (most probably) by the Groovy trick to handle unknown methods with special missingMethod method from EmptyExtenstion.groovy.

But I think the trickiest part will be manual Kotlin script evaluation, the code for Groovy can be found in parseBuildScript method from SettingsPlugin.groovy.

I also fear that entire plugin must be rewritten in Java to make it work for both Kotlin and Groovy, but this is not 100% clear as I never wrote Gradle plugins for Kotlin DSL before.

@larten
Copy link
Author

larten commented Jul 3, 2020

Okay, thanks! I'll check in the next few days/weeks and write here :)

@larten
Copy link
Author

larten commented Jul 4, 2020

Btw temporary solution:

  • Leave your settings.gradle in Groovy, not Kotlin DSL (.gradle.kts)
  • Use git { fetch { ... } }
  • Use the project dependency in your app :)

@alexvasilkov
Copy link
Owner

Yeah, good point, that should work if you are fine with keeping your settings.gradle in Groovy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants