Ant taskdef jwsc/wsdlc/clientgen to Gradle Migration

I am new to Gradle and am trying to migrate components from Ant to Gradle 6.0. I ran into the following tags stopping.


<taskdef name='wsdlc' classname='weblogic.wsee.tools.anttasks.WsdlcTask'>
    <classpath refid='all_libraries'/>
</taskdef>

<taskdef name='clientgen' classname='weblogic.wsee.tools.anttasks.ClientGenTask'>
    <classpath refid='all_libraries'/>
</taskdef>

<target name='generate_bss_eai_stubs'>
	<wsdlc srcWsdl='wsdl/X2YServices.wsdl' destJwsDir='jar_jws'
           destImplDir='${source_dir}' packageName='prova.webservice'/>
</target>

<target name='build_war'>
    <mkdir dir='${war_dir}'/>
    <jwsc srcdir='${source_dir}' destdir='${war_dir}' classpathref='all_libraries'>
        <jws file='prova/webservice/X2YServicesImpl.java'
             compiledWsdl='jar_jws/X2YServices_wsdl.jar'/>
    </jwsc>
....
</target>

Could anyones help me?

Thanks a lot

You can call ant from Gradle, try reading through the Gradle Ant documentation and apply it to your build and come back with further questions

Hi,
you are right. I tried using it and I write the following build gradle

configurations {
  antJwsc
  jwsc
}

repositories {
    mavenCentral()
}

dependencies {
  antJwsc 'com.oracle.weblogic:weblogic-maven-plugin:12.1.3-0-0'
}

task prova {
    doLast {
        ant.taskdef(name: 'jwsc',
                    classname: 'weblogic.wsee.tools.anttasks.JwscTask',
                    classpath:  configurations.antJwsc.asPath)
        ant.jwsc (
    		srcdir : '${source_dir}',
    		destdir : '${war_dir}',
    		debug : 'true',
    		classpath : configurations.jwsc.asPath{
				module (name : 'warname') {
				jws file: 'prova/webservice/X2YServicesImpl.java.java'
				descriptor file: 'WebContent/WEB-INF/web.xml'
				descriptor file: 'WebContent/WEB-INF/weblogic.xml'
				}
			}
  		)
    }
}

but it does not work. the dependency is not good. It seems that the jar is not correct. Do you have any suggestion?

It seems that the dependency you are attempting to use doesn’t contain the ant task in it. It looks like you’re using a maven plugin rather than an ant plugin.

How do you add the ant task to the classpath in your ant build? Have you added a weblogic jar to $ANT_HOME/lib?

You can use the following script to run through the jars looking for the ant task. I’m guessing all the jars report found = false

def findMe = 'weblogic/wsee/tools/anttasks/JwscTask.class'
configurations.jwsc.each { file ->
   def paths = [] as Set
   zipTree(file).visit { fvd ->
      paths << fvd.path
   }
   def found = paths.contains(findMe)
   println "Found $findMe in $file = $found" 
}

It seems that the dependency you are attempting to use doesn’t contain the ant task in it. It looks like you’re using a maven plugin rather than an ant plugin.
You’re right, I tried to use the plugin as maven as it is my first experience with Gradle and it seemed closer to Maven than to ANT

How do you add the ant task to the classpath in your ant build? Have you added a weblogic jar to $ANT_HOME/lib?
I already have the weblogic jars (weblogic.jar, webserviceclient.jar, webservices.jar) inside the ANT lib but I would like to understand which specific jars I need to punt into the gradle dependency in order to run the JWSC task.

You can use the following script to run through the jars looking for the ant task. I’m guessing all the jars report found = false.
I dont’ have results, neither positive nor negative running the script reported below

You could put weblogic.jar, webserviceclient.jar, webservices.jar in $projectDir/lib directory then do.

dependencies {
  antJwsc fileTree('lib')
}

It seems to have unlocked that step but I caught another mistake

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘C:\webservice\build.gradle’ line: 95

  • What went wrong:
    Execution failed for task ‘:prova’.

Could not find method asPath() for arguments [build_7uaczx29ubeumwahgj7bgyhpw$_run_closure8$_closure16$_closure17@512a7ba7] on configuration ‘:jwsc’ of type org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.

  • Try:
    Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:prova’.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:187)
    at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:263)

the build gradle draft is

task prova {
doLast {
ant.taskdef(name: ‘jwsc’,
classname: ‘weblogic.wsee.tools.anttasks.JwscTask’,
classpath: configurations.antJwsc.asPath)
ant.jwsc (
srcdir : ‘{source_dir}', destdir : '{war_dir}’,
debug : ‘true’,
classpath : configurations.jwsc.asPath{ /this is 95 Line/
module (name : ‘warname’) {
jws file: ‘prova/webservice/X2YServicesImpl.java’
//type: ‘JAXWS’
descriptor file: ‘WebContent/WEB-INF/web.xml’
descriptor file: ‘WebContent/WEB-INF/weblogic.xml’
}
}
)
}
}

Am I wrong in something?

You’ve accidentally put “{” where it should be “)”

You want

ant.taskdef(
   name: 'jwsc',
   ... 
   classpath :configurations.jwsc.asPath
) 

Instead of

ant.taskdef(
   name: 'jwsc',
   ... 
   classpath :configurations.jwsc.asPath
{

You are right. I change it. Sorry for my mistake.
I run the gradle script and I catch this one error

Task :checkJwsc FAILED
[ant:jwsc] warning: ‘includeantruntime’ was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘C:\workspaceTeliaSweden\cli_default_repository\eai_bss\bss_eai_webservice\build.gradle’ line: 109

  • What went wrong:
    Execution failed for task ‘:checkJwsc’.

Could not find method module() for arguments [{name=warname}, build_7uaczx29ubeumwahgj7bgyhpw$_run_closure7$_closure15$_closure16@75780fd8] on task ‘:checkJwsc’ of type org.gradle.api.DefaultTask.

  • Try:
    Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:checkJwsc’.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:187)
    at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:263)

What do you mean? Am I wrong anything else?

the build gradle draft is the following

task checkJwsc {
doLast {
ant.taskdef(name: ‘jwsc’,
classname: ‘weblogic.wsee.tools.anttasks.JwscTask’,
classpath: configurations.antJwsc.asPath)
ant.jwsc (
srcdir : ‘src’,
destdir : ‘war_dir’,
debug : ‘true’,
classpath : configurations.jwsc.asPath)
module (name : ‘warname’) {
jws file: ‘/webservice/X2YServicesImpl.java’
descriptor file: ‘WebContent/WEB-INF/web.xml’
descriptor file: ‘WebContent/WEB-INF/weblogic.xml’
}
}
}

Do you have also any info about the following task

<taskdef name='wsdlc' classname='weblogic.wsee.tools.anttasks.WsdlcTask'>
    <classpath refid='all_libraries'/>
</taskdef>

Thanks a lot

I’m guessing that you want

ant.jwsc (
   srcdir : ‘src’,
   ..., 
   classpath : configurations.jwsc.asPath
) {
   module (name : ‘warname’) {...} 
   ... 
} 

Good Thanks a lot @Lance.
Do you have any suggestion about

I migrate it into the following task

task checkWsldc {
doLast {
ant.taskdef(name: ‘wsdlc’,
classname: ‘weblogic.wsee.tools.anttasks.WsdlcTask’,
classpath: configurations.antWsdlc.asPath)
ant.jwsc (
srcWsdl=‘src/wsdl/X2YServices.wsdl’
destJwsDir=‘jar_jws’
destImplDir=‘src/checkWsldc’
packageName=‘prova.webservice’
classpath : configurations.wsdlc.asPath)
}
}

I catch the following error
Execution failed for task ‘:checkWsldc’.

Could not find method prova.webservice() for arguments [{classpath=}] on task ‘:checkWsldc’ of type org.gradle.api.DefaultTask.

For sure I am wrong something. What do you mean?

Thanks a lot

ant.jwsc (
srcWsdl='src/wsdl/X2YServices.wsdl' 
destJwsDir='jar_jwsv
destImplDir='src/checkWsldc' 
packageName='prova.webservice' 
... 

Should be

ant.jwsc (
srcWsdl:‘src/wsdl/X2YServices.wsdl’, 
destJwsDir:'jar_jws’, 
destImplDir:‘src/checkWsldc’, 
packageName:‘prova.webservice’, 
... 

Please read the Gradle Ant docs again

Yes, you are right and sorry for the disturb.

task checkJwsc {
doLast {
ant.taskdef(name: ‘jwsc’,
classname: ‘weblogic.wsee.tools.anttasks.JwscTask’,
classpath: configurations.antJwsc.asPath)
ant.jwsc (
srcdir : ‘src’,
destdir : ‘war_dir’,
debug : ‘true’,
classpath : configurations.jwsc.asPath)
{
module (name : ‘warname’) {
jws file: ‘webservice/X2YServicesImpl.java’
compiledWsdl=‘jar_jws/X2YServices_wsdl.jar’
descriptor file: ‘config/web.xml’
descriptor file: ‘config/weblogic.xml’
}
}
}
}

After the gradle checkJwsc --stacktrace
I catch the following error

  • What went wrong:
    Execution failed for task ‘:checkJwsc’.

weblogic.wsee.tools.WsBuildException: JWS build failed.

  • Try:
    Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:checkJwsc’.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:187)
    at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:263)

I’m afraid I’m quitting my role as your compiler

1 Like

Hi,
I added the antJwsc configuration
configurations {
antJwsc
jwsc
}
to make the checkJwsc task

task checkJwsc {
doLast {
ant.taskdef(name: ‘jwsc’,
classname: ‘weblogic.wsee.tools.anttasks.JwscTask’,
classpath: configurations.antJwsc.asPath)
ant.jwsc (
srcdir : ‘src’,
destdir : ‘lib’,
debug : ‘true’,
classpath : configurations.jwsc.asPath)
{
module (name: ‘x2y_webservice’) {
jws file: ‘webservice/X2YServicesImpl.java’,
compiledWsdl: ‘jar_jws/X2YServices_wsdl.jar’
}
}
}
}

I would like to try to add in the dependencies a set of jars contained in different folders as follows
dependencies {
antJwsc fileTree(dir: thirdpartyLibDir + ‘/beawebservices/lib’) { include ‘.jar’ }
antJwsc fileTree(dir: thirdpartyLibDir + ‘/EAI/18_1_449’) { include '
.jar’ }
antJwsc fileTree(dir: thirdpartyLibDir + ‘/bea/lib/12_1_3’) { include ‘wlfullclient.jar’}
antJwsc fileTree(dir: thirdpartyLibDir + ‘/apache/lib/httpcomponents-client-4.2.1/lib’) { include ‘*.jar’ }
antJwsc fileTree(dir: commonLibDir+ ‘/library/eai_common.jar’)
antJwsc fileTree(dir: commonLibDir+ ‘/library/nso_eai_client.jar’)
}
but it doesn’t seem to work. Looks like I need to add the jars one at a time as below

dependencies {
antJwsc fileTree(dir: thirdpartyLibDir + ‘/beawebservices/lib/apache_xbean.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/beawebservices/lib/weblogic.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/beawebservices/lib/xbean.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/bea/lib/12_1_3/wlfullclient.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/beawebservices/lib/webserviceclient.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/beawebservices/lib/webservices.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/beawebservices/lib/webserviceclient+ssl.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/beawebservices/lib/ant.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/beawebservices/lib/jsafe.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/beawebservices/lib/weblogic-container-binding.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/apache/lib/httpcomponents-client-4.2.1/lib/commons-codec-1.6.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/apache/lib/httpcomponents-client-4.2.1/lib/commons-logging-1.1.1.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/apache/lib/httpcomponents-client-4.2.1/lib/fluent-hc-4.2.1.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/apache/lib/httpcomponents-client-4.2.1/lib/httpclient-4.2.1.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/apache/lib/httpcomponents-client-4.2.1/lib/httpclient-cache-4.2.1.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/apache/lib/httpcomponents-client-4.2.1/lib/httpcore-4.2.1.jar’)
antJwsc fileTree(dir: thirdpartyLibDir + ‘/apache/lib/httpcomponents-client-4.2.1/lib/httpmime-4.2.1.jar’)
antJwsc fileTree(dir: commonLibDir+ ‘/library/eai_common.jar’)
antJwsc fileTree(dir: commonLibDir+ ‘/library/nso_eai_client.jar’)
}
Is it possible to add several folders?

Thanks a lot

Half the time you are passing a directory into Project.fileTree(...) and the other half you are passing a single jar file. You want to use Project.files(...) for individual files.

Eg:

ext {
   dir1 = 'path/to/dir1'
   dir2 = 'path/to/dir2' 
}
dependencies {
   antJwsc fileTree("$dir1/lib") { include '*.jar' } 
   antJwsc files("$dir2/jar1.jar", "$dir2/jar2.jar")
   antJwsc files("$dir2/jar3.jar")
} 

See Project.files(…)