2017-04-06 158 views
1

我想从wsdl生成java文件。我尝试使用wsdl2java gradle插件。我定义插件:Gradle wsdl生成

subprojects { 
buildscript{ 
    repositories{ 
     jcenter() 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'no.nils:wsdl2java:0.10' 
    } 
} 


apply plugin: 'java' 
apply plugin: 'eclipse' 
apply plugin: 'maven-publish' 
apply plugin: 'application' 
apply plugin: 'no.nils.wsdl2java' 
.... 
} 

,但我得到这个错误:

> Plugin with id 'no.nils.wsdl2java:no.nils:wsdl2java' not found. 

我检查语法(很多时候是好的)。我为这个插件搜索了一下,它被很多人使用。

有没有人有一个想法是什么问题?

UPD:

我在插件定义的主gradle这个,有三个子项目,在这里我想用这个插件。

我定义的子项目在settings.gradle

include 'project1', 'project2', 'project3' 

我做了一个文件夹和文件build.gradle每个项目。

如果我在子项目中的主build.gradlewsdl2java方法中注释掉apply plugin: 'no.nils.wsdl2java',则gradle可正常工作。

+1

你的代码工作正常,请提供一些更多的信息。 – jmattheis

+0

嗨! Thx为回应,我更新了描述。 – LakiGeri

回答

2

您在subprojects -closure内添加buildscript,那不支持,请参阅this Gradle discussion (Buildscript {} in subprojects {} ignored?)

您不必添加buildscript每一个项目,这是不够的,只是宣称它的根的build.gradle

buildscript{ 
    repositories{ 
     jcenter() 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'no.nils:wsdl2java:0.10' 
    } 
} 

subprojects { 
    apply plugin: 'java' 
    apply plugin: 'eclipse' 
    apply plugin: 'maven-publish' 
    apply plugin: 'application' 
    apply plugin: 'no.nils.wsdl2java' 
    .... 
} 
1

我能得到wsdl2的java在我的工作gradle build with jaxws and ant任务。这里是

apply plugin: 'java' 

repositories { 
    mavenCentral() 
    flatDir { 
     dirs 'lib' 
    } 
} 

configurations { jaxws } 
dependencies { jaxws 'com.sun.xml.ws:jaxws-tools:2.2.6' } 

dependencies { 
    compile 'com.sun.xml.bind:jaxb-impl:2.2.6' 
} 


task generateSCMOrderImportServiceClient{ 
    if(!file("./lib/employee-services-client.jar").exists()) { 

     def rootDir = file("build/wsdlToJava/employee-services-client"); 
     def javaDir = file("${rootDir}/java"); 
     def wsdlJarDir = file("${projectDir}/lib"); 
     def classesDir = file("${rootDir}/classes"); 
     def wsdlDir=file("${projectDir}/src/main/resources/wsdl"); 
     def wsdlFile = file("${wsdlDir}/employee-services.wsdl") 

     doLast{ 
      classesDir.mkdirs() 
      javaDir.mkdirs() 
      wsdlJarDir.mkdirs() 
      copy { 
       from "${wsdlFile}" 
       into "${classesDir}" 
      } 

      ant { 
        taskdef(name: 'wsimport', 
          classname: 'com.sun.tools.ws.ant.WsImport', 
          classpath: configurations.jaxws.asPath) 
        wsimport(keep: true, 
          destdir: classesDir, 
          sourcedestdir: javaDir, 
          extension: "true", 
          verbose: "true", 
          quiet: "false", 
          xnocompile: "false", 
          xendorsed: true, 
          wsdlLocation: "EmployeeServices.wsdl", 
          wsdl: "${wsdlFile}") 
        { 
         binding(dir:"${wsdlDir}", includes:"jaxb-bindings.xml,jaxws-bindings.xml") 
         xjcarg(value: "-XautoNameResolution") 
        } 
      } 

      ant.jar(
        destfile: wsdlJarDir.path + "/employee-services-client.jar", 
        basedir: classesDir 
      ) 
     } 
    } 

} 



compileJava.dependsOn generateSCMOrderImportServiceClient