Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle build fail

I am using the tutorial at https://spring.io/guides/gs/producing-web-service/#initial to try and produce a SOAP web service. I am using Gradle to manage my dependencies.

I have a .xsd file which specifies certain classes that I want gradle to create.

However, when I try to run a gradle build on the build.gradle file in eclipse I get the following error:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\zekucukkose\workspace2\gs-producing-web-service-initial\build.gradle' 
line: 32

* What went wrong:
A problem occurred evaluating root project 'gs-producing-web-service-initial'.

> Could not find method jaxb() for arguments [com.sun.xml.bind:jaxb-xjc:2.2.4-1]
 on root project 'gs-producing-web-service-initial'.

Lines 27 through 34 are as follows:

27 dependencies {
28    compile("org.springframework.boot:spring-boot-starter-web")
29        compile("org.springframework.boot:spring-boot-starter-ws")
30    testCompile("org.springframework.boot:spring-boot-starter-test")
31    compile("wsdl4j:wsdl4j:1.6.1")
32    jaxb("com.sun.xml.bind:jaxb-xjc:2.2.4-1")
33    compile(files(genJaxb.classesDir).builtBy(genJaxb))
34 }

jaxb is what is used to generate the actual classes as far as I'm aware.

If anyone could help, I'd really appreciate it. Thanks

This is the whole script:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.7.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

jar {
    baseName = 'gs-producing-web-service'
    version =  '0.1.0'
}

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
        compile("org.springframework.boot:spring-boot-starter-ws")
    testCompile("org.springframework.boot:spring-boot-starter-test")
    compile("wsdl4j:wsdl4j:1.6.1")
    jaxb("com.sun.xml.bind:jaxb-xjc:2.2.4-1")
    compile(files(genJaxb.classesDir).builtBy(genJaxb))
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.3'
}

task genJaxb {
    ext.sourcesDir = "${buildDir}/generated-sources/jaxb"
    ext.classesDir = "${buildDir}/classes/jaxb"
    ext.schema = "src/main/resources/countries.xsd"

    outputs.dir classesDir

    doLast() {
        project.ant {
            taskdef name: "xjc", classname: "com.sun.tools.xjc.XJCTask",
                    classpath: configurations.jaxb.asPath
            mkdir(dir: sourcesDir)
            mkdir(dir: classesDir)

            xjc(destdir: sourcesDir, schema: schema) {
                arg(value: "-wsdl")
                produces(dir: sourcesDir, includes: "**/*.java")
            }

            javac(destdir: classesDir, source: 1.6, target: 1.6, debug: true,
                    debugLevel: "lines,vars,source",
                    classpath: configurations.jaxb.asPath) {
                src(path: sourcesDir)
                include(name: "**/*.java")
                include(name: "*.java")
            }

            copy(todir: classesDir) {
                fileset(dir: sourcesDir, erroronmissingdir: false) {
                    exclude(name: "**/*.java")
                }
            }
        }
    }
}

configurations {
    jaxb
}

jar {
    baseName = 'gs-producing-web-service'
    version =  '0.1.0'
    from genJaxb.classesDir
}
like image 945
Zekik64 Avatar asked Dec 05 '22 19:12

Zekik64


1 Answers

You need to add jaxb as a configuration. This way:

configurations {
   jaxb
}

Could you please provide the whole script? Or project sources?

like image 143
Opal Avatar answered Dec 11 '22 12:12

Opal