Skip to content

Commit 3a836da

Browse files
authored
Merge pull request #655 from maxmind/greg/eng-3367
Add API compatibility checking with japicmp
2 parents 2cc0f3e + 7ce1695 commit 3a836da

3 files changed

Lines changed: 86 additions & 0 deletions

File tree

.github/workflows/api-compat.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: API Compatibility Check
2+
on:
3+
pull_request:
4+
permissions:
5+
contents: read
6+
jobs:
7+
api-compat:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
11+
with:
12+
submodules: true
13+
persist-credentials: false
14+
- uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
15+
with:
16+
distribution: zulu
17+
java-version: 17
18+
cache: maven
19+
- name: Check API Compatibility
20+
run: mvn verify -P api-compat -DskipTests -Dgpg.skip=true

dev-bin/release.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ mvn versions:set -DnewVersion="$version"
134134
perl -pi -e "s/(?<=<version>)[^<]*/$version/" README.md
135135
perl -pi -e "s/(?<=com\.maxmind\.geoip2\:geoip2\:)\d+\.\d+\.\d+([\w\-]+)?/$version/" README.md
136136

137+
# Update japicmp.baselineVersion for API compatibility checking
138+
perl -pi -e "s/(<japicmp\.baselineVersion>)[^<]*(<\/japicmp\.baselineVersion>)/\${1}$version\${2}/" pom.xml
139+
137140
cat README.md >>$page
138141

139142
git diff

pom.xml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@
102102
</dependencies>
103103
<properties>
104104
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
105+
<!-- Baseline version for API compatibility checking. Update after each release. -->
106+
<japicmp.baselineVersion>5.0.2</japicmp.baselineVersion>
105107
</properties>
106108
<build>
107109
<plugins>
@@ -304,5 +306,66 @@
304306
</plugins>
305307
</build>
306308
</profile>
309+
<profile>
310+
<id>api-compat</id>
311+
<build>
312+
<plugins>
313+
<!-- Download baseline JAR directly from Maven Central for API comparison -->
314+
<plugin>
315+
<groupId>org.apache.maven.plugins</groupId>
316+
<artifactId>maven-antrun-plugin</artifactId>
317+
<version>3.1.0</version>
318+
<executions>
319+
<execution>
320+
<id>download-baseline</id>
321+
<phase>package</phase>
322+
<goals>
323+
<goal>run</goal>
324+
</goals>
325+
<configuration>
326+
<target>
327+
<mkdir dir="${project.build.directory}/japicmp"/>
328+
<get src="https://repo1.maven.org/maven2/com/maxmind/geoip2/geoip2/${japicmp.baselineVersion}/geoip2-${japicmp.baselineVersion}.jar"
329+
dest="${project.build.directory}/japicmp/baseline.jar"
330+
skipexisting="false"/>
331+
</target>
332+
</configuration>
333+
</execution>
334+
</executions>
335+
</plugin>
336+
<plugin>
337+
<groupId>com.github.siom79.japicmp</groupId>
338+
<artifactId>japicmp-maven-plugin</artifactId>
339+
<version>0.25.1</version>
340+
<configuration>
341+
<oldVersion>
342+
<file>
343+
<path>${project.build.directory}/japicmp/baseline.jar</path>
344+
</file>
345+
</oldVersion>
346+
<newVersion>
347+
<file>
348+
<path>${project.build.directory}/${project.artifactId}-${project.version}.jar</path>
349+
</file>
350+
</newVersion>
351+
<parameter>
352+
<accessModifier>public</accessModifier>
353+
<breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
354+
<onlyBinaryIncompatible>false</onlyBinaryIncompatible>
355+
<onlyModified>true</onlyModified>
356+
</parameter>
357+
</configuration>
358+
<executions>
359+
<execution>
360+
<phase>verify</phase>
361+
<goals>
362+
<goal>cmp</goal>
363+
</goals>
364+
</execution>
365+
</executions>
366+
</plugin>
367+
</plugins>
368+
</build>
369+
</profile>
307370
</profiles>
308371
</project>

0 commit comments

Comments
 (0)