Weblogic WsdlcTask for gradle - gradle

I am looking for the weblogic.wsee.tools.anttasks.WsdlcTask for gradle. All I could find so far was an example for Ant.
Importing the ant script with ant.importBuild "wsdlc_build.xml" works perfectly fine in my gradle build script, but I would prefer writing the task in gradle. Has someone already found a solution for this?
My ant script:
<project name="WebServices" basedir=".">
<property name="build.wls.home" value="C:\User\wls\"/>
<path id="weblogic.tools.path">
<fileset dir="${build.wls.home}/wlserver/server/lib">
<include name="weblogic.jar" />
</fileset>
</path>
<taskdef name="wsdlc" classname="weblogic.wsee.tools.anttasks.WsdlcTask" classpathref="weblogic.tools.path"/>
<target name="build_opera">
<wsdlc failOnError="true"
srcWsdl="WebContent/WEB-INF/wsdls/OperaService.wsdl"
destImplDir="src"
destJwsDir="WebContent/WEB-INF/lib"
packageName="server.opera.webservice.service"
verbose="on" debug="on"
type="JAXWS">
</wsdlc>
</target>
<target name="build_nez">
<wsdlc
failOnError="true"
srcWsdl="WebContent/WEB-INF/wsdls/NezService.wsdl"
destImplDir="src"
destJwsDir="WebContent/WEB-INF/lib"
packageName="server.nez.webservice.service"
srcPortName="NezSoapPort"
type="JAXWS">
</wsdlc>
</target>
<target name="build_nezp">
<wsdlc
failOnError="true"
srcWsdl="WebContent/WEB-INF/wsdls/NezpService.wsdl"
destImplDir="src"
destJwsDir="WebContent/WEB-INF/lib"
packageName="server.nezp.webservice.service"
srcPortName="NezPSoapPort"
type="JAXWS">
</wsdlc>
</target>

Related

How to execute the Environment Variables (env.) from Teamcity in Nant script

I am using TeamCity to build the.Net Solution using Nant script and everything works fine if I hard Code the solution path. I want to use Environment Variables from TeamCity (env.) to be used as Solution Path -->env.solution.path----- C:\a\testteamcity\Demo\deptest.sln inside Nant script test.build file:
<?xml version="1.0"?>
<project name ="first Nant file" default="compile-solution" >
<property name="bin.folder.svn" value="C:\a\testteamcity\Demo\bin123"/>
<property name="bin.folder.sln" value="C:\cicheckout\webapp\bin"/>
<target name="compile-solution">
<exec program="C:\Program Files (x86)\MSBuild\12.0\Bin\Msbuild.exe" verbose="true" >
<arg line="${environment::get-variable('env.solution.path')}" />
<arg value="/p:Configuration=Release" />
</exec>
<copy todir="${bin.folder.sln}" overwrite="true" failonerror="true">
<fileset basedir="${bin.folder.svn}">
</fileset>
</copy>
</target>
</project>
Error:Unexpected token 'Punctuation'.
Expression: ${environment::get-variable(‘env.solution.path’)}
Any Help would be great.Thanks
Create system.solution.path --> C:\a\testteamcity\demo\deptest.sln under System Properties (system.) in Teamcity and in Nant script-->
<?xml version="1.0"?>
<project name ="Build-Solution" default="build-solution" >
<property name="solution.path" value="${system.solution.path}" dynamic="true" unless="${property::exists('solution.path')}"/>
<!-- Build solution -->
<target name="build-solution">
<exec program="C:\Program Files (x86)\MSBuild\12.0\Bin\Msbuild.exe" verbose="true" >
<arg line="${solution.path}" />
<arg value="/p:Configuration=Release" />
</exec>
</target>
</project>

Zipping sub folders into separate zip files

I have a directory structure like this:
Parent
|->A
|->B
|->*
and I need to zip it like so:
Dest
|->A.zip
|->B.zip
|->*.zip
Where the * means that I don't know what are the names of the sub-folders.
How can I do this?
I'm working with a maven project but I don't mind using the antrun plugin
Here is another solution that I like since it doesn't require antcontrib:
<target name="zipContentPackage">
<basename property="dir.name" file="${file_name}"/>
<echo message="Zipping folder: ${dir.name}"/>
<zip destfile="${zip_dir}/${dir.name}.zip" basedir="${file_name}"/>
</target>
<target name="-wrapper-zipContentPackage">
<antcall target="zipContentPackage" inheritAll="true">
<param name="file_name" value="${basedir}" />
</antcall>
</target>
<target name="packageContent">
<delete dir="${zip_dir}"/>
<mkdir dir="${zip_dir}"/>
<subant genericantfile="${ant.file}" target="-zipContentPackage" inheritall="true">
<dirset dir="${content_dir}" includes="*" />
</subant>
</target>
Notes:
I used sagioto's code to illustrate
This isn't the most efficient solution
I ended up using foreach of antcontrib
<target name="init">
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.compile.classpath"/>
</target>
<target name="packageContent" depends="init">
<delete dir="${zip_dir}"/>
<mkdir dir="${zip_dir}"/>
<foreach target="zipContentPackage" param="file_name">
<path>
<dirset dir="${content_dir}" includes="*"/>
</path>
</foreach>
</target>
<target name="zipContentPackage">
<basename property="dir.name" file="${file_name}"/>
<echo message="Zipping folder: ${dir.name}"/>
<zip destfile="${zip_dir}/${dir.name}.zip" basedir="${file_name}"/>
</target>

Maven and Ant Can't run Java - CreateProcess error=206, The filename or extension is too long

When maven via antrun executes this java code I get the dreaded error=206, The filename or extension is too long
<java classname="com.me.api" failonerror="true" fork="true" maxmemory="128m" output="${wsdlFile}.out">
<arg value="${className}" />
<arg value="${name}" />
<arg value="${wsdlFile}" />
<classpath>
<path refid="maven.test.classpath" />
</classpath>
Maven creates lengthy classpaths due to the structure and location of the local maven repo. We need to use a pathing jar.
Convert Classpath into string
Escape windows drive letter (C: = bad \C: = good)
Create manifest only jar with class path attribute
Use the pathing jar instead of the maven compile classpath
<mkdir dir="${classpath-compile.dir}"/>
<!-- Convert into usable string . -->
<pathconvert property="compile_classpath_raw" pathsep=" ">
<path refid="maven.compile.classpath"/>
</pathconvert>
<!-- escape windows drive letters (remove C: from paths -- need to wrap with a condition os.family="windows")-->
<propertyregex property="compile_classpath_prep"
input="${compile_classpath_raw}"
regexp="([A-Z]:)"
replace="\\\\\1"
casesensitive="false"
global="true"/>
<!-- Create pathing Jars -->
<jar destfile="${classpath-compile.jar}">
<manifest>
<attribute name="Class-Path" value="${compile_classpath_prep}"/>
</manifest>
</jar>
<java classname="com.me.api" failonerror="true" fork="true" maxmemory="128m" output="${wsdlFile}.out">
<arg value="${className}" />
<arg value="${name}" />
<arg value="${wsdlFile}" />
<classpath>
<pathelement location="${classpath-compile.jar}" />
</classpath>
Extending the answer provided by #user4386022: You can define (starting with Ant 1.8) this macro which can help you if you have the same problem in different places in your build process (and you cannot just copy-paste the same snippet everywhere because Ant does not allow re-defining properties, so you will get an error saying that "manifest.classpath" is already defined.)
<macrodef name="create-classpath-jar" description="Create classpath Jar, to avoid getting the error about CreateProcess error=206, The filename or extension is too long">
<attribute name="classpathjar"/>
<attribute name="classpathref"/>
<sequential>
<!-- Turn the classpath into a property formatted for inclusion in a MANIFEST.MF file -->
<local name="manifest.classpath.property"/>
<manifestclasspath property="manifest.classpath.property" jarfile="#{classpathjar}">
<classpath refid="#{classpathref}" />
</manifestclasspath>
<!-- Create the Jar -->
<jar destfile="#{classpathjar}">
<manifest>
<attribute name="Class-Path" value="${manifest.classpath.property}"/>
</manifest>
</jar>
</sequential>
</macrodef>
To use the macro in your targets or tasks, then simply use it like this:
<path id="myclasspath">
.........
</path>
<create-classpath-jar classpathjar="classpath-compile.jar" classpathref="myclasspath" />
If using Ant 1.7 or newer you can utilize the manifestclasspath task to generate a manifest file then include it in a jar for use on the javac classpath
<!-- turn the classpath into a property formatted for inclusion in a MANIFEST.MF file -->
<manifestclasspath property="manifest.classpath"
jarfile="${classpath-compile.jar}">
<classpath refid="maven.compile.classpath" />
</manifestclasspath>
<!-- Create pathing Jars -->
<jar destfile="${classpath-compile.jar}">
<manifest>
<attribute name="Class-Path" value="${manifest.classpath}"/>
</manifest>
</jar>
<java classname="com.me.api" failonerror="true" fork="true" maxmemory="128m" output="${wsdlFile}.out">
<arg value="${className}" />
<arg value="${name}" />
<arg value="${wsdlFile}" />
<classpath>
<pathelement location="${classpath-compile.jar}" />
</classpath>
Fixed problem by removing fork="true" from javac target in build.xml file. Please refer to solutions above if forking is mandatory for your build process.

Tomcat reply 401 for ant starttask

I'm following spring tutorial . In that it control tomcat with ant tasks. Earlier I face few problems because of tomcat 7 manager app is different from previous versions. But I was able to fix them. Now ant listtask is working fine. But others are not. For an example ant starttask returns this error.
start-webapp:
BUILD FAILED
C:\Users\rsenarath\workspace\myspringapp\build.xml:108: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/text/start?path=%2Fmyspringapp
But when I copy the url(http://localhost:8080/manager/text/start?path=%2Fmyspringapp) on the browser it asks for username password and it replies as without a problem as follows.
OK - Started application at context path /myspringapp
Can some one help me with this. My build.properties is as below
appserver.name=tomcat
appserver.home=C:/Users/rsenarath/apache-tomcat-7.0.34
appserver.lib=${appserver.home}/lib
appserver.bin=${appserver.home}/bin
deploy.path=${appserver.home}/webapps
tomcat.manager.url=http://localhost:8080/manager/text
tomcat.manager.username=tomcat
tomcat.manager.password=s3cret
and ans tasks are as below
<path id="catalina-ant-classpath">
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"/>
<include name="tomcat-coyote.jar"/>
<include name="tomcat-util.jar"/>
</fileset>
<fileset dir="${appserver.home}/bin">
<include name="tomcat-juli.jar"/>
</fileset>
</path>
<taskdef name="catalina-deploy" classname="org.apache.catalina.ant.DeployTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-list" classname="org.apache.catalina.ant.ListTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-reload" classname="org.apache.catalina.ant.ReloadTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-resources" classname="org.apache.catalina.ant.ResourcesTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-start" classname="org.apache.catalina.ant.StartTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-stop" classname="org.apache.catalina.ant.StopTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-undeploy" classname="org.apache.catalina.ant.UndeployTask" classpathref="catalina-ant-classpath"/>
<target name = "stop-webapp">
<catalina-stop url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${name}"
failonerror="false"/>
</target>
<target name = "start-webapp">
<catalina-start url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${name}"/>
</target>
<target name="list-webapp" description="List Tomcat applications">
<catalina-list url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"/>
</target>
In your start-webapp and stop-webapp targets you use these variables for user/pass:
tomcat.username
tomcat.password
But in your config data you set these:
tomcat.manager.username
tomcat.manager.password
The username and password are therefore probably not set when you run the start-webapp target, hence the 401. Perhaps you could update the variable names in the start and stop targets to match the config.

How to run Sahi tests as part of a Hudson build?

In the absence of a Maven plugin for Sahi, what's the easiest way to run Sahi tests from Hudson?
You do have a tutorial for integrating Hudson with Sahi, but it is based on a free-style project, and a Ant task (as Pascal Thivent commented)
with zkdemo.xml and other Sahi ant tasks detailed here:
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="bids" default="runfftests">
<property environment="env"/>
<property name="sahi.home" value="${env.SAHI_HOME}" location="/mnt/sda4/Sahi/sahi/" />
<property name="user.data" value="${env.SAHI_USERDATA_DIR}" location="/mnt/sda4/Sahi/sahi/userdata" />
<property name="urlbase" value="http://www.google.com/"/>
<taskdef name="sahi" classname="net.sf.sahi.ant.RunSahiTask" classpath="${sahi.home}/lib/ant-sahi.jar"/>
<target name="runfftests">
<antcall target="startsahi"/>
<sleep seconds="4"/>
<sahi suite="${user.data}/scripts/my.suite"
browser="/usr/bin/firefox"
baseurl="${urlbase}"
sahihost="localhost"
sahiport="9999"
failureproperty="sahi.failed"
haltonfailure="false"
browserProcessName="firefox"
threads="3">
</sahi>
<sleep seconds="4"/>
<antcall target="stopsahi"/>
<sleep seconds="4"/>
<antcall target="failsahi"/>
</target>
<target name="failsahi" if="sahi.failed">
<fail message="Sahi tests failed!"/>
</target>
<target name="startsahi" description="start sahi proxy">
<java classname="net.sf.sahi.Proxy" fork="true" spawn="true" dir="${sahi.home}">
<!--<env key="MOZ_NO_REMOTE" value="1"/>-->
<classpath location="${sahi.home}/lib/sahi.jar">
<fileset dir="${sahi.home}/extlib" includes="**/*.jar"/>
</classpath>
<arg value="${sahi.home}" id="basePath"/>
<arg value="${user.data}" id="userdataPath"/>
</java>
</target>
<target name="stopsahi" description="stop sahi server">
<sahi stop="true" sahihost="localhost" sahiport="9999"/>
</target>
</project>
you can use maven Surefire plugin call sahi junit test case, then integrated with Jenkin server

Resources