I have a wsdl and I'd like to generate jax-ws type Java source from it using IBM Websphere version of wsimport. How can I do this in an easy way? wsimport.bat references com.ibm.ws.jaxws.tools.WsImport to do the code generation.
I solved the problem by calling wsimport directly. Just make sure websphereHome is set to the websphere home folder on your machine. Then genDir is the folder where you want the files to be generated to. Finally, wsdlFile is the path to the wsdl used for generation.
task generateWSDL2Java(type:Exec) {
doFirst{
genDir.mkdirs()
}
cmd = websphereHome + '/bin/wsimport.bat -keep -d '+genDir+' '+wsdlFile
commandLine = ['cmd', '/K', cmd]
}
Here's a simple Ant script, using a WebSphere 6.1 runtime (with the WebSphere Feature Pack, which is required for JAX-WS), which I just tested:
<?xml version="1.0" encoding="UTF-8"?>
<project name="JAX-WS Client">
<property name="was.dir" value="C:\Program Files (x86)\IBM\WebSphere\AppServer"/>
<path id="jaxws.gen.classpath">
<fileset dir="${was.dir}/plugins">
<include name="*com.ibm.wsfp.main_6.1.0.jar" />
<include name="*org.apache.axis2_6.1.0.jar" />
<include name="*com.ibm.jaxws.tools_6.1.0.jar" />
<include name="*com.ibm.jaxb.tools_6.1.0.jar" />
</fileset>
<fileset file="${was.dir}/lib/j2ee.jar"/>
</path>
<!-- Ant task definition for wsimport -->
<taskdef classpathref="jaxws.gen.classpath" name="wsimport" classname="com.sun.tools.ws.ant.WsImport"/>
<target name="wsimport">
<wsimport sourcedestdir="./src" destdir="./build" debug="true" verbose="true"
keep="true" wsdl="${wsdlFile}" />
</target>
</project>
If you have RAD 8, here's the InfoCenter article which describes using the JAX-WS Ant tasks from within that. I'm not sure how other WebSphere development environments compare.
JAX-WS artifacts are portable, which means that you are not required to use IBM's tools. BTW, I think that the wsgen and wsimport tools shipped with WAS actually use code from the Sun/Oracle reference implementation.
Therefore you could use any documented solution for Gradle, even if it is not WebSphere specific.
Related
I have an testsuite of API testing in SOAP UI.
I want an HTML report of testcases results. I am using basic SOAP UI version. Give me a solution apart from SOAP UI Pro.
Yes, it is possible to generate Junit Style HTML reports using SoapUI Opensource Edition as well.
All you need to do is the execution of tests has to be done
use Apache-Ant software, more details on installing and configuring here
write build script
Here is the sample build script(build.xml):
Note that modify the SOAPUI_HOME(or define environment variable), soapui project file path, results directory path according to your environment.
<project basedir="." default="testreport" name="ant script for testing soapui project">
<property environment="env"/>
<property name="soapui.project" value="/app/demo-soapui-project.xml"/>
<property name="results.dir" value="/tmp/results"/>
<property name="reports.dir" value="${results.dir}/Reports"/>
<property name="html.dir" value="${reports.dir}/html"/>
<target name="execute.project">
<exec dir="${env.SOAPUI_HOME}" executable="testrunner.sh">
<arg line="-raj -f ${results.dir} ${soapui.project}" />
</exec>
</target>
<target name="testreport" depends="execute.project">
<mkdir dir="${reports.dir}"/>
<junitreport todir="${reports.dir}">
<fileset dir="${results.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${html.dir}" />
</junitreport>
</target>
</project>
and execute following command (run soapui project and generate report):
ant
There is also simple way (i.e., every thing configured and readily available envrionment) if you are willing to use this docker image.
Short video also available there on how to.
I'm using WL 6.2.0.1 and one of our projects contains a Java files inside the WL server directory.
When I do the build for war file through eclipse I follow the following steps:
1- Right click on the project name > Build Project.
2- Right click on the project name > IBM Mobile Application Platform Pattern > Build Worklight EAR file.
Which generates to me the war file and inside it I see the java files.
When I switched to use ANT script to build the WAR file, I can't see the Java files anymore inside the war file:
ANT script:
<?xml version="1.0" encoding="UTF-8"?>
<project name="MobileApp" default="package" basedir="../">
<property name="WL_PATH" value="./buildscripts"/>
<property name="project.name" value="MobileApp"/>
<taskdef resource="com/worklight/ant/defaults.properties">
<classpath>
<pathelement location="${WL_PATH}/worklight-ant6.2/worklight-ant-builder.jar"/>
</classpath>
</taskdef>
<target name="WAR_CREATE">
<war-builder projectfolder="${basedir}/temp/source/${project.name}"
destinationfolder="bin/war"
warfile="bin/MobileApp.war"
classesFolder="classes-folder"/>
</target>
</project>
I'm not sure if I need to add the Java element to the script so it will compile the Java files. but I tried to add <Javac> but didn't work.
I referred to the following URL : https://ant.apache.org/manual/Tasks/javac.html. But Didn't know which one to use.
Any help thanks.
XML
<?xml version="1.0" encoding="UTF-8"?>
<project name="myProject" default="all">
<taskdef resource="com/worklight/ant/defaults.properties">
<classpath>
<pathelement location="cli_install_dir/public/worklight-ant-builder.jar"/>
</classpath>
</taskdef>
<path id="server-classpath">
<fileset dir="..\jars\Resources" includes="worklight-jee-library.jar" />
<fileset dir="..\jars\Resources\dev" includes="**/*.jar" />
</path>
<mkdir dir="bin\classes"/>
<javac
srcdir="${worklight.repositary}\${proj.brcname}\server\java"
classpathref="server-classpath"
destdir="bin\classes"
verbose="true"
includeantruntime="false"
target="1.6"
/>
<target name="all">
<war-builder projectfolder="."
destinationfolder="bin/war"
warfile="bin/project.war"
classesFolder="bin\classes"/>
</target>
</project>
The Above is the XML is used to Create a War file along with java classes.
Note :
In the places of dir , location and srcdir replace the content directory with your Locations.
Unlike when using the Studio which automatically compiles any Java files that reside under the server\ folder, this does not happen when using the Ant task scripts.
You must first compile these files and point to the folder containing the resulting .class files. This pointing is done in the classesFolder attribute in the Ant task script.
For further elaboration see this answer by me: https://stackoverflow.com/a/30302415/1530814
I've been using the Mylyn WikiText User Guide to learn how to convert textile files to Eclipse help but I also want to be able to do this using ant because, ultimately, I want to have many textile files contribute to a single textile file then convert to Eclipse help to enable multiple developers to create help pages with minimal conflicts.
The following ant script should take all *.textile files in the 'doc' folder and convert them to Eclipse help:
<?xml version="1.0"?>
<project name="helpwikitext" default="generate-help">
<property name="wikitext.standalone" value="doc" />
<path id="wikitext.classpath">
<fileset dir="${wikitext.standalone}">
<include name="org.eclipse.mylyn.wikitext.*core*.jar" />
</fileset>
</path>
<taskdef classpathref="wikitext.classpath" resource="org/eclipse/mylyn/wikitext/core/util/anttask/tasks.properties" />
<target name="generate-help" description="Generate Eclipse help from textile source">
<wikitext-to-eclipse-help markupLanguage="Textile" multipleOutputFiles="true" navigationImages="true" helpPrefix="help">
<fileset dir="${basedir}">
<include name="doc/*.textile" />
</fileset>
<stylesheet url="styles/help.css" />
<stylesheet url="styles/main.css" />
</wikitext-to-eclipse-help>
</target>
</project>
I get the following error:
[taskdef] Could not load definitions from resource org/eclipse/mylyn/wikitext/core/util/anttask/tasks.properties. It could not be found.
build.xml:11: Problem: failed to create task or type wikitext-to-eclipse-help
I'm fairly sure that I have all the Mylyn features installed so it looks like the ant script doesn't know where to find them. Does anyone know how to fix this?
Do you have the wikitext standalone package installed in your doc directory?
That is what is expected as you define the path used by the taskdef like this:
<property name="wikitext.standalone" value="doc" />
I'll take a guess that your wikitext package is in a different dir.
You then use the same dir as the root for your textfiles. I would suggest to keep the wikitext standalone package separate from your textfiles.
I am executing lot of scp and sshexec and other remote commands from an ant build script. These commands don't work if jsch.jar isn't in the ant lib directory. To make it work, I copied the JAR into the ant lib directory, but this is not a good solution, as anyone else wanting to run the script would have to do the same thing. To run the ant target from Teamcity, we will have to explicitly set the path of the lib file.
Is there a way I can specify the path of the JAR in the ant build XML itself?
Thanks all for your answers. I am managed to get it work with classloader task. This is what I did.
<project basedir="." >
<property environment="env"/>
<taskdef resource="net/jtools/classloadertask/antlib.xml">
<classpath>
<fileset dir="${basedir}/lib" includes="ant-classloader*.jar"/>
</classpath>
</taskdef>
<!--Add JSCH jar to the classpath-->
<classloader loader="system">
<classpath>
<fileset dir="${basedir}/lib" includes="jsch*.jar"/>
</classpath>
</classloader>
<target name="Test">
<scp todir="user1:pass1#server1:/tmp" trust="true" >
<fileset dir="dir1">
<include name="test.txt" />
</fileset>
</scp>
</target>
</project>
As you can see here, I didn't have to give any dependant target for my "Test" target, it just works. It uses classloader, which appends jsch.jar to the system classloader.
One possible work around would be to use the -lib command line option to tell ant where to look for additional jars. Perhaps you could create a wrapper script that calls ant with this option set.
Another way would be to move the ant-jsch.jar file (this is the jar that comes with ant that defines the tasks, not the jsch.jar file you need to download separately) out of your ant lib directory, and create a taskdef for your ssh task separate to the built in one, then set the classpath for this task to the jsch.jar and the ant-jsch.jar:
<taskdef name="sshexec"
classname="org.apache.tools.ant.taskdefs.optional.ssh.SSHExec">
<classpath>
<pathelement location="jsch-0.1.44.jar"/>
<pathelement location="ant-jsch.jar" />
</classpath>
</taskdef>
I'm not sure this will help you though, since it also involves making changes to the lib directory.
As far as I'm aware, it's not currently possible to specify the extra jars required for the built in tasks in the build file itself in general. There are some special cases, like junit for instance.
To ensure your build is more cross platform I'd suggest using dependency management. The ivy plug-in can automatically install the version of your build's plugin at build-time.
This approach means the last jar you'll ever need to install into your ANT lib is ivy-2.2.0.jar :-)
First declare your project's dependencies in the file ivy.xml
<ivy-module version="2.0">
<info organisation="com.myspotontheweb" module="demo"/>
<configurations>
<conf name="anttask" description="Jars implementing ANT tasks"/>
</configurations>
<dependencies>
<dependency org="com.jcraft" name="jsch" rev="0.1.42" conf="anttask->default"/>
</dependencies>
</ivy-module>
Within your build.xml run ivy and use it to populate a custom classpath based on the ivy configuration:
<target name='init' description='Resolve project dependencies and set classpaths'>
<ivy:resolve/>
<ivy:cachepath pathid="anttask.path" conf="anttask"/>
</target>
Finally, elsewhere in your build declare your ANT tasks using the class path now automatically populated by ivy.
<target name='dosomething' depends="init">
<taskdef name="sshexec"
classname="org.apache.tools.ant.taskdefs.optional.ssh.SSHExec"
classpathref="anttask.path"/>
..
..
</target>
This approach works for all ANT plug-ins, most of which are available in the central Maven repository. The second benefit is that it's easy to upgrade the plug-in versions across all builds.
I want create Ivy Ant tasks in xml editor in IDE (Intellij iDEA) with autocomplete based on xsd , but I cannot find xsd for register XML namespace xmlns:ivy="antlib:org.apache.ivy.ant"
Where I can find it?
I just copied the ivy jar to INTELLIJ_HOME/lib/ant and now intellij can resolve the ivy tasks.
Or import this ant file to your ant project, its actually the first ivy example in ivy documentation, make sure to always depend on install-ivy target, add your ant file to idea in the ant build window and you dont even have to install ivy and idea recognizes ivy tasks.
<property name="ivy.jar.dir" value="${user.home}/.ivy2/jars" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<property name="ivy.install.version" value="2.2.0" />
<target name="check-ivy-installed" unless="INTERN-ivy.jar.exists">
<available property="INTERN-ivy.jar.exists" file="${ivy.jar.file}"/>
</target>
<target name="download-ivy" depends="check-ivy-installed" unless="INTERN-ivy.jar.exists">
<echo message="downloading and installing ivy"/>
<mkdir dir="${ivy.jar.dir}"/>
<!-- download Ivy from web site so that it can be used even without any special installation -->
<get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
<echo message="ivy installed"/>
</target>
<!-- =================================
target: install-ivy
this target is not necessary if you put ivy.jar in your ant lib directory
if you already have ivy in your ant lib, you can simply remove this
target and the dependency the 'go' target has on it
================================= -->
<target name="install-ivy" depends="download-ivy" description="--> install ivy">
<!-- try to load ivy here from local ivy dir, in case the user has not already dropped
it into ant's lib dir (note that the latter copy will always take precedence).
We will not fail as long as local lib dir exists (it may be empty) and
ivy is in at least one of ant's lib dir or the local lib dir. -->
<echo message="Installing ivy"/>
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</target>
To complete Shalom's answer, the location where to add the ivy.jar for the IntelliJ IDEA Community Edition is INTELLIJ_HOME/lib/ant/lib (one more folder to go).
Maybe it also apply to the full version.
might be, there was no xsd in the past time this discussion started, but at least since may 2011 the ivy scheme is well documented at
http://ant.apache.org/ivy/schemas/ivy.xsd
which is linked right from the documentation in http://ant.apache.org/ivy/
so, to start over using the scheme, you just need:
<?xml version="1.0" encoding="UTF-8"?>
<project name="yourproject"
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd"
>
<!-- … -->
I guess this discussion might help you. It appears that there is no xsd for the ivy ant tasks, but Eclipse does autocomplete.
yes, no xsd for ivy ant tasks avialable. but i found the way to make autocomplete in Intellij IDEA
in ant build file need to define additional task:
<property name="ivy.jar.dir" value="C:/Apache/apache-ivy-2.2.0/"/>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant">
<classpath>
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
</classpath>
</taskdef>
XML plugin for jEdit defines AntCompleteTask (ant task) that produces an xml file called ant-complete.xml. The resulting file looks as follows:
<element-list>
<!-- ... -->
<element name="classpath"
content="(fileset|dirset|extdirs|existing|filelist|pathelement|path)">
<attribute name="id" type="ID" />
<attribute name="location" type="CDATA" />
<attribute name="cache" type="(true|false|on|off|yes|no)" />
<attribute name="refid" type="CDATA" />
<attribute name="description" type="CDATA" />
<attribute name="path" type="CDATA" />
</element>
<!-- ... -->
The generated file may be downloaded as XML plugin archive. Open XML.jar and browse to xml/completion directory. It's syntax is defined in xml-completion-info.dtd.
The task code does not contain an explicit license, but it's at least GPL. Anyway you probably don't need to distribute that task, only to use it and this doesn't require any license.
I can't assess the usability of the resulting xml file, but jEdit uses it for autocompletion.