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

Genereated classes can not be resolved #35

Open
helmbold opened this issue Jun 11, 2020 · 1 comment
Open

Genereated classes can not be resolved #35

helmbold opened this issue Jun 11, 2020 · 1 comment

Comments

@helmbold
Copy link

helmbold commented Jun 11, 2020

If I generate Java classes from xsd files the resulting classes are not found. During compilation I get Unresolved reference: MyClass errors.

The configuration is like the following:

plugins {
    kotlin("jvm") version "1.3.72"
    kotlin("plugin.spring") version "1.3.72"
    id("com.intershop.gradle.jaxb") version "4.3.0"
}

jaxb {
    javaGen {
        create("example1") {
            language = "XMLSCHEMA"
            schemas = layout.files(
                "src/main/generation/example1a.xsd",
                "src/main/generation/example1b.xsd"
            )
            bindings = layout.files("src/main/generation/example1.xjb")
        }
        create("example2") {
            language = "XMLSCHEMA"
            schemas = layout.files("src/main/generation/example2.xsd")
            bindings = layout.files("src/main/generation/example2.xjb")
        }
    }
}

sourceSets {
    main {
        java {
            srcDirs += file("generated/jaxb/java")
        }
    }
}

All class files are generated as expected. They are located under "build/generated/jaxb/java".

Following the documentation they should be added to the source set "main" automatically, but even adding them explicitly with the sourceSets block doesn't help.

Everything was working with the plug-in version 4.0.0.

@mschorsch
Copy link

mschorsch commented Nov 25, 2023

The problem is that the plugin does not support Kotlin properly. The generated source files are only added to the Java sourceset "main" and not to the Kotlin sourceset "main". In addition, the generation of the classes should be done before the task "compileKotlin".

Something like this:

plugins {
    id("com.intershop.gradle.jaxb") version "6.0.0"
}

jaxb {
     // generate java code from schema
     javaGen {
        //generates a 'project' schema file from existing java code
        register("name") {
            schema = file("schema.xsd")
            binding = file("binding.xjb")
        }
    }
}

sourceSets {
    main {
        kotlin {
            srcDir("${project.buildDir}/generated/jaxb/java/name")
        }
    }
}

tasks.compileKotlin {
   dependsOn("jaxbJavaGenName")
}

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

2 participants