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.
The project has been maintained by Aline Brito and Laerte Xavier under supervision of Professor Marco Tulio Valente (Aserg UFMG) and Professor Andre Hora (UFMS FACOM).
The following Breaking Changes (BC) are supported:
Element | Breaking Changes (BC) |
---|---|
Type | Rename Type, Move Type, Move and Rename Type, Remove Type, Lost Visibility, Add Final Modifier, Remove Static Modifier, Change in Supertype, Remove Supertype |
Method | Move Method, Rename Method, Remove Method, Push Down Method, Inline Method, Change in Parameter List, Change in Exception List, Change in Return Type Method, Lost Visibility, Add Final Modifier, Remove Static Modifier |
Field | Remove Field, Move Field, Push Down Field, Change in Default Value, Change in Type Field, Lost Visibility, Add Final Modifier |
The following Non-breaking Changes (NBC) are supported:
Element | Non-breaking Changes (NBC) |
---|---|
Type | Add Type, Extract Supertype, Gain Visibility, Remove Final Modifier, Add Static Modifier, Add Supertype, Deprecated Type |
Method | Pull Up Method, Gain Visibility, Remove Final Modifier, Add Static Modifier, Deprecated Method, Add Method, Extract Method |
Field | Pull Up Field, Add Field, Deprecated Field, Gain Visibility, Remove Final Modifier |
The refactorings catalog is reused from RefDiff.
- 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.
APIDiff is available in the Maven Central Repository:
<dependency>
<groupId>com.github.aserg-ufmg</groupId>
<artifactId>apidiff</artifactId>
<version>2.0.0</version>
</dependency>
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/