@@ -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