Skip to content

Commit 9ec204f

Browse files
committed
check also the plugins for new version
1 parent 48f3139 commit 9ec204f

2 files changed

Lines changed: 48 additions & 11 deletions

File tree

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
<build-helper-plugin.version>3.6.1</build-helper-plugin.version>
8585
<checkstyle-plugin.version>3.6.0</checkstyle-plugin.version>
8686
<pmd-plugin.version>3.28.0</pmd-plugin.version>
87-
<spotbugs-plugin.version>4.10.2.0</spotbugs-plugin.version>
87+
<spotbugs-plugin.version>4.10.3.0</spotbugs-plugin.version>
8888
<gpg-plugin.version>3.2.8</gpg-plugin.version>
8989
<enforcer-plugin.version>3.6.3</enforcer-plugin.version>
9090
<changes-plugin.version>2.12.1</changes-plugin.version>
@@ -98,7 +98,7 @@
9898
<bundle-plugin.version>6.0.2</bundle-plugin.version>
9999
<jacoco-plugin.version>0.8.15</jacoco-plugin.version>
100100
<jdepend-plugin.version>2.2.0</jdepend-plugin.version>
101-
<cyclonedx-plugin.version>2.9.1</cyclonedx-plugin.version>
101+
<cyclonedx-plugin.version>2.9.2</cyclonedx-plugin.version>
102102
</properties>
103103

104104
<build>

src/test/java/org/htmlunit/ExternalTest.java

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,57 @@ public void pom() throws Exception {
8989
final Pattern ignorePattern = Pattern.compile("" + model.getProperties().get("maven.version.ignore"));
9090

9191
final List<String> wrongVersions = new LinkedList<>();
92+
93+
// Dependencies
9294
for (var dep : model.getDependencies()) {
93-
String version = dep.getVersion();
94-
if (version.startsWith("${")) {
95-
version = "" + model.getProperties().get(version.substring(2, version.length() - 1));
96-
}
97-
try {
98-
assertVersion(dep.getGroupId(), dep.getArtifactId(), version, ignorePattern);
95+
checkVersion(dep.getGroupId(), dep.getArtifactId(), dep.getVersion(),
96+
model, ignorePattern, wrongVersions);
97+
}
98+
99+
// Plugins declared directly under <build><plugins>
100+
if (model.getBuild() != null) {
101+
if (model.getBuild().getPlugins() != null) {
102+
for (var plugin : model.getBuild().getPlugins()) {
103+
checkVersion(plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(),
104+
model, ignorePattern, wrongVersions);
105+
}
99106
}
100-
catch (final AssertionError e) {
101-
wrongVersions.add(e.getMessage());
107+
108+
// Plugins declared under <build><pluginManagement><plugins>
109+
if (model.getBuild().getPluginManagement() != null
110+
&& model.getBuild().getPluginManagement().getPlugins() != null) {
111+
for (var plugin : model.getBuild().getPluginManagement().getPlugins()) {
112+
checkVersion(plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(),
113+
model, ignorePattern, wrongVersions);
114+
}
102115
}
103116
}
117+
104118
if (!wrongVersions.isEmpty()) {
105119
Assertions.fail(String.join("\n ", wrongVersions));
106120
}
107121
}
108122
}
109123

124+
private static void checkVersion(String groupId, String artifactId, String rawVersion,
125+
Model model, Pattern ignorePattern, List<String> wrongVersions) throws Exception {
126+
if (rawVersion == null) {
127+
// e.g. version inherited from a parent/BOM - nothing to resolve locally
128+
return;
129+
}
130+
131+
String version = rawVersion;
132+
if (version.startsWith("${")) {
133+
version = "" + model.getProperties().get(version.substring(2, version.length() - 1));
134+
}
135+
136+
try {
137+
assertVersion(groupId, artifactId, version, ignorePattern);
138+
} catch (final AssertionError e) {
139+
wrongVersions.add(e.getMessage());
140+
}
141+
}
142+
110143
/**
111144
* Tests that we use the latest chrome driver.
112145
* @throws Exception if an error occurs
@@ -219,6 +252,7 @@ public void snapshot() throws Exception {
219252
private static void assertVersion(final String groupId, final String artifactId,
220253
final String pomVersion, final Pattern ignorePattern)
221254
throws Exception {
255+
System.out.println("assertVersion(" + groupId);
222256
String latestMavenCentralVersion = null;
223257
String url = MAVEN_REPO_URL_
224258
+ groupId.replace('.', '/') + '/'
@@ -270,7 +304,10 @@ private static boolean isIgnored(final String groupId, final String artifactId,
270304
final String version, final Pattern ignorePattern) {
271305
// version > 3.12.0 does not work with our site.xml and also not with a refactored one
272306
if ("maven-site-plugin".equals(artifactId)
273-
&& (version.startsWith("3.12.1") || version.startsWith("3.20.") || version.startsWith("3.21."))) {
307+
&& (version.startsWith("3.12.1")
308+
|| version.startsWith("3.20.")
309+
|| version.startsWith("3.21.")
310+
|| version.startsWith("3.22."))) {
274311
return true;
275312
}
276313

0 commit comments

Comments
 (0)