File tree Expand file tree Collapse file tree
it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent
main/java/org/codehaus/mojo/versions Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ invoker.goals =${project.groupId}:${project.artifactId}:${project.version}:display-plugin-updates
Original file line number Diff line number Diff line change 1+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
2+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
3+ <modelVersion >4.0.0</modelVersion >
4+
5+ <groupId >localhost</groupId >
6+ <artifactId >it-101-parent</artifactId >
7+ <version >1.0</version >
8+ <packaging >pom</packaging >
9+ <name >display-plugin-updates-parent</name >
10+
11+ <build >
12+ <pluginManagement >
13+ <plugins >
14+ <plugin >
15+ <groupId >localhost</groupId >
16+ <artifactId >dummy-maven-plugin</artifactId >
17+ <version >1.0</version >
18+ </plugin >
19+ <plugin >
20+ <artifactId >maven-install-plugin</artifactId >
21+ <version >2.2</version >
22+ </plugin >
23+ <plugin >
24+ <artifactId >maven-site-plugin</artifactId >
25+ <version >2.0</version >
26+ </plugin >
27+ </plugins >
28+ </pluginManagement >
29+ </build >
30+
31+ </project >
Original file line number Diff line number Diff line change 1+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
2+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
3+ <modelVersion >4.0.0</modelVersion >
4+
5+ <parent >
6+ <groupId >localhost</groupId >
7+ <artifactId >it-101-parent</artifactId >
8+ <version >1.0</version >
9+ <relativePath >parent/pom.xml</relativePath >
10+ </parent >
11+
12+ <groupId >localhost</groupId >
13+ <artifactId >it-101</artifactId >
14+ <version >1.0</version >
15+ <packaging >pom</packaging >
16+ <name >display-plugin-updates</name >
17+
18+ <description >Ignore plugin used in this POM without version, which has a version defined in a parent POM.</description >
19+
20+ <build >
21+ <pluginManagement >
22+ <plugins >
23+ <plugin >
24+ <groupId >localhost</groupId >
25+ <artifactId >dummy-maven-plugin</artifactId >
26+ </plugin >
27+ <plugin >
28+ <artifactId >maven-clean-plugin</artifactId >
29+ <version >2.2</version >
30+ </plugin >
31+ <plugin >
32+ <artifactId >maven-deploy-plugin</artifactId >
33+ <version >2.3</version >
34+ </plugin >
35+ </plugins >
36+ </pluginManagement >
37+ </build >
38+
39+ </project >
Original file line number Diff line number Diff line change 1+ import java.io.*;
2+ import org.codehaus.plexus.util.FileUtils;
3+ import java.util.regex.*;
4+
5+ try
6+ {
7+ File file = new File( basedir, "build.log" );
8+ String buf = FileUtils.fileRead( file );
9+
10+ // output should not contain any message like 'localhost:dummy-maven-plugin .....' because this plugin should be ignored due to its version defined in parent POM
11+ Pattern p = Pattern.compile( "\\Qlocalhost:dummy-maven-plugin\\E\\s*\\.+" );
12+ Matcher m = p.matcher( buf.toString() );
13+ if ( m.find() )
14+ {
15+ System.out.println( "dummy-maven-plugin should not be listed in output, version is defined in Parent POM" );
16+ return false;
17+ }
18+ }
19+ catch( Throwable t )
20+ {
21+ t.printStackTrace();
22+ return false;
23+ }
24+
25+ return true;
Original file line number Diff line number Diff line change @@ -404,6 +404,13 @@ public void execute()
404404 {
405405 version = parentPlugins .get ( coords );
406406 }
407+
408+ boolean versionSpecifiedInCurrentPom = pluginsWithVersionsSpecified .contains ( coords );
409+ if ( !versionSpecifiedInCurrentPom && parentPlugins .containsKey ( coords ) ) {
410+ getLog ().debug ( "Skip " + coords + ", version " + version + " is defined in parent POM." );
411+ continue ;
412+ }
413+
407414 getLog ().debug ( "Checking " + coords + " for updates newer than " + version );
408415 String effectiveVersion = version ;
409416
@@ -515,7 +522,7 @@ public void execute()
515522
516523 String newVersion ;
517524
518- if ( version == null && pluginsWithVersionsSpecified . contains ( coords ) )
525+ if ( version == null && versionSpecifiedInCurrentPom )
519526 {
520527 // Hack ALERT!
521528 //
@@ -530,8 +537,8 @@ public void execute()
530537 getLog ().debug ( "[" + coords + "].version=" + version );
531538 getLog ().debug ( "[" + coords + "].artifactVersion=" + artifactVersion );
532539 getLog ().debug ( "[" + coords + "].effectiveVersion=" + effectiveVersion );
533- getLog ().debug ( "[" + coords + "].specified=" + pluginsWithVersionsSpecified . contains ( coords ) );
534- if ( version == null || !pluginsWithVersionsSpecified . contains ( coords ) )
540+ getLog ().debug ( "[" + coords + "].specified=" + versionSpecifiedInCurrentPom );
541+ if ( version == null || !versionSpecifiedInCurrentPom )
535542 {
536543 version = superPomPluginManagement .get ( coords );
537544 getLog ().debug ( "[" + coords + "].superPom.version=" + version );
You can’t perform that action at this time.
0 commit comments