ANT Gradle - Axis WSDL 2 Java:没有这样的属性:类的轴:org.gradle.api.internal

时间:2014-05-28 20:54:05

标签: ant wsdl gradle axis wsdl2java

我在ANT build.xml中有以下代码,它将WSDL转换为Java。它工作并使用axis-ant.jar 1.4.0

  <!-- Build generated jars -->
  <target name="axis-WSDL-2-Java" depends="init">
    <taskdef resource="axis-tasks.properties" classpathref="axis.classpath" />
    <axis-wsdl2java
       output="${build.gen.src}"
       testcase="true"
       verbose="true"
       url="${build.src.wsdl.v1}/${build.ws.wsdlfile}" >
    </axis-wsdl2java>


   <!-- Compile artifacts -->
     <echo message="Compiling WS artifact source for Axis..." />
     <javac destdir="${build.gen.classes}" debug="true" >
         <src path="${build.gen.src}" />
            <classpath>
               <pathelement path="${build.lib.3rdParty}" />
               <path refid="axis.classpath" />
            </classpath>
     </javac>

    <jar .... some jar code here...
    </jar>
  </target>



现在,我将构建脚本转换为Gradle,并提供了以下Gradle代码snap ..

//wsdl to java
task axisWSDLTojava() << {
       println "-- Inside axisWSDLToJava"
       def flGen = new File( "$project.buildDir/thidsGen/src" )
       flGen.mkdirs()
       flGen =  new File( "$project.buildDir/thidsGen/classes" )
       flGen.mkdirs()

       ant {
            taskdef(
            resource: 'axis-tasks.properties',
            classpath: configurations.axisAnt.asPath )
            axis-wsdl2java(
              output: "$project.buildDir/thidsGen/src",
              testcase: "true",
              verbose: "true",
              url: "$projectDir/src/ws/v1/wsdl/MDSSFileInfo.wsdl")
       }
}

//compile generated src to classes
task compileJavaWsArtifacts (type: JavaCompile, dependsOn: axisWSDLTojava) << {
       println "-- Inside compileGenSrc"
       source = "$project.buildDir/thidsGen/src"
       classpath = configurations.axisAnt.asPath
       destinationDir = "$project.buildDir/thidsGen/classes"
}
// Build jar with web service artifacts
task jarWsArtifacts( type: Jar, dependsOn: compileJavaWsArtifacts ) << {
   println "-- Inside jarWsArtifacts"
   // some code here
   // some code here to create the jar etc
}



用于调用相应任务的Gradle逻辑全部设置,即我在CompileJava Gradle任务中将上述任务称为dependsOn。

// Compile java server components - must have artifacts first
compileJava {
   dependsOn jarWsArtifacts
}

Gradle中的配置部分定义为:

// Custom configurations
configurations {
   axisAnt
}
Gradle中的

依赖关系部分定义为:

// Define dependencies
dependencies {
   // Compilation
   //compile 'groupid:artifactid:x.x.x'
   //compile 'groupid:artifactid:x.x.x@yyy'
   //other bunch of dependencies... come here which are required for compile task in Gradle

   //axis-wsdl2java generates java files, which generates class files and jard into a -ws.jar file
   compile  fileTree( dir: 'build/resultantJar', include: "$ProjectName-ws-*.jar" )

   // Unit Tests
   testCompile 'xxx:yyy:x.x.x'
   testCompile 'xxx:yyy:x.x.x'
   //more artifacts for testCompile..

   // Integration tests
   // Everything from compile and testCompile targets
   integrationTestCompile configurations.compile
   integrationTestCompile configurations.testCompile

   // Output of compiling "main" files
   integrationTestCompile sourceSets.main.output

   // Additional dependencies from war and others
   integrationTestCompile 'xxx:yyy:x.x.x'
   integrationTestCompile 'xxx:yyy:x.x.x'
   //other enteries for IT test task 

   // All configuration files in conf folder in source control required for IT tests.
   integrationTestRuntime files( 'conf' )

   //Axis-ANT
   axisAnt 'axis:axis-ant:1.4.0'
   axisAnt 'othergroupid:otherartifactid:x.x.x'
   axisAnt 'othergroupid:otherartifactid:x.x.x'
   // comes here which are required for axis-wsdl2java to work
}

但是,在运行&#34; gradle clean build&#34;时,我收到以下错误消息:

:axisWSDLTojava FAILED

FAILURE: Build failed with an exception.

* Where:
Build file '/production/jenkinsAKS/workspace/DFDailyFeedSvc/build.gradle' line: 90

* What went wrong:
Execution failed for task ':axisWSDLTojava'.
> No such property: axis for class: org.gradle.api.internal.project.DefaultAntBuilder
  Possible solutions: ant

任何想法,为什么它无法看到axis-wsdl2java(我看到如果在axis-ant.jar 1.4.0版本中的 axis-tasks.properties 文件中定义为以下:)

#properties file for taskdefing the public Axis taskdefs

axis-wsdl2java=org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask
axis-java2wsdl=org.apache.axis.tools.ant.wsdl.Java2WsdlAntTask
axis-admin=org.apache.axis.tools.ant.axis.AdminClientTask

1 个答案:

答案 0 :(得分:2)

好的,已经解决了。

在Gradle代码中更改以下内容就可以了。不知道为什么没有双引号方式Gradle没有选择它。原因:在Java / Groovy中(Gradle使用Groovy),你的名字中不能有一个带“ - ”的函数(你可以有giga_fifa而不是giga-fifa)。很高兴,使用“”解决了它。

axis-wsdl2java( 

"axis-wsdl2java"(

其他的事情,无论我在哪里使用“$ project.buildDir ..我将其更改为$ buildDir,因为ANT抱怨找不到project.buildDir,或者以$ project.buildDir格式编写时找不到buildDir。使用$ buildDir解决了这些问题。

另外,compileJavaWsArtifacts没有看到生成的src文件!即使在Gradle构建中的wsdl2java操作之后成功生成了。所以,shenzi是否使用以下代码:

//compile generated src to classes
//task compileJavaWsArtifacts (type: JavaCompile, dependsOn: axisWSDLToJava) << {
//       source = "$buildDir/thidsGen/src"
//       classpath = configurations.axisAnt.asPath
//       destinationDir = "$buildDir/thidsGen/classes"
//}

//compile generated src to classes
task compileJavaWsArtifacts (dependsOn: axisWSDLToJava) << {
   ant {
      javac( destdir: "$buildDir/thidsGen/classes", debug: 'true', includeAntRuntime: 'no', classpath: configurations.axisAnt.asPath ) {
         src( path: "$buildDir/thidsGen/src" )
      }
   }
}