Skip to content

Commit fc19a62

Browse files
authored
Merge pull request #582 from maxmind/greg/eng-3367
Add API compatibility checking with japicmp
2 parents b51f304 + 7cc2338 commit fc19a62

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

.github/workflows/api-compat.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
persist-credentials: false
13+
- uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
14+
with:
15+
distribution: zulu
16+
java-version: 17
17+
cache: maven
18+
- name: Check API Compatibility
19+
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\.minfraud\:minfraud\:)\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: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@
277277

278278
<properties>
279279
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
280+
<!-- Baseline version for API compatibility checking. Update after each release. -->
281+
<japicmp.baselineVersion>4.0.0</japicmp.baselineVersion>
280282
</properties>
281283

282284
<reporting>
@@ -305,4 +307,68 @@
305307
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
306308
</repository>
307309
</distributionManagement>
310+
311+
<profiles>
312+
<profile>
313+
<id>api-compat</id>
314+
<build>
315+
<plugins>
316+
<!-- Download baseline JAR directly from Maven Central for API comparison -->
317+
<plugin>
318+
<groupId>org.apache.maven.plugins</groupId>
319+
<artifactId>maven-antrun-plugin</artifactId>
320+
<version>3.1.0</version>
321+
<executions>
322+
<execution>
323+
<id>download-baseline</id>
324+
<phase>package</phase>
325+
<goals>
326+
<goal>run</goal>
327+
</goals>
328+
<configuration>
329+
<target>
330+
<mkdir dir="${project.build.directory}/japicmp"/>
331+
<get src="https://repo1.maven.org/maven2/com/maxmind/minfraud/minfraud/${japicmp.baselineVersion}/minfraud-${japicmp.baselineVersion}.jar"
332+
dest="${project.build.directory}/japicmp/baseline.jar"
333+
skipexisting="false"/>
334+
</target>
335+
</configuration>
336+
</execution>
337+
</executions>
338+
</plugin>
339+
<plugin>
340+
<groupId>com.github.siom79.japicmp</groupId>
341+
<artifactId>japicmp-maven-plugin</artifactId>
342+
<version>0.25.1</version>
343+
<configuration>
344+
<oldVersion>
345+
<file>
346+
<path>${project.build.directory}/japicmp/baseline.jar</path>
347+
</file>
348+
</oldVersion>
349+
<newVersion>
350+
<file>
351+
<path>${project.build.directory}/${project.artifactId}-${project.version}.jar</path>
352+
</file>
353+
</newVersion>
354+
<parameter>
355+
<accessModifier>public</accessModifier>
356+
<breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
357+
<onlyBinaryIncompatible>false</onlyBinaryIncompatible>
358+
<onlyModified>true</onlyModified>
359+
</parameter>
360+
</configuration>
361+
<executions>
362+
<execution>
363+
<phase>verify</phase>
364+
<goals>
365+
<goal>cmp</goal>
366+
</goals>
367+
</execution>
368+
</executions>
369+
</plugin>
370+
</plugins>
371+
</build>
372+
</profile>
373+
</profiles>
308374
</project>

0 commit comments

Comments
 (0)