Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate hk2 inhabitant files with Gradle for Kotlin files #494

Open
pmwmedia opened this issue Feb 27, 2020 · 0 comments
Open

Generate hk2 inhabitant files with Gradle for Kotlin files #494

pmwmedia opened this issue Feb 27, 2020 · 0 comments

Comments

@pmwmedia
Copy link

pmwmedia commented Feb 27, 2020

The HK2 Metadata Generator seems to generate nothing for Kotlin projects. Is there any way to adapt the HK2 Metadata Generator for Kotlin?

Currently I'm using a dirty workaround with a custom Gradle task:

dependencies {
    "implementation"(kotlin("stdlib-jdk8"))
    "implementation"("org.glassfish.hk2:hk2:2.6.1")
    "implementation"("org.glassfish.jersey.containers:jersey-container-jetty-http:2.30")
    "compileOnly"("org.glassfish.hk2:hk2-inhabitant-generator:2.6.1")

    invoke {
        configurations["implementation"].isCanBeResolved = true
    }
}

tasks {
    val hk2InhabitantGeneration = register<JavaExec>("hk2InhabitantGeneration") {
        onlyIf { project.buildDir.resolve("classes/kotlin/main").isDirectory }

        classpath = configurations["compileClasspath"]
        main = "org.jvnet.hk2.generator.HabitatGenerator"
        args = listOf(
                "--searchPath",
                configurations["implementation"].asPath,
                "--file",
                project.buildDir.resolve("classes/kotlin/main").absolutePath,
                "--directory",
                project.buildDir.resolve("resources/main/META-INF/hk2-locator").absolutePath)
    }

    named("classes") {
        doFirst {
            hk2InhabitantGeneration.get().exec()
        }
    }
}
@pmwmedia pmwmedia changed the title Gradle Plugin for Inhabitant Generation Gradle Plugin for Inhabitant Generation with Kotlin Feb 27, 2020
@pmwmedia pmwmedia changed the title Gradle Plugin for Inhabitant Generation with Kotlin Generate hk2 inhabitant files with Gradle for Kotlin files Feb 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant