Skip to content

Commit 631f24b

Browse files
committed
Introduce jdiff Gradle task
The new jdiff task generates a report of API differences between the current version (i.e. the value of `version` in gradle.properties) and any older version of the framework, as specified by -DOLD_VERSION at the command line, or defaulting to `previousVersion` in gradle.properties. Running the command requires a separate clone directory pinned to the desired old version, as specified by -DOLD_VERSION_ROOT at the command line. This creates challenges from a build automation perspective, largely because Gradle doesn't (yet) have APIs for working with Git. This task may be further automated and included in nightly CI runs, but in the meantime, a number of reports back to 3.1.3.RELEASE have been generated manually and uploaded to [1], where one can now find the following entries in the directory listing: - 3.1.3.RELEASE_to_3.2.0.RC1 - 3.2.0.M1_to_3.2.0.M2 - 3.2.0.M2_to_3.2.0.RC1 - 3.2.0.RC1_to_3.2.0.BUILD-SNAPSHOT Ideally, the final entry there would be kept up-to-date on a daily basis - again we may revisit doing so in the future. Going forward, reports will be generated and uploaded manually on an as needed basis and as part of the release process. The goal of these reports are as follows: - to ease the process of ensuring backward compatibility - to aid in code reviews, particularly when reviewing large pull requests - to ease the process of creating migration guides for project maintainers, i.e. to help us remember what's changed - to allow ambitious end-users to discover what's been changing at the API level without without needing to wait for detailed "what's new in version X" and/or migration guide documentation See documentation in jdiff.gradle for usage details. Note that the jdiff-1.1.1 distribution as downloaded from [2] has been added wholesale to the source tree under gradle/jdiff instead of uploading JDiff jars to repo.springsource.org as we would normally do. This is due to some unfortunate limitations in the implementation of the jdiff ant task that require a phisical JDIFF_HOME directory. Checking in the jars and various resources represents the simplest and most pragmatic solution to this problem, though ambitious contributors are free to do what's necessary to arrive at a more elegant arrangement. [1]: http://static.springframework.org/spring-framework/docs [2]: http://sourceforge.net/projects/javadiff/files/latest/download Issue: SPR-9957
1 parent d4fb1c8 commit 631f24b

15 files changed

+1688
-0
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ configure(rootProject) {
659659
description = 'Spring Framework'
660660

661661
apply plugin: 'docbook-reference'
662+
apply from: "${gradleScriptDir}/jdiff.gradle"
662663

663664
reference {
664665
sourceDir = file('src/reference/docbook')

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
version=3.2.0.BUILD-SNAPSHOT
2+
previousVersion=3.2.0.RC1

gradle/jdiff.gradle

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**
2+
* Generate a JDiff report between the current version and an older version.
3+
*
4+
* Usage:
5+
* gradle jdiff [-D OLD_VERSION=3.1.3.RELEASE] -D OLD_VERSION_ROOT=/path/to/3.1.3.RELEASE
6+
*
7+
* View generated report at:
8+
* build/reports/jdiff/changes.html
9+
*
10+
* @param OLD_VERSION optional, defaulting to value of `previousVersion` in gradle.properties
11+
* @param OLD_VERSION_ROOT required, typically pointing to a separate git clone dir
12+
*/
13+
task jdiff {
14+
description = 'Generates a JDiff report'
15+
group = 'Documentation'
16+
17+
def jdiffHome = "${rootProject.rootDir}/gradle/jdiff"
18+
19+
ant.taskdef(
20+
name: 'jdiff',
21+
classname: 'jdiff.JDiffAntTask',
22+
classpath: "${jdiffHome}/antjdiff.jar")
23+
24+
def previousVersion = rootProject.previousVersion
25+
26+
def currentVersion = rootProject.version
27+
def currentVersionRoot = rootProject.rootDir
28+
29+
def oldVersion = System.getProperty("OLD_VERSION") ?: previousVersion
30+
def oldVersionRoot = System.getProperty("OLD_VERSION_ROOT")
31+
32+
def outputDir = "${rootProject.buildDir}/reports/jdiff/${oldVersion}_to_${currentVersion}"
33+
34+
doLast {
35+
if (oldVersionRoot == null)
36+
throw new IllegalArgumentException(
37+
"Set OLD_VERSION_ROOT property to indicate the root directory for ${oldVersion}")
38+
39+
oldVersionRoot = new File(oldVersionRoot)
40+
41+
ant.property(name: 'JDIFF_HOME', value: jdiffHome)
42+
ant.mkdir(dir: outputDir)
43+
ant.jdiff(
44+
destdir: outputDir,
45+
verbose: 'off',
46+
stats: 'on',
47+
docchanges: 'on') {
48+
old(name: "Spring Framework ${oldVersion}") {
49+
oldVersionRoot.eachDirMatch( {
50+
def candidate = new File(it)
51+
candidate.name.matches("org.springframework.*") ||
52+
candidate.name.matches("spring-.*") }) { match ->
53+
match.eachDirRecurse { subdir ->
54+
if (subdir.path ==~ '.*/src/main/java$') {
55+
dirset(dir: subdir.path, includes: 'org/**')
56+
}
57+
}
58+
}
59+
}
60+
'new'(name: "Spring Framework ${currentVersion}") {
61+
currentVersionRoot.eachDirMatch( {
62+
def candidate = new File(it)
63+
candidate.name.matches("org.springframework.*") ||
64+
candidate.name.matches("spring-.*") }) { match ->
65+
match.eachDirRecurse { subdir ->
66+
if (subdir.path ==~ '.*/src/main/java$') {
67+
dirset(dir: subdir.path, includes: 'org/**')
68+
}
69+
}
70+
}
71+
}
72+
}
73+
}
74+
}

gradle/jdiff/LICENSE.txt

Lines changed: 506 additions & 0 deletions
Large diffs are not rendered by default.

gradle/jdiff/Null.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* This class is used only as a "null" argument for Javadoc when comparing
3+
* two API files. Javadoc has to have a package, .java or .class file as an
4+
* argument, even though JDiff doesn't use it.
5+
*/
6+
public class Null {
7+
public Null() {
8+
}
9+
}

gradle/jdiff/README-SPRING.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This distribution of JDiff 1.1.1 is included in the Spring Framework build
2+
because JDiff has a hard requirement on a JDIFF_HOME directory containing
3+
jdiff.jar and xerces.jar as well as other presentation resources.
4+
5+
The actual generation of JDiff reports is driven by the `jdiff` task declared
6+
in build.gradle in the project root.

gradle/jdiff/README.txt

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
JDiff Doclet
3+
------------
4+
5+
Matthew Doar
6+
7+
8+
9+
The JDiff doclet is used to generate a report describing the
10+
difference between two public Java APIs.
11+
12+
The file jdiff.html contains the reference page for JDiff. The latest
13+
version of JDiff can be downloaded at:
14+
http://sourceforge.net/projects/javadiff
15+
16+
To use the Ant task on your own project, see example.xml. More examples
17+
of using JDiff to compare the public APIs of J2SE1.3 and J2SE1.4 can
18+
be seen at http://www.jdiff.org
19+
20+
For an example with the source distribution, run "ant" and
21+
look at the HTML output in ./build/reports/example/changes.html
22+
The page at ./build/reports/example/changes/com.acme.sp.SPImpl.html
23+
shows what a typical page of changes looks like.
24+
25+
System Requirements
26+
-------------------
27+
28+
JDiff has been tested with all releases of Java since J2SE1.2 but
29+
releases of JDiff after 1.10.0 focus on JDK1.5.
30+
31+
License
32+
-------
33+
34+
JDiff is licensed under the Lesser GNU General Public License (LGPL).
35+
See the file LICENSE.txt.
36+
37+
Acknowledgements
38+
----------------
39+
40+
JDiff uses Stuart D. Gathman's Java translation of Gene Myers' O(ND)
41+
difference algorithm.
42+
43+
JDiff uses Xerces 1.4.2 from http://www.apache.org.
44+
45+
JDiff also includes a script to use the classdoc application from
46+
http://classdoc.sourceforge.net or http://www.jensgulden.de, by Jens
47+
Gulden, ([email protected]), to call a doclet such as jdiff on a .jar
48+
file rather than on source.
49+
50+
Many thanks to the reviewers at Sun and Vitria who gave feedback on early
51+
versions of JDiff output, and also to the distillers of Laphroaig, and to
52+
Arturo Fuente for his consistently fine cigars which helped inspire
53+
much of this work.
54+
55+
56+
Footnote:
57+
58+
If you are looking for a generalized diff tool for XML, try diffmk from
59+
http://wwws.sun.com/software/xml/developers/diffmk/

gradle/jdiff/antjdiff.jar

5.7 KB
Binary file not shown.

gradle/jdiff/background.gif

559 Bytes
Loading

gradle/jdiff/black.gif

799 Bytes
Loading

0 commit comments

Comments
 (0)