Hey david, letting you know of a possible bug (pos...
# http4k
r
Hey david, letting you know of a possible bug (possibly minor): In gradle under dependencies if I have both: compile group: “org.http4k”, name: “http4k-server-netty”, version: http4kVersion and compile group: “org.http4k”, name: “http4k-server-jetty”, version: http4kVersion The generated jar file is broken, cannot find main function. I didn’t really need both, I was using only one, but took me a few hours to find out why my jar is broken since everything else was configured correctly.
d
That's really weird - which gradle plugin are you using to provide the main function? Could you please post a minimal gradle file? We don't have any control over how gradle packages up the apps - it could be something about how jetty or netty jars are produced (meta-inf).
r
Sure
Copy code
plugins {
    id 'java'
    id 'org.jetbrains.kotlin.jvm' version '1.3.40'
}

group 'com.test'
version '1.0'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

sourceSets {
    main.java.srcDirs += 'src/main/kotlin/'
    test.java.srcDirs += 'src/test/kotlin/'
}
ext {
    kotlin_version = '1.3.40'
    http4kVersion = '3.146.0'
}

dependencies {
    compile ("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    testCompile group: 'junit', name: 'junit', version: '4.12'

    /**
     *  HTTP Kit
     */
    compile group: "org.http4k", name: "http4k-core", version: http4kVersion
    compile group: "org.http4k", name: "http4k-contract", version: http4kVersion
    compile group: "org.http4k", name: "http4k-server-netty", version: http4kVersion
    compile group: "org.http4k", name: "http4k-server-jetty", version: http4kVersion
    compile group: "org.http4k", name: "http4k-client-okhttp", version: http4kVersion
    compile group: "org.http4k", name: "http4k-cloudnative", version: http4kVersion
    compile group: "org.http4k", name: "http4k-format-jackson", version: http4kVersion
    compile group: "org.http4k", name: "http4k-testing-hamkrest", version: http4kVersion
}

compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

jar {
    manifest {
        attributes 'Main-Class': 'HelloWorldKt'
    }
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
Main function is just a HelloWorld.kt file with
Copy code
fun main(args:Array<String>){
    println("Hello world")
}
Even that seems to have a jar lunch problem when using:
java -jar example.jar
Removing either jetty or netty seems to solve it
d
That is very weird - will look further, but not sure there is anything we can do TBH - it's probably something in the jetty or Netty jars interfering with the manifests when you zip them. Also, we generally use the standard "application" plugin to give us a ZIP file containing a launcher script instead of the jar.
r
Tried that too :x
I don’t really mind to be honest I only need one of them anyway
Was just to let you know in case it was important to you guys, again thanks 🙂
d
Thanks for the heads up. 😉