7

The Android Open Source regularly releases a list of API differences between API levels. Here are some examples from developer.android.com:

Difference between API Level 18 and 19

Difference between API Level 14 and 15

This looks like it was somehow automatically generated.

I would like to use a similar tool so I can track differences between API versions of my own source code.

What tool can do this for me?

hopia
  • 4,880
  • 7
  • 32
  • 54
  • Take a look at this script: https://groups.google.com/forum/#!msg/android-building/0DtsHawjs4k/And8o3Dni_UJ – Yury Feb 15 '14 at 10:55

2 Answers2

1

They use JDiff, spring also uses it on their documentations.

If you are using gradle you can use this file as reference on how to make use of JDiff to generate API difference reports automatically:
https://github.com/Netflix/governator/blob/master/jdiff.gradle

/*
 * Copyright 2015 Netflix, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
plugins {
    id 'org.ajoberstar.github-pages' version '1.4.2'
}
/**
 * Generate a JDiff report between a newer version and an older version.
 *
 * Usage:
 *  gradle -PjDiff.olderVersion=2.1312.0 [-PjDiff.newerVersion=2.1716.0] generateJDiffReport
 *
 * View generated report at:
 *  build/reports/jDiff/${olderVersion}-to-${newerVersion}/changes.html
 */
task generateJDiffReport(dependsOn: '_jDiff_cloneOldVersion') {
    description = "Generates a JDiff report"
    group = "Documentation"

    final jDiffHome = "${rootProject.rootDir}/buildSrc/lib/jdiff-1.1.1/"

    ant.taskdef(
        name: 'jDiff',
        classname: 'jdiff.JDiffAntTask',
        classpath: "${jDiffHome}/antjdiff.jar")

    doLast {
        final olderVersion = project.getProperty('jDiff.olderVersion')
        final olderVersionRoot = new File("${rootProject.buildDir}/jDiff/${rootProject.name}-${olderVersion}")

        if (olderVersion == null)
            throw new IllegalArgumentException(
                'Set `jDiff.olderVersion` property to indicate older of the two versions being compared')

        final newerVersion = project.hasProperty('jDiff.newerVersion') ? project.getProperty('jDiff.newerVersion') : rootProject.version
        final newerVersionRoot = rootProject.rootDir

        final outputDir = "${rootProject.buildDir}/reports/jDiff/${olderVersion}-to-${newerVersion}"
        mkdir(outputDir)

        ant.metaClass.jDiff_getSrcDirSets = { root ->
            root.eachDirMatch({ dir ->
                new File("${dir}/src/main/java").exists()
            }) { dir ->
                dirset(dir: "${dir}/src/main/java")
            }
        }

        ant.property(name: "JDIFF_HOME", value: jDiffHome)
        ant.jDiff(
            destdir: outputDir,
            verbose: 'off',
            stats: 'on',
            docchanges: 'off',
            source: '1.8') {
            old(name: "${rootProject.name}-${olderVersion}") {
                jDiff_getSrcDirSets(olderVersionRoot)
            }

            'new'(name: "${rootProject.name}-${newerVersion}") {
                jDiff_getSrcDirSets(newerVersionRoot)
            }
        }
    }
}
import org.ajoberstar.grgit.Grgit
task _jDiff_cloneOldVersion << {
    final olderVersion = project.getProperty('jDiff.olderVersion')
    final olderVersionRoot = new File("${rootProject.buildDir}/jDiff/${rootProject.name}-${olderVersion}")

    final newerVersionRoot = rootProject.rootDir

    if (!olderVersionRoot.isDirectory()) {
        Grgit.clone(
            uri: "file://${newerVersionRoot.path}/.git",
            dir: olderVersionRoot.path,
            refToCheckout: "refs/tags/v${olderVersion}")
    }
}
Polyana Fontes
  • 3,156
  • 1
  • 27
  • 41
0

I'm guessing, but it's most likely you want to look into Javadoc generation tools. I've not used them much beyond the basics but it's likely to be one of those that creates the type of documents you are after, maybe in conjunction with some version control to generate only partial javadocs.

I reiterate, I'm not certain about anything I just said, I'm just offering this in case it helps point you, or other visitors in the right direction seeing as you have no other answers.

If that's not it and you don't mine making the effort to parse results yourself, or, if you're only interested in seeing the results yourself, do you use Git/Version control?

Git can help get you part way, git diff has a lot of flexibility to show you what's changed. The following would probably what you want initially (where patchfirstcommit and patchlastcommit should be the identifiers for the range of commits you are interested in)

  git diff --name-summary patchlastcommit patchfirstcommit

(You can see the list of commits with this:)

  git reflog

You could then parse the results as you see fit.

Nick Cardoso
  • 20,807
  • 14
  • 73
  • 124
  • I think you meant git log to show list of commits. git reflog is something completely different – Bartek Filipowicz Feb 06 '14 at 23:44
  • git reflog gives you both the commit id and the head version, which are the two pieces of information that can be used with the diff. git log just gives messages and huge hashes nobody would want to type for a diff command. Even if you weren't wrong, your comment adds nothing – Nick Cardoso Feb 07 '14 at 09:36
  • Sorry, I thought you made a typo. If I knew you were just wrong I would be more verbose. 'git relfog' is a local history of the commits that your HEAD was pointing to. If you just cloned the repo, this will only contain one entry with you HEAD. Here's the disambiguation: http://stackoverflow.com/questions/17857723/whats-the-difference-between-git-reflog-and-log. My comment just points to a mistake in your answer. It is nothing personal. Try also 'log --graph --decorate --pretty=oneline --abbrev-commit' to have a nice log output with short commit hashes that you can retype (or even copy). – Bartek Filipowicz Feb 07 '14 at 10:09
  • Also for git diff you can use branch names instead of commit hashes. (branch names are actually alisases for their head commits). So you'd like to do something like git 'diff --name-only kitkat-release froyo' to show the files that differ between the branches. – Bartek Filipowicz Feb 07 '14 at 10:14