我有 pom.xml 文件,该文件与 MAVEN 中给定的 apache cxf codegen插件绝对可以正常工作。但是我需要创建我的项目在gradle中,因此我需要在 build.gradle 中使用相同的插件来生成类。
这是我尝试过的。.build.gradle文件看起来像这样
configurations {
jaxb
}
task genJaxb {
ext.sourcesDir = "src/main/generated-sources/jaxb"
ext.classesDir = "src/main/classes/jaxb"
ext.schema = "../app-webapp/src/main/resources/xyz.wsdl"//my wsdl file location in my project
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,
package: "com.model") {
arg(value: "-wsdl")
produces(dir: sourcesDir, includes: "**/*.java")
}
javac(destdir: classesDir, source: 1.8, target: 1.8, 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")
}
}
}
}
dependencies {
compile(files(genJaxb.classesDir).builtBy(genJaxb))
jaxb 'com.sun.xml.bind:jaxb-xjc:2.3.2'
jaxb 'com.sun.xml.bind:jaxb-core:2.3.0.1'
jaxb 'com.sun.xml.bind:jaxb-impl:2.3.2'
compile project(':app-model')
compile project(':app-repository')
compile project(':app-service')
}
尝试此操作后。.我可以看到生成的类,但不能看到 Service 端点接口,该接口必须存在(其中包含 @webservice注释)。但是有了行家,一切都变得越来越 产生... 我可以使用cxf代替Jaxb吗?
这是我的Pom.xml
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>src/main/java-generated</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>src/main/resources/xyz.wsdl</wsdl>
<extraargs>
<extraarg>-frontend</extraarg>
<extraarg>jaxws21</extraarg>
<extraarg>-verbose</extraarg>
</extraargs>
<bindingFiles>
<bindingFile>src/main/resources/jaxws-binding.xml
</bindingFile>
</bindingFiles>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
我希望build.gradle文件中具有相同的插件,该插件应生成所有类,包括服务端点接口