gpt4 book ai didi

java - 如何从 build.gradle 文件运行 WSDLToJava?

转载 作者:太空宇宙 更新时间:2023-11-04 10:58:58 25 4
gpt4 key购买 nike

我能够成功地从命令行运行 WSDLToJava 类,以从 WSDL 生成 JaxB 类。

   java -Xmx128M  
-cp "C:\cxf\apache-cxf-3.1.6\lib\cxf-manifest.jar;
C:\java\jdk1.7.0_80\lib\tools.jar"
-Djava.util.logging.config.file="C:\cxf\apache-cxf-3.1.6
\etc\logging.properties"
org.apache.cxf.tools.wsdlto.WSDLToJava
-d generated -frontend jaxws21 -b C:\Project\jaxb-bindings.xml
C:\Project\Service.wsdl

如何从“build.gradle”文件运行相同的命令行?我对 Gradle 完全陌生。

预先感谢您的帮助。皮特

最佳答案

虽然有一些 Gradle 插件可以实现此功能,但我认为直接通过 JavaExec 任务进行调用同样容易。将以下内容添加到您的 build.gradle 中:

ext.cxfVersion = "3.1.6"

configurations {
wsdl2java
}

dependencies {
wsdl2java("org.apache.cxf:cxf-tools-wsdlto-core:${cxfVersion}")
wsdl2java("org.apache.cxf:cxf-tools-wsdlto-frontend-jaxws:${cxfVersion}")
wsdl2java("org.apache.cxf:cxf-tools-wsdlto-databinding-jaxb:${cxfVersion}")
}

task wsdl2java(type: JavaExec) {
main = "org.apache.cxf.tools.wsdlto.WSDLToJava"
classpath = configurations.wsdl2java
// Uncomment to add JVM arguments if necessary (e.g. for cert-based security)
//jvmArgs = [
// "-Djavax.net.ssl.keyStore=${keystorePath}",
// "-Djavax.net.ssl.keyStorePassword=${keystorePassword}"
//]
args = [
"-d", "src/gen/java",
"example.wsdl"
// Uncomment and remove the previous line to run for multiple WSDL files
//"-wsdlList, "wsdls.txt"
]
}

// If you want to be able to debug the wsdl2java task from Eclipse, add the following
//eclipse {
// classpath {
// plusConfiguration += [configurations.wsdl2java]
// }
//}

通过运行gradlew wsdl2java来执行任务。

关于java - 如何从 build.gradle 文件运行 WSDLToJava?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47111490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com