Skip to content

Commit b2385ae

Browse files
Update dependencies in pom.xml to latest versions and add validation test for version consistency
- Updated org.jetbrains:annotations from 2.0.10 to 24.1.0 - Updated commons-codec:commons-codec from 2.0.10 to 1.16.0 - Updated com.google.code.gson:gson from 2.0.10 to 2.11.0 - Updated org.apache.httpcomponents:httpmime from 2.0.10 to 4.5.14 - Updated maven-surefire-plugin from 2.0.10 to 3.2.5 - Updated central-publishing-maven-plugin from 2.0.10 to 0.8.0 - Updated maven-source-plugin from 2.0.10 to 3.3.0 - Updated maven-javadoc-plugin from 2.0.10 to 3.6.0 - Updated maven-gpg-plugin from 2.0.10 to 3.2.4 - Added PomValidationTest to ensure plugin/dependency versions do not match project version
1 parent 8bdaee3 commit b2385ae

2 files changed

Lines changed: 40 additions & 9 deletions

File tree

zero-bounce-sdk/pom.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@
4747
<dependency>
4848
<groupId>org.jetbrains</groupId>
4949
<artifactId>annotations</artifactId>
50-
<version>2.0.10</version>
50+
<version>24.1.0</version>
5151
</dependency>
5252

5353
<dependency>
5454
<groupId>commons-codec</groupId>
5555
<artifactId>commons-codec</artifactId>
56-
<version>2.0.10</version>
56+
<version>1.16.0</version>
5757
</dependency>
5858

5959
<dependency>
6060
<groupId>com.google.code.gson</groupId>
6161
<artifactId>gson</artifactId>
62-
<version>2.0.10</version>
62+
<version>2.11.0</version>
6363
</dependency>
6464

6565
<dependency>
@@ -72,7 +72,7 @@
7272
<dependency>
7373
<groupId>org.apache.httpcomponents</groupId>
7474
<artifactId>httpmime</artifactId>
75-
<version>2.0.10</version>
75+
<version>4.5.14</version>
7676
</dependency>
7777

7878
<!-- https://mvnrepository.com/artifact/junit/junit -->
@@ -120,7 +120,7 @@
120120
<plugin>
121121
<groupId>org.apache.maven.plugins</groupId>
122122
<artifactId>maven-surefire-plugin</artifactId>
123-
<version>2.0.10</version>
123+
<version>3.2.5</version>
124124
<configuration>
125125
<argLine>
126126
@{argLine} -javaagent:${settings.localRepository}/org/mockito/mockito-core/${mockito.version}/mockito-core-${mockito.version}.jar
@@ -178,7 +178,7 @@
178178
<plugin>
179179
<groupId>org.sonatype.central</groupId>
180180
<artifactId>central-publishing-maven-plugin</artifactId>
181-
<version>2.0.10</version>
181+
<version>0.8.0</version>
182182
<extensions>true</extensions>
183183
<configuration>
184184
<publishingServerId>central</publishingServerId>
@@ -189,7 +189,7 @@
189189
<plugin>
190190
<groupId>org.apache.maven.plugins</groupId>
191191
<artifactId>maven-source-plugin</artifactId>
192-
<version>2.0.10</version>
192+
<version>3.3.0</version>
193193
<executions>
194194
<execution>
195195
<id>attach-sources</id>
@@ -203,7 +203,7 @@
203203
<plugin>
204204
<groupId>org.apache.maven.plugins</groupId>
205205
<artifactId>maven-javadoc-plugin</artifactId>
206-
<version>2.0.10</version>
206+
<version>3.6.0</version>
207207
<executions>
208208
<execution>
209209
<id>attach-javadocs</id>
@@ -217,7 +217,7 @@
217217
<plugin>
218218
<groupId>org.apache.maven.plugins</groupId>
219219
<artifactId>maven-gpg-plugin</artifactId>
220-
<version>2.0.10</version>
220+
<version>3.2.4</version>
221221
<executions>
222222
<execution>
223223
<id>sign-artifacts</id>

zero-bounce-sdk/src/test/java/com/zerobounce/PomValidationTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,49 @@
55
import java.io.File;
66
import java.nio.file.Files;
77
import java.nio.file.Path;
8+
import java.util.ArrayList;
9+
import java.util.List;
10+
import java.util.regex.Matcher;
811
import java.util.regex.Pattern;
912

1013
import static org.junit.jupiter.api.Assertions.*;
1114

1215
/**
1316
* Validates POM plugin/dependency versions that are easy to misversion (e.g. copy-paste).
1417
* Fails during {@code mvn test} so issues are caught locally before CI.
18+
* (Pattern from Android SDK: project/publish version is separate from plugin/dependency versions.)
1519
*/
1620
class PomValidationTest {
1721

1822
private static final Pattern JACOCO_VERSION = Pattern.compile("0\\.8\\.\\d+");
1923

24+
@Test
25+
void noPluginOrDependencyVersionMustEqualProjectVersion() throws Exception {
26+
File pom = findPom();
27+
assertTrue(Files.isRegularFile(pom.toPath()), "pom.xml not found at " + pom.getAbsolutePath());
28+
String content = Files.readString(pom.toPath());
29+
30+
// Project version is the first <version> in the POM (root element).
31+
Matcher firstVersion = Pattern.compile("<version>([^<]+)</version>").matcher(content);
32+
assertTrue(firstVersion.find(), "No <version> found in pom.xml");
33+
String projectVersion = firstVersion.group(1).trim();
34+
35+
// Collect all other <version> values (after the first).
36+
List<String> mistaken = new ArrayList<>();
37+
while (firstVersion.find()) {
38+
String v = firstVersion.group(1).trim();
39+
if (projectVersion.equals(v)) {
40+
mistaken.add(v);
41+
}
42+
}
43+
assertTrue(
44+
mistaken.isEmpty(),
45+
"Plugin/dependency version must not equal project version (" + projectVersion + "). "
46+
+ "That copy-paste causes PluginResolutionException (e.g. maven-surefire-plugin has no such version on Maven Central). "
47+
+ "Found " + mistaken.size() + " occurrence(s). Use explicit versions per artifact."
48+
);
49+
}
50+
2051
@Test
2152
void jacocoMavenPluginVersionMustBe08x() throws Exception {
2253
File pom = findPom();

0 commit comments

Comments
 (0)