Sunday, October 6, 2013

06 - Introduction to Plugins with the Maven Compiler Plugin



Here you see a plug in called maven compiler which has configuration tags source and target. Source is nothing but JVM version and target for runtime is 1.4. This is there because while choosing archetype jee verion 1.4, if I choosen jee 5 then this would be 1.5.
Default source is 1.4, if you don’t  fine in pom.xml maven takes 1.4 as default.
If you are trying to write Generic method of 1.5 then you need to change the source to 1.5.
Here what I will try to run some Generic method of 1.5 which generates error.
Let create a class in src eg. MyClass.java
public class MyClass{
                public static void main(String[] args){
                List<String> stringList = new ArrayList<String>();
                }
}

mvn compile -> here is the error “generics not supported in source 1.4”. It is coming from pom.xml, now change the source to 1.5 and target to 1.5. now compile again mvn compile.
Now remove the source plugin and compile again it works fine.

No comments:

Post a Comment