GradleGitDependenciesPlugin
GradleGitDependenciesPlugin copied to clipboard
Kotlin DSL
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("[email protected]: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
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.
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 :)
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.
Okay, thanks! I'll check in the next few days/weeks and write here :)
Btw temporary solution:
- Leave your settings.gradle in Groovy, not Kotlin DSL (.gradle.kts)
- Use git { fetch { ... } }
- Use the project dependency in your app :)
Yeah, good point, that should work if you are fine with keeping your settings.gradle
in Groovy.