Coroutines Dependency in Kotlin Gradle Plugin

Multi tool use
I’m building a Gradle Plugin with Kotlin, in one of the features I’m using Ktor and Coroutines. The plugin must to be included as classpath in third part projects.
Problem comes when I’m trying to use the Plugin in another project, I'm getting:
Caused by: java.lang.NoClassDefFoundError: kotlin/coroutines/Continuation
on the consumer project.
I tried to isolate the Coroutines dependencies and apply transitive dependencies for Ktor but no success.
I have seen too different solutions(https://github.com/Kotlin/kotlinx.coroutines/issues/430) like applying ShadowJar to build a FatJar but maybe I’m missing something in the configuration. Once I apply the Shadow Plugin the jar is about 62Mb, even applying minimize
size of the jar is 12MB.
The basic conf(based on the samples of Kotlin-DSL) of the plugin would be:
plugins {
`kotlin-dsl`
`maven-publish`
kotlin("jvm") version "1.3.10"
id("com.github.johnrengelman.shadow") version "4.0.3"
}
gradlePlugin {
plugins {
register("greet-plugin") {
id = "greet"
implementationClass = "GreetPlugin"
}
}
dependencies {
api("io.ktor:ktor-client-okhttp:1.0.1")
}
}
val sourcesJar by tasks.registering(Jar::class) {
classifier = "sources"
from(sourceSets.main.get().allSource)
}
val shadowJar: ShadowJar by tasks
shadowJar.apply {
baseName = "test"
classifier = ""
minimize()
}
The complete example is here:
https://github.com/cdsap/testPluginCoroutinesProblem
A more detailed error
java.lang.NoClassDefFoundError: kotlin/coroutines/Continuation
at io.ktor.client.engine.okhttp.OkHttp.create(OkHttp.kt:8)
at io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:36)
at io.ktor.client.HttpClientKt.HttpClient$default(HttpClient.kt:33)
at GreetPlugin.apply(GreetPlugin.kt:26)
at GreetPlugin.apply(GreetPlugin.kt:12)
I expect the plugin will build properly the coroutines dependency within Ktor and don't have big jar as dependency.
kotlin gradle-kotlin-dsl
add a comment |
I’m building a Gradle Plugin with Kotlin, in one of the features I’m using Ktor and Coroutines. The plugin must to be included as classpath in third part projects.
Problem comes when I’m trying to use the Plugin in another project, I'm getting:
Caused by: java.lang.NoClassDefFoundError: kotlin/coroutines/Continuation
on the consumer project.
I tried to isolate the Coroutines dependencies and apply transitive dependencies for Ktor but no success.
I have seen too different solutions(https://github.com/Kotlin/kotlinx.coroutines/issues/430) like applying ShadowJar to build a FatJar but maybe I’m missing something in the configuration. Once I apply the Shadow Plugin the jar is about 62Mb, even applying minimize
size of the jar is 12MB.
The basic conf(based on the samples of Kotlin-DSL) of the plugin would be:
plugins {
`kotlin-dsl`
`maven-publish`
kotlin("jvm") version "1.3.10"
id("com.github.johnrengelman.shadow") version "4.0.3"
}
gradlePlugin {
plugins {
register("greet-plugin") {
id = "greet"
implementationClass = "GreetPlugin"
}
}
dependencies {
api("io.ktor:ktor-client-okhttp:1.0.1")
}
}
val sourcesJar by tasks.registering(Jar::class) {
classifier = "sources"
from(sourceSets.main.get().allSource)
}
val shadowJar: ShadowJar by tasks
shadowJar.apply {
baseName = "test"
classifier = ""
minimize()
}
The complete example is here:
https://github.com/cdsap/testPluginCoroutinesProblem
A more detailed error
java.lang.NoClassDefFoundError: kotlin/coroutines/Continuation
at io.ktor.client.engine.okhttp.OkHttp.create(OkHttp.kt:8)
at io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:36)
at io.ktor.client.HttpClientKt.HttpClient$default(HttpClient.kt:33)
at GreetPlugin.apply(GreetPlugin.kt:26)
at GreetPlugin.apply(GreetPlugin.kt:12)
I expect the plugin will build properly the coroutines dependency within Ktor and don't have big jar as dependency.
kotlin gradle-kotlin-dsl
add a comment |
I’m building a Gradle Plugin with Kotlin, in one of the features I’m using Ktor and Coroutines. The plugin must to be included as classpath in third part projects.
Problem comes when I’m trying to use the Plugin in another project, I'm getting:
Caused by: java.lang.NoClassDefFoundError: kotlin/coroutines/Continuation
on the consumer project.
I tried to isolate the Coroutines dependencies and apply transitive dependencies for Ktor but no success.
I have seen too different solutions(https://github.com/Kotlin/kotlinx.coroutines/issues/430) like applying ShadowJar to build a FatJar but maybe I’m missing something in the configuration. Once I apply the Shadow Plugin the jar is about 62Mb, even applying minimize
size of the jar is 12MB.
The basic conf(based on the samples of Kotlin-DSL) of the plugin would be:
plugins {
`kotlin-dsl`
`maven-publish`
kotlin("jvm") version "1.3.10"
id("com.github.johnrengelman.shadow") version "4.0.3"
}
gradlePlugin {
plugins {
register("greet-plugin") {
id = "greet"
implementationClass = "GreetPlugin"
}
}
dependencies {
api("io.ktor:ktor-client-okhttp:1.0.1")
}
}
val sourcesJar by tasks.registering(Jar::class) {
classifier = "sources"
from(sourceSets.main.get().allSource)
}
val shadowJar: ShadowJar by tasks
shadowJar.apply {
baseName = "test"
classifier = ""
minimize()
}
The complete example is here:
https://github.com/cdsap/testPluginCoroutinesProblem
A more detailed error
java.lang.NoClassDefFoundError: kotlin/coroutines/Continuation
at io.ktor.client.engine.okhttp.OkHttp.create(OkHttp.kt:8)
at io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:36)
at io.ktor.client.HttpClientKt.HttpClient$default(HttpClient.kt:33)
at GreetPlugin.apply(GreetPlugin.kt:26)
at GreetPlugin.apply(GreetPlugin.kt:12)
I expect the plugin will build properly the coroutines dependency within Ktor and don't have big jar as dependency.
kotlin gradle-kotlin-dsl
I’m building a Gradle Plugin with Kotlin, in one of the features I’m using Ktor and Coroutines. The plugin must to be included as classpath in third part projects.
Problem comes when I’m trying to use the Plugin in another project, I'm getting:
Caused by: java.lang.NoClassDefFoundError: kotlin/coroutines/Continuation
on the consumer project.
I tried to isolate the Coroutines dependencies and apply transitive dependencies for Ktor but no success.
I have seen too different solutions(https://github.com/Kotlin/kotlinx.coroutines/issues/430) like applying ShadowJar to build a FatJar but maybe I’m missing something in the configuration. Once I apply the Shadow Plugin the jar is about 62Mb, even applying minimize
size of the jar is 12MB.
The basic conf(based on the samples of Kotlin-DSL) of the plugin would be:
plugins {
`kotlin-dsl`
`maven-publish`
kotlin("jvm") version "1.3.10"
id("com.github.johnrengelman.shadow") version "4.0.3"
}
gradlePlugin {
plugins {
register("greet-plugin") {
id = "greet"
implementationClass = "GreetPlugin"
}
}
dependencies {
api("io.ktor:ktor-client-okhttp:1.0.1")
}
}
val sourcesJar by tasks.registering(Jar::class) {
classifier = "sources"
from(sourceSets.main.get().allSource)
}
val shadowJar: ShadowJar by tasks
shadowJar.apply {
baseName = "test"
classifier = ""
minimize()
}
The complete example is here:
https://github.com/cdsap/testPluginCoroutinesProblem
A more detailed error
java.lang.NoClassDefFoundError: kotlin/coroutines/Continuation
at io.ktor.client.engine.okhttp.OkHttp.create(OkHttp.kt:8)
at io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:36)
at io.ktor.client.HttpClientKt.HttpClient$default(HttpClient.kt:33)
at GreetPlugin.apply(GreetPlugin.kt:26)
at GreetPlugin.apply(GreetPlugin.kt:12)
I expect the plugin will build properly the coroutines dependency within Ktor and don't have big jar as dependency.
kotlin gradle-kotlin-dsl
kotlin gradle-kotlin-dsl
asked Dec 31 '18 at 19:01
cdsapcdsap
4319
4319
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53990624%2fcoroutines-dependency-in-kotlin-gradle-plugin%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53990624%2fcoroutines-dependency-in-kotlin-gradle-plugin%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
LMj5HiQuRfqLUSn9zw50e4bMSyB S,gxhhc5aabNGD