Add API Compatibility Task to Java Libraries#25
Conversation
| } | ||
|
|
||
| private void japiCmp(Project project) { | ||
| project.afterEvaluate { |
There was a problem hiding this comment.
Needs to happen after evaluation so plugin config settings are available.
| project.afterEvaluate { | ||
| def lib = project.extensions.oss | ||
| def baselineVersion = lib.baselineVersion | ||
| if (baselineVersion) { |
There was a problem hiding this comment.
let's invert this condition and return sooner
There was a problem hiding this comment.
new commit to invert and return earlier pushed.
| apply plugin: 'me.champeau.gradle.japicmp' | ||
| task('apiDiff', type: JapicmpTask, dependsOn: 'jar') { | ||
| oldClasspath = files(getBaselineJar(project, baselineVersion)) | ||
| newClasspath = files("$buildDir/libs/${project.name}-${project.version}.jar") |
There was a problem hiding this comment.
I think you could use archiveFile here instead of hardcoding the name. Archive File is a property from the Jar task
There was a problem hiding this comment.
👍 new commit to use the archiveFile pushed.
| it.name == "${project.name}-${baselineVersion}.jar" | ||
| } | ||
| } finally { | ||
| project.group = group |
There was a problem hiding this comment.
so if the baseline jar is found, the group gets updated before adding the dependency; but after that, it gets reset to the original value?
There was a problem hiding this comment.
correct. Similar to what okhttp does, and seen the same pattern in other repos.
| String organization | ||
| String repository | ||
| String description | ||
| String baselineVersion |
There was a problem hiding this comment.
This prop name has a meaning in the context of the japicmp plugin. How about here? Maybe we can come up with a better name that explains that diff check (can't think of any right now)
There was a problem hiding this comment.
How about baselineCompareVersion? It's a little long, but maybe is clearer?
There was a problem hiding this comment.
Yes, I agree it's clearer and I don't mind it being long as long if it's descriptive. Let's change it 👍
There was a problem hiding this comment.
New commit to rename to baselineCompareVersion pushed. Will also update the PR description with the new name.
Description
Currently, we rely on manual inspection of changes to ensure no breaking changes are introduced. Instead, we can leverage an API compatibility-checker, JApiCmp through the JApicmp Gradle Plugin.
This change adds a task,
apiDiff, to Java projects that specify abaselineCompareVersionproperty in theossconfig:oss { // ... baselineCompareVersion "3.13.0" }Details:
baselineCompareVersionconfiguration property is not addedChecklist
master