Hi. Not sure if this is the right place to ask. I ...
# gradle
m
Hi. Not sure if this is the right place to ask. I am trying to get jaxb generated java classes into my kotlin project using gradle with the kotlin-dsl. I am applying the
com.ewerk.gradle.plugins.jaxb2
-plugin. So far I’ve got the classes generated, but they don’t seem to be added to my classpath correctly, as I can’t use them from my kotlin source code. The generated java classes are put in
src/generated/java
. anyone got any experience with using java generators in componation with kotlin? Or got a working jaxb/kotlin/gradle/kotlin-dsl example?
a
I'm using that same plugin and the way I use it is by adding
src/generated
is the following: (sorry for the groovy)
Copy code
sourceSets {
    main {
        java {
            srcDirs += ['src/generated/java']
m
Which version are you using? Do you mind sharing your plugin config as well? I've done this as well, but not getting the results I'm expecting.
a
Copy code
sourceSets {
    main {
        java {
            srcDirs += ['src/generated/java']
        }
    }
}

jaxb2 {
  xjc {
    'hello' {
        generatedSourcesDir  = 'src/generated/java'
        basePackage = 'com.ourcompany'
        schema = 'src/main/resources/xsd/schema.xsd'
        createSourceSet = false
    }
  }
}

dependencies {
    compile jaxbApi
    jaxb2 'org.glassfish.jaxb:jaxb-xjc:2.4.0-b180830.0438'
}
Though the plugin itself is getting pretty dated at this point, there doesn't seem to be any ongoing work on maintaining it and featurewise it's somewhere at gradle 3/4
m
Yeah, was the newest I could find. Will try it out, or I just might just code the xml by hand...
a
It works for sure, but if I were you I'd put jaxb into its own project
m
Got me to the point where I’ve now got the files in the src, but shouldn’t they really just be in the out (target in java?) Not the src?
a
Do you not want them compiled? For me it seemed to make the most sense to have them get generated into
src/generated/java
and to put that into
.gitignore