APIDiff

A tool to identify API breaking and non-breaking changes between two versions of a Java library

License

License

GroupId

GroupId

com.github.aserg-ufmg
ArtifactId

ArtifactId

apidiff
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

APIDiff
A tool to identify API breaking and non-breaking changes between two versions of a Java library
Project URL

Project URL

https://github.com/aserg-ufmg/apidiff
Source Code Management

Source Code Management

https://github.com/aserg-ufmg/apidiff.git

Download apidiff

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.aserg-ufmg/apidiff/ -->
<dependency>
    <groupId>com.github.aserg-ufmg</groupId>
    <artifactId>apidiff</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.aserg-ufmg/apidiff/
implementation 'com.github.aserg-ufmg:apidiff:2.0.0'
// https://jarcasting.com/artifacts/com.github.aserg-ufmg/apidiff/
implementation ("com.github.aserg-ufmg:apidiff:2.0.0")
'com.github.aserg-ufmg:apidiff:jar:2.0.0'
<dependency org="com.github.aserg-ufmg" name="apidiff" rev="2.0.0">
  <artifact name="apidiff" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.aserg-ufmg', module='apidiff', version='2.0.0')
)
libraryDependencies += "com.github.aserg-ufmg" % "apidiff" % "2.0.0"
[com.github.aserg-ufmg/apidiff "2.0.0"]

Dependencies

compile (14)

Group / Artifact Type Version
com.jcabi : jcabi-github jar 0.29
org.eclipse.jgit : org.eclipse.jgit jar 4.6.0.201612231935-r
org.eclipse.core : contenttype jar 3.4.200-v20140207-1251
org.eclipse.birt.runtime : org.eclipse.core.jobs jar 3.6.1.v20141014-1248
org.eclipse.birt.runtime : org.eclipse.core.resources jar 3.9.1.v20140825-1431
org.eclipse.core : runtime jar 3.10.0-v20140318-2214
org.eclipse.equinox : common jar 3.6.200-v20130402-1505
org.eclipse.equinox : preferences jar 3.5.200-v20140224-1527
org.eclipse.jdt : org.eclipse.jdt.core jar 3.10.0
org.eclipse.birt.runtime : org.eclipse.osgi jar 3.10.2.v20150203-1939
org.apache.maven.plugins : maven-compiler-plugin jar 3.6.1
org.slf4j : slf4j-api jar 1.7.5
org.slf4j : slf4j-log4j12 jar 1.7.5
com.github.aserg-ufmg : refdiff-core jar 0.1.1

Project Modules

There are no modules declared in this project.

APIDiff

A tool to identify API breaking and non-breaking changes between two versions of a Java library. APIDiff analyses libraries hosted on the distributed version control system git.

Catalog

Breaking Changes are modifications performed in API elements such as types, methods, and fields that may break client applications:

Element Breaking Changes (BC)
Type rename, move, move and rename, remove, lost visibility, add final modifier, remove static modifier, change in supertype, remove supertype
Method move, rename, remove, push down, inline, change in parameter list, change in exception list, change in return type, lost visibility, add final modifier, remove static modifier
Field remove, move, push down field, change in default value, change in type field, lost visibility, add final modifier

Non-breaking Changes are modifications that do not break clients:

Element Non-breaking Changes (NBC)
Type add, extract supertype, gain visibility, remove final modifier, add static modifier, add supertype, deprecated type
Method pull up, gain visibility, remove final modifier, add static modifier, deprecated method, add, extract
Field pull up, add, deprecated field, gain visibility, remove final modifier

The refactorings catalog is reused from RefDiff.

Examples

  • Detecting changes in version histories:
APIDiff diff = new APIDiff("bumptech/glide", "https://github.com/bumptech/glide.git");
diff.setPath("/home/projects/github");

Result result = diff.detectChangeAllHistory("master", Classifier.API);
for(Change changeMethod : result.getChangeMethod()){
    System.out.println("\n" + changeMethod.getCategory().getDisplayName() + " - " + changeMethod.getDescription());
}
  • Detecting changes in specific commit:
APIDiff diff = new APIDiff("mockito/mockito", "https://github.com/mockito/mockito.git");
diff.setPath("/home/projects/github");

Result result = diff.detectChangeAtCommit("4ad5fdc14ca4b979155d10dcea0182c82380aefa", Classifier.API);
for(Change changeMethod : result.getChangeMethod()){
    System.out.println("\n" + changeMethod.getCategory().getDisplayName() + " - " + changeMethod.getDescription());
}
  • Fetching new commits:
APIDiff diff = new APIDiff("bumptech/glide", "https://github.com/bumptech/glide.git");
diff.setPath("/home/projects/github");
    
Result result = diff.fetchAndDetectChange(Classifier.API);
for(Change changeMethod : result.getChangeMethod()){
    System.out.println("\n" + changeMethod.getCategory().getDisplayName() + " - " + changeMethod.getDescription());
}
  • Writing a CSV file:
APIDiff diff = new APIDiff("mockito/mockito", "https://github.com/mockito/mockito.git");
diff.setPath("/home/projects/github");
Result result = diff.detectChangeAtCommit("4ad5fdc14ca4b979155d10dcea0182c82380aefa", Classifier.API);
		
List<String> listChanges = new ArrayList<String>();
listChanges.add("Category;isDeprecated;containsJavadoc");
for(Change changeMethod : result.getChangeMethod()){
    String change = changeMethod.getCategory().getDisplayName() + ";" + changeMethod.isDeprecated()  + ";" + changeMethod.containsJavadoc() ;
    listChanges.add(change);
}
UtilFile.writeFile("output.csv", listChanges);
  • Filtering Packages according to their names:
Classifier.INTERNAL: Elements that are in packages with the term "internal".

Classifier.TEST: Elements that are in packages with the terms "test"|"tests", or is in source file "src/test", or ends with "test.java"|"tests.java".

Classifier.EXAMPLE: Elements that are in packages with the terms "example"|"examples"|"sample"|"samples"|"demo"|"demos"

Classifier.EXPERIMENTAL: Elements that are in packages with the term "experimental".

Classifier.NON_API: Internal, test, example or experimental elements.

Classifier.API: Elements that are not non-APIs.

Usage

APIDiff is available in the Maven Central Repository:

<dependency>
    <groupId>com.github.aserg-ufmg</groupId>
    <artifactId>apidiff</artifactId>
    <version>2.0.0</version>
</dependency>

Publications

Aline Brito, Laerte Xavier, Andre Hora, Marco Tulio Valente. APIDiff: Detecting API Breaking Changes. In 25th International Conference on Software Analysis, Evolution and Reengineering (SANER), Tool Track, pages 1-5, 2018.

Learn more about our research group at http://aserg.labsoft.dcc.ufmg.br/

com.github.aserg-ufmg

Applied Software Engineering Research Group

Department of Computer Science, Federal University of Minas Gerais

Versions

Version
2.0.0