In Maven 2, if you didn’t specify the version for each plugins that used in pom.xml, it will pick the latest plugin version automatically, which is very convenient. However, in Maven 3, if you didn’t explicitly specify the plugin version, it will prompt you warning message. Read this “Maven 3 compatibility” for detail.

For example, in Maven 2, normally, we use the “maven-compiler-plugin” plugin without specifying the version, and it’s 100% valid.

        //...pom.xml in Maven 2
	<build>
		<finalName>SpringMVC</finalName>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
		</plugins>
	</build>
//...

However, in Maven 3, above declaration will prompt you following “WARNING” messages :

[INFO] Scanning for projects...
[WARNING] Some problems were encountered while building the effective model 
          for com.mkyong.common:SpringMVC:war:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin 
          is missing. @ line 55, column 12
[WARNING] It is highly recommended to fix these problems because they threaten 
          the stability of your build.
[WARNING] For this reason, future Maven versions might no longer support 
          building such malformed projects.

To fix it, just specify the plugin version like this :

        //...pom.xml in Maven 3
	<build>
		<finalName>SpringMVC</finalName>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
		</plugins>
	</build>
How to know what’s the Maven’s plugin version?
You can try search the plugin at http://search.maven.org/ , or visit the plugin website, for example – Maven compiler plugin official website.

References

  1. Maven 3 compatibility
  2. Maven compiler plugin
Tags :
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider making a donation to the charity, thanks.

Related Posts

Popular Posts