Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从build.gradle文件运行WSDLToJava?_Java_Jaxb_Cxf_Wsdl2java - Fatal编程技术网

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

如何从build.gradle文件运行WSDLToJava?,java,jaxb,cxf,wsdl2java,Java,Jaxb,Cxf,Wsdl2java,我能够从命令行成功地运行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.

我能够从命令行成功地运行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”文件运行相同的命令行?我对格拉德尔完全是新手

提前感谢您的帮助。
Pete

虽然有一些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

执行任务虽然有一些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

执行任务最好不要使用普通shell任务,而是使用任务,就像他们在中所做的那样或感谢zap1的建议。最好不要使用普通shell任务,而是使用任务,就像他们在《或感谢你》中所做的那样,zap1的建议将对此进行调查。感谢你1)他上面的建议2)编辑我的问题以使其更清楚。感谢你1)他上面的建议2)编辑我的问题以使其更清楚。