I'd like to pass extraClasses parameter when I generate java2wsdl. Here is my Ant task:
<target name="rews.all" depends="xews.aar">
<echo message="${axis2.classpath}" />
<delete file="${build.dir}/wsdl/XEWS.wsdl" />
<taskdef name="java2wsdl"
classname="org.apache.ws.java2wsdl.Java2WSDLTask"
classpathref="axis2.classpath">
</taskdef>
<java2wsdl className="com.dd.xews.XEWS"
outputLocation="${build.dir}/wsdl/"
targetNamespace="http://xews.dd.com/"
schemaTargetNamespace="http://xews.dd.com">
<classpath>
<pathelement path="${axis2.classpath}"/>
<pathelement location="${build.dir}/classes"/>
<pathelement location="${vendor.dir}/AWS/lib/aws-java-sdk-1.2.1.jar"/>
</classpath>
</java2wsdl>
<copy todir="${build.dir}/" file="${build.dir}/wsdl/XEWS.wsdl"/>
</target>
Tried everything but no luck.
Does anyone know the syntax? How do I add extraClasses here?
Test1 (failed)
This failed with error java2wsdl doesn't support the "extraClasses" attribute:
<java2wsdl className ="com.dd.xews.XEWS"
outputLocation ="${build.dir}/wsdl/"
targetNamespace ="http://xews.dd.com/"
schemaTargetNamespace ="http://xews.dd.com"
extraClasses ="com.dd.xews.XEWS.Emailer.java">
</java2wsdl>
How to find out which attributes java2wsdl Ant task does support?
My Axis2 version is 1.5.4.
Here's a link to the source code of Ant task: Java2WSDLTask.
#setExtraClasses accepts String parameter, and then tries to split it using comma delimiter. So try passing something like
<extraClasses>com.test.Class1,com.test.Class2</extraClasses>
EDIT
This will not work in older versions of Axis2 (to be more precise -- versions prior 1.6.0). It's because of 'extraClasses' attribute was specified as an array-type, which is obviously not supported as Ant task attribute. You can find all the details in this JIRA issue: AXIS2-4634: Ant task Java2WSDLTask does not allow the use of extraClasses
The easiest way to make it work is to upgrade Axis2 JARs to a newer 1.6.x version. If you are stuck with Axis2 version for some project-specific reasons (I don't see there should be any), you could take the source code of Java2WSDLTask from the newer version (see link to GrepCode above), and make a copy of this task in your project (you'll have to use different class name, or package), then use it as an Ant task just like you are using it currently. Except for it will be possible to use 'extraClasses' attribute.
Axis2 1.4 and up support the "-xc" attribute. Here's how I did it:
<java classname="org.apache.ws.java2wsdl.Java2WSDL" fork="true">
....
<arg value="-xc"/>
<arg value="com.example.mypackage.MyClass"/>
<arg value="-xc"/>
<arg value="com.example.anotherpackage.MyOtherClass"/>
....
</java>
Related
I'm currently working on a pde build for a rcp application.
During the build I want to execute a .jar which requires the path to all plugins I use in my rcp application.
The Problem is the plugins all have a version at the end of their name.
e.g.: com.ibm.icu_52.1.1.v201501240615.jar
The .jar does not support wildcards in the argument so I tried using filelist and pathconvert:
<filelist id="plugins.jars"
dir="${eclipse.pdebuild.home}.."
files="com.ibm.icu*.jar,org.eclipse.equinox.simpleconfigurator*.jar"
/>
<pathconvert pathsep=";" property="plugins" refid="plugins.jars"/>
<java jar="Programm.jar"
fork="true"
failonerror="true">
<arg value="${plugins}" />
</java>
The problem with that is that the * won't get resolved.
[java] Info: Setting additionally referenced classes (C:\Program Files (x86)\eclipse_rcp\plugins\com.ibm.icu*.jar;C:\Program Files (x86)\eclipse_rcp\plugins\org.eclipse.equinox.simpleconfigurator*.jar).
[java] Error : Classpath file C:\Program Files (x86)\eclipse_rcp\plugins\com.ibm.icu*.jar does not exist
Does anyone have an idee how I could solve this problem?
Any help is appreciated!
Best regards,
Andi
Use fileset instead :
<fileset dir="${eclipse.pdebuild.home}" id="plugins.jars"
includes="com.ibm.icu*.jar,org.eclipse.equinox.simpleconfigurator*.jar/>
<!-- simple echo -->
<echo>${toString:plugins.jars}</echo>
<pathconvert pathsep=";" property="plugins" refid="plugins.jars"/>
Use ',' or blank as separator for includes.
I have a modular layout of my project sources which are built using ant. After having built the project with javac, I am running (for a particular module) the iajc task to advise binary classes scattered over the inpath that composes binary output directories from my dependency modules:
<iajc destDir="${dest.dir}" >
<inpath refid="modules.binaries.path" />
<classpath>
<path refid="module.classpath" />
</classpath>
<aspectpath refid="aspects.path" />
</iajc>
The problem is that like this the woven output from all the binaries is merged into ${dest.dir} which means that I am losing my modular structure of binaries as a result. But I need it kept in runtime. Not specifying destDir at all has no effect. Is there any way to have the woven classes stay where they are thus overwriting their originals (unwoven) within the inpath?
Thanks for any help or hint on this.
I've ended up with iterating over elements of the path that composes binary directories of the dependency modules. inpath and destDir are being set equal to the current path element at each iteration:
<for param="path.item" >
<path refid="modules.binaries.path" />
<sequential>
<iajc destDir="#{path.item}" >
<inpath>
<pathelement location="#{path.item}" />
</inpath>
<classpath>
<path refid="module.classpath" />
</classpath>
<aspectpath refid="aspects.path" />
</iajc>
</sequential>
</for>
This way classes are being advised in their places by overwriting the original version.
With the GWT compiler, is it possible set pass in properties as arguments to the GWT compiler? I know you can pass in certain defined parameters such as -war and -style, but this is for passing in property values, such as "user.agents" or "locale".
From what I can see of the documentation, the properties can only be set using from within the module descriptor. But I want to be able to control these properties externally, from my build script.
I've tried looking for documentation on what arguments are supported by com.google.gwt.dev.Compile, but there doesn't appear to be any reference documentation for that class. The docs are long on how-tos, and distressingy short on detail.
The answer is no!
I've asked the exact same question in the commiters newsgroup and currently there is nothing available.
They are thinking about adding support of supplying an extra .gwt.xml to override/configure things externally. This would cover what I wanted to do, but if you really want a generic access to the Properties at compile time then I'm afraid this is not possible.
Maybe you should create a Functional Request... let me know I'll put a start on it as well since it would be very usefull to switch on/off certain things from the compiler command line operation.
It does take arguments. An example from an ant build file I wrote:
<target name="compile.gwt" depends="compile">
<java failonerror="true" classname="com.google.gwt.dev.Compiler" fork="true">
<arg value="-war" />
<arg value="${webcontent.dir}" />
<arg value="-style" />
<arg value="obfuscated" />
<arg value="${module.name}" />
<jvmarg value="-Xmx256m" />
<jvmarg value="-Xss64M" />
<classpath>
<path refid="project.class.path" />
<pathelement path="${gwt.home}/gwt-dev-windows.jar" />
</classpath>
</java>
</target>
I think this covers all the flags:
Debugging and Compiling - Google Web Toolkit - Google Code
As far as whether you pass user agents, I haven't seen it, but I haven't looked, either.
If the generator is a custom class, then you can always pass -Dname=value arguments to the java command and access them with System.getProperty("name"). Even if the generator is canned, perhaps you could subclass it and inject/override properties by wrapping the GeneratorContext passed to the superclass and replacing its PropertyOracle.
I have a legacy product, spread across dozens of repositories. I'm currently trying to refactor (and understand...) the given build process. First step was moving from the old version control system to mercurial, which was encouraging and easy.
The build process mainly uses ant build scripts (good news) but has to run 'on' the repository file structure (bad news...) because the ant scripts take files from all repositories and leave artifacts on .. lets say, several places... But that's not a blocker.
Before I trigger the build (now with hudson CI), I have to make sure, that all repositories are updated to the tip or a selected tag. I could write a script/batch or write a custom ant task (again) but, I don't want to ignore existing features (again):
is it possible to update a set of mercurial repositories by using existing ant tasks or mercurial features? All repositories are located in one folder (like /repo) and have a common prefix (like SYSTEMNAME_module) so it's easy to locate them/create a fileset.
The most simple solution today is to start the hg executable from Ant (using the exec task. Note: MacroDef is your friend). Just create a "main" build file in one of the projects, change to the parent directory (where you can access all the local copies) and then update each one.
I found a different ant based solution, based on the 'apply' task:
<apply executable="hg">
<arg value="update" />
<arg value="--verbose" />
<arg value="--revision" />
<dirset dir="/repos" include="REPO_SUFFIX*" />
</apply>
Thanks to Aaron, his very helpful answer showed me the right direction.
I think this would be a more flexible way to update a mercurial depo. From a set of directories it chooses which ones are depots and updates those. Note that you can also do this with the foreach tag of ant contrib but the 'for' seems to consume a lot less memory.
<!-- See if the directory looks like a mercurial depo, if so update it -->
<target name="-mercurial-update">
<dirset dir="${dir.deps}" id="lib.dirs">
<exclude name="build"/>
<present targetdir="${dir.deps}">
<mapper type="glob" from="*" to="*/.hg" />
</present>
</dirset>
<for param="file">
<path>
<dirset refid="lib.dirs"/>
</path>
<sequential>
<echo>Trying to update mercuriali depo #{file}</echo>
<exec executable="hg" dir="#{file}">
<arg line="pull" />
</exec>
<exec executable="hg" dir="#{file}">
<arg line="up" />
</exec>
</sequential>
</for>
</target>
We have an Apache ANT script to build our application, then check in the resulting JAR file into version control (VSS in this case). However, now we have a change that requires us to build 2 JAR files for this project, then check both into VSS.
The current target that checks the original JAR file into VSS discovers the name of the JAR file through some property. Is there an easy way to "generalize" this target so that I can reuse it to check in a JAR file with any name? In a normal language this would obviously call for a function parameter but, to my knowledge, there really isn't an equivalent concept in ANT.
I would suggest to work with macros over subant/antcall because the main advantage I found with macros is that you're in complete control over the properties that are passed to the macro (especially if you want to add new properties).
You simply refactor your Ant script starting with your target:
<target name="vss.check">
<vssadd localpath="D:\build\build.00012.zip"
comment="Added by automatic build"/>
</target>
creating a macro (notice the copy/paste and replacement with the #{file}):
<macrodef name="private-vssadd">
<attribute name="file"/>
<sequential>
<vssadd localpath="#{file}"
comment="Added by automatic build"/>
</sequential>
</macrodef>
and invoke the macros with your files:
<target name="vss.check">
<private-vssadd file="D:\build\File1.zip"/>
<private-vssadd file="D:\build\File2.zip"/>
</target>
Refactoring, "the Ant way"
It is generally considered a bad idea to version control your binaries and I do not recommend doing so. But if you absolutely have to, you can use antcall combined with param to pass parameters and call a target.
<antcall target="reusable">
<param name="some.variable" value="var1"/>
</antcall>
<target name="reusable">
<!-- Do something with ${some.variable} -->
</target>
You can find more information about the antcall task here.
Take a look at Ant macros. They allow you to define reusable "routines" for Ant builds. You can find an example here (item 15).
Also check out the subant task, which lets you call the same target on multiple build files:
<project name="subant" default="subant1">
<property name="build.dir" value="subant.build"/>
<target name="subant1">
<subant target="">
<property name="build.dir" value="subant1.build"/>
<property name="not.overloaded" value="not.overloaded"/>
<fileset dir="." includes="*/build.xml"/>
</subant>
</target>
</project>
You can use Gant to script your build with groovy to do what you want or have a look at the groovy ant task.