I’m trying to use the Kotlin Gradle plugin by loading the plugin artifacts and all its runtime dependencies from a local directory. However, the plugin is not able to find the kotlin-scripting-compiler-embeddable
dependency, even though this JAR (and all its transitive runtime dependencies) is in the classpath.
My directory structure is:
$ ls
build.gradle libs settings.gradle src
$ ls libs
kotlin-android-extensions-1.3.20.jar kotlin-gradle-plugin-1.3.20.jar kotlin-script-runtime-1.3.20.jar
kotlin-annotation-processing-gradle-1.3.20.jar kotlin-gradle-plugin-api-1.3.20.jar kotlin-stdlib-1.3.20.jar
kotlin-compiler-embeddable-1.3.20.jar kotlin-gradle-plugin-model-1.3.20.jar trove4j-1.0.20181211.jar
kotlin-compiler-runner-1.3.20.jar kotlin-reflect-1.3.20.jar
kotlin-daemon-client-1.3.20.jar kotlin-scripting-compiler-embeddable-1.3.20.jar ```
My build.gradle
is:
buildscript {
dependencies {
classpath fileTree(dir: 'libs', include: '*.jar')
}
}
apply plugin: 'kotlin'
dependencies {
kotlinCompilerClasspath fileTree(dir: 'libs', include: '*.jar')
kotlinCompilerPluginClasspath fileTree(dir: 'libs', include: '*.jar')
}
And the problem is:
$ gradle assemble
Picked up _JAVA_OPTIONS: -Xmx900m
> Task :compileKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileKotlin'.
> Could not resolve all files for configuration ':kotlinCompilerPluginClasspath'.
> Cannot resolve external dependency org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.3.20 because no repositories are defined.
Required by:
project :
...
To reproduce the failure, there must be at least one Kotlin file in src/main/kotlin
(even if it’s empty).
I’m using Gradle 4.10.2.
Please note: I’m aware that adding an external repository to the project (like mavenCentral) solves the problem, as explained e.g. here. However, I have the requirement to resolve all build artifacts locally (including gradle plugins), without connecting to any repository.
Am I doing something wrong? Is there a limitation in how the plugin resolves the classpath that doesn’t allow this (admittedly uncommon) use case?
Thanks in advance.