mavennetbeansmaven-plugin

Netbeans Maven annotations not supported in source 1.3, use source 5


When building my projects using Maven from Netbeans 6.7, I get these error messages:

Error   annotations are not supported in -source 1.3   (use -source 5 or higher to enable annotations)

I've already seen on this thread that I need to add a maven-compiler-plugin configuration to my POM.xml, but I don't want to do this to every project. Can I set this in one central location that will affect all my maven projects? In settings.xml somehow?

I've already configured Netbeans to use Maven 3.0.3 and my JAVA_HOME is pointing to JDK 1.5.


Solution

  • Even if it is quiet simple using Netbeans to configure this in each project :

    A better approach will be to use (inheritance in poms) .

    Configure the plugin in a parent pom.xml :

            <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
          <groupId>com.mycompany</groupId>
          <artifactId>parent-pom</artifactId>
          <version>1.0-SNAPSHOT</version>
          <packaging>pom</packaging>
          <name>parent-pom</name>
          <build>
              <plugins>
                  <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>2.3.2</version>
                        <configuration>
                            <source>1.3</source>
                            <target>1.3</target>
                        </configuration>
                    </plugin>
              </plugins>
          </build>
        </project>
    

    Then after, your modules can inherit this behaviour this way :

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.mycompany</groupId>
        <artifactId>parent-pom</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <artifactId>mavenproject1</artifactId>
    <packaging>jar</packaging>
    <name>mavenproject1</name>