Adding Some XML To Netbeans POM Files

I am working on a small program with Netbeans. I chose to make this project a Maven project. But when I ran “mvn compile” on the command line outside of Netbeans, the program would not compile.

After doing some searching, I found that I needed to add some XML to the POM file:

     <build>
        <finalName>Project Name</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

It would be nice if Netbeans just included that automatically.

It is interesting that IDEs now support Maven, and that Maven is getting a lot of traction in the industry. When it first came out, people thought it was too restrictive, and now “convention over configuration” is the rage. A lot of people looked at it and thought, “Why do we need this? We already have Ant.” But it looks like Maven is overtaking Ant. (This is a subjective, anecdotal observation.)

Image from Wikipedia