nieschumi
nieschumi

Reputation: 561

How to run JDiff on java 1.7

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?

Upvotes: 1

Views: 670

Answers (2)

user2179737
user2179737

Reputation: 551

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.

Upvotes: 0

Chad Nouis
Chad Nouis

Reputation: 7041

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.

Upvotes: 1

Related Questions