Does the kotlin dsl not have the `api` method for ...
# gradle
s
Does the kotlin dsl not have the
api
method for dependencies?
g
Kotlin-DSL can use
api
configuration
No problem there, it's just configurations api
Probably you have some problem because of dynamic usage of api configuration, when Kotlin-dsl doesn't provide you type safe accessor. You can use dynamic string invocation syntax: "api"("somedependency1.2.3")
s
Hm. i'm not doing anything dynamic, just trying to use it regularly, but it says that it's not a method.
Copy code
Line 29:     api("io.swagger:swagger-annotations")
               ^ Unresolved reference: api
I'll try the string syntax
that gives me this error instead...
Configuration with name 'api' not found.
m
Are you using the
java-library
plugin?
s
@mkobit
Copy code
plugins {
    base
    java
    kotlin("jvm") version "1.2.51"
}
so no, but i was using the java plugin
c
api
is provided by
java-library
👍 1
n
The java-library plugin does work with the kotlin-jvm plugin, however compatibility isn't guaranteed (https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_known_issues) 🙁.
Would be good to see the kotlin-jvm plugin being officially supported by the java-library plugin, even on Kotlin multi-platform (https://kotlinlang.org/docs/reference/multiplatform.html) projects.
g
Android plugin uses java-library plugin under the hood (or uses the same approach not sure) and there are no problems with Kotlin plugin.
simple smile 1
g
I never encountered any problems with the java-library plugin. And since both plugins share most of their code in the Java base plugin, I do not expect any problems.
g
Of course some update of java-library or Kotlin can introduce some problems (maybe classpath resolution changed or something like that), but it can happen with any feature.