I have a java project that using java 1.7 features, I wanted to generate a JDiff doc with two versions of this project, my ant build.xml is this:
<?xml version="1.0" encoding="UTF-8"?>
<project name="jdiff" default="jdiff_report" basedir=".">
<target name="jdiff_report" depends="">
<property name="JDIFF_HOME" value="/Users/Desktop/diffSource/jdiff-1.1.1" />
<taskdef name="jdiff" classname="jdiff.JDiffAntTask" classpath="${JDIFF_HOME}/antjdiff.jar" />
<jdiff destdir="./" verbose="off" stats="off" docchanges="on">
<old name="Project.previous">
<dirset dir="/Users/Desktop/diffSource/docs/old"
includes="com/**"/>
</old>
<new name="Project.current">
<dirset dir="/Users/Desktop/diffSource/docs/new"
includes="com/**"/>
</new>
</jdiff>
</target>
</project>
This is all in build.xml.
But when I run ant, I got this log messages:
warning: [options] bootstrap class path not set in conjunction with -source 1.5
[Javadoc for Project.previous] /Users/Desktop/diffSource/docs/old/com/java/A/B.java:194: error: diamond operator is not supported in -source 1.5
Since there are errors, I can't get corresponding xml of java classes for JDiff to compare. I've seen that jdiff doesn't accept a target attribute, so how can I tell ant to use java 1.7 for this task?
It appears that the JDiff Ant task supports a source attribute that configures the task for a specific version of Java. For example:
<jdiff destdir="./" verbose="off" stats="off" docchanges="on" source="1.7">
...
</jdiff>
In the above example, source="1.7" configures JDiff so it can handle Java 1.7 code.
If you are working with maven repos you could use spf4j-jdiff-maven-plugin
you can easily use it from Ant by executing the command:
<exec executable="java">
<arg value="-jar"/>
<arg value="spf4j-jdiff-maven-plugin-8.5.6-uber.jar"/>
<arg value="-gId"/>
<arg value="artfGroupId"/>
<arg value="-aId"/>
<arg value="artifactId"/>
<arg value="-fromVersion"/>
<arg value="1.0"/>
<arg value="-toVersion"/>
<arg value="3.0"/>
<arg value="-o"/>
<arg value="target/destination"/>
</exec>
It will generate the API diff report between the versions you specify from a maven repo.
Related
Here is my problem.
I have a #env tag on feature level to identify which env to run on, and #current tag on scenario level to identify its the one to be run.
Feature files are placed under different folders (depending on the env) and I have used #Cucumberoptions to set the tag specific feature file path.
All good till here.
But when I run the feature files, it picks up all the scenarios with the #current tag irrespective of the feature file tag.
For E.G. I had added only #Env1 and #Env2 in the cucumber options, but it picks up #Env3 features as well and runs them. How do I stop cucumber to run feature files not mentioned in the #cucumberOptions?
Here is the ANT target code:
<java classname="cucumber.api.cli.Main" fork="true" failonerror="false" resultproperty="cucumber.exitstatus">
<sysproperty key="log4j.configuration" value="file:///${basedir}/log4j.conf"/>
<classpath refid="classpath"/>
<arg value="--monochrome"/>
<arg value="--format"/>
<arg value="junit:target/cucumber-junit-report/allcukes.xml"/>
<arg value="--format"/>
<arg value="pretty"/>
<arg value="--format"/>
<arg value="html:target/cucumber-html-report"/>
<arg value="--glue"/>
<arg value="src.test.cucumber.userlevel"/>
<arg value="features"/>
<arg value="--tags" />
<arg value="#current"/>
<arg value="--tags" />
<arg value="~#obsolete" />
<arg value="--tags" />
<arg value="~#business" />
</java>
Any responses would be appreciated.
Thanks.
Need to use a AND, OR combination in the tag filter expression to make this work. Not too sure about how to run Cucumber from Ant so including tag filters in cucumberoptions and from cli.
For cucumberoptions -> tags={"#Env1,#Env2","#Current"}
For CLI -> --tags #Env1,#Env2 --tags #Current
For Ant ->
<arg value="--tags" />
<arg value="#Env1,#Env2"/>
<arg value="--tags" />
<arg value="#Current" />
I am using ANT to precompile handblebars in build time. I follow the way here http://blog.selvakn.in/2012/05/precompiling-handlerbars-tempates-with.html. And for only one target, it works very well. But then I try to invoke the target twice like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><project basedir="." default="echoIt" name="precompile">
<property name="charset" value="utf-8"/>
<target name="echoIt">
</target>
<target name="precompile-templates0" depends="echoIt">
<property name="outputJS" value="../../jsp/jsp_1/js/templates0.js"/>
<property name="templatesPath" value="../../jsp/jsp_1/js/tmpl"/>
<java dir="${basedir}" failonerror="true" fork="true" jar="../../lib/js.jar">
<arg value="../../otherFiles/lib/rhino-handlebars-compiler.js"/>
<arg value="--handlebars"/>
<arg value="../../otherFiles/third-party/handlebars-v1.3.0.js"/>
<arg value="--templates"/>
<arg value="${templatesPath}"/>
<arg value="--output"/>
<arg value="${outputJS}"/>
</java>
<echo>Template Precompiled to web/js/compiled-templates.js</echo>
<echo> is now ready to compress....</echo>
</target>
<target name="precompile-templates1" depends="echoIt">
<property name="outputJS" value="../../jsp/jsp_2/js/templates1.js"/>
<property name="templatesPath" value="../../jsp/jsp_2/js/tmpl"/>
<echo> is now precompiling the second one </echo>
<java dir="${basedir}" failonerror="true" fork="true" jar="../../lib/js.jar">
<arg value="../../otherFiles/lib/rhino-handlebars-compiler.js"/>
<arg value="--handlebars"/>
<arg value="../../otherFiles/third-party/handlebars-v1.3.0.js"/>
<arg value="--templates"/>
<arg value="${templatesPath}"/>
<arg value="--output"/>
<arg value="${outputJS}"/>
</java>
<echo>Template Precompiled to web/js/compiled-templates.js</echo>
<echo> is now ready to compress....</echo>
</target></project>
The output on the console is like this:
Buildfile: F:\AffirmedNetworks\ServerAutomation\cache\subBuildTarget\precompileTarget.xml
echoIt:
precompile-templates0:
[echo] Template Precompiled to web/js/compiled-templates.js
[echo] is now ready to compress....
echoIt:
precompile-templates1:
[echo] is now precompiling the second one
[echo] Template Precompiled to web/js/compiled-templates.js
[echo] is now ready to compress....
BUILD SUCCESSFUL
Total time: 2 seconds
As you can see, the build is successful. However when I check the outputs in the expected directory, only a ‘templates0.js’ is generated in the path:jsp/jsp_1/js/. There is nothing in the path: jsp/jsp_2/js/. However, it should have on named 'templates1.js' in this folder. This is really weird. No errors occurred and the first on is generated successfully, but the second one disappeared. Can someone give me some help on this? Thanks!
the issue is in your re-use of the <property> task!
Properties are immutable: whoever sets a property first freezes it for the rest of the build; they are most definitely not variables. i.e. once you assign a value to an identifier using <property>, it cannot be changed. See HERE
although, you set the values to outputJS and templatesPath within both targets separately, maybe assuming/expecting local scope, that is not the case in ant.
reason: In general properties are of global scope, i.e. once they have been defined they are available for any task or target invoked subsequently
exception: it is not possible to set a property in a child build process created via the ant, antcall or subant tasks and make it available to the calling build process
therefore, the values for outputJS and templatesPath, as defined in the target precompile-templates0, are retained throughout the build.
to solve your issue, you may do either of the following:
change property names, for eg to outputJS1 and templatesPath1 in the target precompile-templates1
(if you're using Ant 1.8.0 or above) use the <local> task instead of the <property> task for declaring outputJS and templatesPath. See HERE for this.
use the <var> task of ant-contrib. See ant-contrib and var task.
My program was previously used JDK 1.4 . Now I want to use 1.6 to compile it . It was successfully compile against the 1.4 but when I change JDK to 1.6 It gives following compilation error.
[javac] symbol : constructor StartTagInfo(java.lang.String,java.lang.String,java.lang.String,org.xml.sax.helpers.At
tributesImpl,com.abc.jaxb.ssdclm.impl.runtime.MSVValidator)
[javac] location: class com.sun.msv.util.StartTagInfo
[javac] StartTagInfo sti = new StartTagInfo(
But I have the jaxb-libs-jwsdp-1.6 jar in my class path which contains StartTagInfo class with above constructor.
If anyone have an idea of this issue, please advice me. thanks.
I suspect that due to change in JDK version, there would be one of the support lib jar's version has become incompatable. Worst could be that it may be a native lib jar.
I am not providing a solution of current issue. But providing another approach. If you can not change your code with this approach, let me know ; we will try to find issue with existing java upgrade.
With Java 1.6, the JWSDP pack is not longer required. Java 1.6 version comes with inbuilt JAXB version and hence one can directly use it.
Java 1.6 version comes with “xjc” compiler to generate java objects from xml.
Usage: xjc [-options ...]
Below code snippet shows on how the xjc compiler of of 1.6 can be used in the ant script to generate the java objects form XML file.
The below ant target will compile the xsd files test1.xsd and test2.xsd and will create the java objects from xsd into folder output/java
<target name=”xsd2java” description=”Generate java model from XSD xml schema using XJC compiler.”>
<echo message=”Generating java files from XSD using XJC compiler…” />
<mkdir dir=”output/java”/>
<exec executable=”xjc”>
<arg value=”-d”/>
<arg value=”output/java”/>
<arg value=”test1.xsd”/>
<arg value=”test2.xsd”/>
</exec>
</target>
The below code snippet shows how to compile Java objects from dtd files.
<div><macrodef name=”dtd2java”>
<attribute name=”dtdDir”/>
<attribute name=”dtdFile”/>
<attribute name=”javaPackage”/>
<attribute name=”javaDir”/>
<sequential>
<mkdir dir=”output/java/#{javaDir}”/>
<exec executable=”xjc”>
<arg value=”-d”/>
<arg value=”${output.dir}/java”/>
<arg value=”-p”/>
<arg value=”#{javaPackage}”/>
<arg value=”${output.dir}/java/#{javaDir}”/>
<arg value=”-extension”/><arg value=”-dtd”/>
<arg value=”#{dtdDir}/#{dtdFile}”/>
</exec>
</sequential>
</macrodef>
<target name=”dtd2java” description=”Generate java model from DTD using XJC2 compiler.” >
<echo message=”Generating java files from DTD using XJC2 compiler…”/>
<dtd2java dtdDir=”test/dtd” dtdFile=”test1.dtd” javaPackage=”com.test1.dtd” javaDir=”com/test1/dtd”/>
<dtd2java dtdDir=”test/dtd” dtdFile=”test2.dtd” javaPackage=”com.test2.dtd” javaDir=”com/test2/dtd”/>
</target>
</div>
I've followed http://www.eclipse.org/equinox/documents/quickstart-framework.php but it seems to be old and not valid.
There is no such bundles as described org.eclipse.update.configurator_3.2.100.jar
I tried with the org.eclipse.equinox.simpleconfigurator_1.0.200.v20100503, but doesn't work.
Anyone can tell me how to make Equinox auto load the bundles inside plugins folder?
Simplest approach would be to use Apache Felix File Install. It works just fine with Equinox, you only need to put File Install configuration parameters into the configuration/config.ini. Note though that if you launch Equinox via launcher JAR or via binary, the working directory would be parent of configuration/ or plugins/ directory.
Excerpt from our project config.ini:
# Start File Install itself
osgi.bundles=reference\:file\:org.apache.felix.fileinstall_3.1.0.jar#1\:start
# The name of the directory to watch
felix.fileinstall.dir=./plugins
# A regular expression to be used to filter file names
# We have all bundles in plugins/ directory, this regexp
# forbids monitoring bundles that are started via osgi.bundles property
felix.fileinstall.filter=^(?!org.apache.felix.fileinstall|org.eclipse.osgi).*
# Determines if File Install waits felix.fileinstall.poll milliseconds before doing an initial scan or not.
felix.fileinstall.noInitialDelay=true
# Not sure why we have this...
felix.fileinstall.start.level=2
Other possible solution would be to use Eclipse P2. It is much more advanced and powerful, though I find it quite difficult to use.
Good thing is that if your application is agnostic to the way bundles are provisioned (and it should be this way), you can always change your mind later.
Here is the fragment from my automated eclipse installer written in ant.
This installs all features from the custom update site. The code is 'as is', but I sure would have liked to have something like this to guide me when I wrote it.
This script also uses antcontrib extension to ant. Antcontrib tasks are have 'ac:' namespace prefix
Hope this helps.
<property name="real.eclipse.home" location="${eclipse.home}/eclipse"/>
<property file="${real.eclipse.home}/configuration/config.ini" prefix="ECLIPSE_CONFIG"/>
<property name="eclipse-plugins.dir" location="${real.eclipse.home}/plugins"/>
<path id="newest.equinox.launcher-library.path.id">
<dirset dir="${eclipse-plugins.dir}">
<include name="org.eclipse.equinox.launcher.*"/>
</dirset>
</path>
<property name="equinox.launcher-library.full-path" refid="newest.equinox.launcher-library.path.id"/>
<basename property="equinox.launcher-library.dir" file="${equinox.launcher-library.full-path}"/>
<echo message="equinox.launcher-library.dir='${equinox.launcher-library.dir}'"/>
<path id="newest.equinox.launcher.path.id">
<fileset dir="${eclipse-plugins.dir}">
<include name="org.eclipse.equinox.launcher_*.jar"/>
</fileset>
</path>
<property name="equinox.launcher.jar" refid="newest.equinox.launcher.path.id"/>
<basename property="equinox.launcher.jar.basename" file="${equinox.launcher.jar}"/>
<echo message="equinox.launcher.jar='${equinox.launcher.jar}'"/>
<java jar="${equinox.launcher.jar}"
fork="true"
failonerror="true"
>
<arg value="-consolelog"/>
<arg value="-application"/>
<arg value="org.eclipse.equinox.p2.director"/>
<arg value="-repository"/>
<arg value="http://${repository.server}/custom-update-site"/>
<arg value="-list"/>
<redirector
logError="true"
outputproperty="features.list"
>
<outputfilterchain>
<linecontains>
<contains value="feature.group="/>
</linecontains>
<replaceregex pattern="(.*feature\.group)=.*$" replace="\1"/>
</outputfilterchain>
</redirector>
</java>
<ac:for list="${features.list}" delimiter="${line.separator}" trim="true" param="feature">
<sequential>
<ac:if>
<isset property="feature.comma.list"/>
<then>
<ac:var name="feature.comma.list" value="${feature.comma.list},#{feature}"/>
</then>
<else>
<property name="feature.comma.list" value="#{feature}"/>
</else>
</ac:if>
</sequential>
</ac:for>
<echo message="Found following features to install"/>
<echo message="${features.list}"/>
<java jar="${equinox.launcher.jar}"
fork="true"
failonerror="true"
>
<arg value="-consolelog"/>
<arg value="-application"/>
<arg value="org.eclipse.equinox.p2.director"/>
<arg value="-repository"/>
<arg value="http://${repository.server}/custom-update-site"/>
<arg value="-destination"/>
<arg file="${real.eclipse.home}"/>
<arg value="-installIU"/>
<arg value="${feature.comma.list}"/>
<arg value="-profile"/>
<arg value="${ECLIPSE_CONFIG.eclipse.p2.profile}"/>
</java>
P.S. For its usefulness and complexity Eclipse P2 is surely one of the most underdocumented features.
In your eclipse installation folder you have the file bundles.info, for example:
eclipse-3.6.1/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info
You can modify the file to add any bundle you want, and also the start level. But the simplest method of adding bundles to an eclipse installation is to add them to the "dropins" folder. This will lead to an automatic modification of the bundle.info file.
I have a compiler (and language) I am building that is normally invoked thus:
java -jar nc.jar \
-p some/referenced/package.nc \
-p framework.nc \
source1.ns source2.ns sourceN.ns \
-o output/package.nc
I'd like to include a task in my ANT build file that invokes the compiler to compile the standard library and all test cases, but specifying each separate compiler invocation as a <java> task is painful:
<target name="framework" depends="compiler" description="Build the n framework">
<!-- More compile steps -->
<java jar="nc.jar" fork="true">
<arg value="-p"/>
<arg path="../nframework/build/n.core.nc"/>
<arg path="../nframework/n/debug/DebugPrint.ns"/>
<arg path="../nframework/n/debug/Trace.ns"/>
<arg value="-o"/>
<arg path="../nframework/build/n.debug.nc"/>
</java>
<!-- More compile steps -->
</target>
I would like to create an ANT task of some sort that can simplify this into something like:
<target name="framework" depends="compiler" description="Build the n framework">
<!-- More compile steps -->
<nc output="../nframework/build/n.debug.nc">
<link-package path="../nframework/build/n.core.nc"/>
<src>
<fileset dir="../nframework/n/debug" includes="**/*.ns"/>
</src>
</nc>
<!-- More compile steps -->
</target>
To this end, I tried macrodef:
<macrodef name="nc">
<attribute name="output"/>
<element name="link-package"/>
<element name="src"/>
<sequential>
<java jar="nc.jar" fork="true">
<arg value="-p"/>
<!-- This doesn't do what I want -->
<link-package/>
<!-- Neither does this -->
<src/>
<arg value="-o"/>
<arg path="#{output}"/>
</java>
</sequential>
</macrodef>
I've tried several variations on the above, but each errors out with something like:
/home/jwarner/code/nlang/nc/build.xml:55: java doesn't support nested "fileset" element.
Is there a way to do this without extending ANT itself? Alternatively, would it be fairly easy to add an ant task to my compiler? I'm not terribly picky about the syntax of the final <nc> task.
I have had a similar problem in the past where the out-of-the-box Ant tasks didn't quite do what I wanted them to do. I found that it was very easy to write my own Ant task.
The documentation is concise but does a good job of explaining what you need to do.
http://ant.apache.org/manual/develop.html#writingowntask