I had a difficult time working out from the Apache Maven 2 site documentation how to build my JDK 5 projects with m2. I found the spot in the documentation for configuring plugins and reasoned that the Java compilation goal must be connected to a plugin, but did not see exactly how to tie it all together.
After several futile Google attempts, I finally hit upon trying pom.xml source target 1.5 and found this JIRA issue covering an example and including an attached pom.xml. Using the example, a basic POM (what was previously project.xml with Maven 1) is:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Maven Quick Start Archetype</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project> I got this by running the suggested new project generator:
m2 archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app
And adding the needed <build/> section.
2 comments:
Thanks ! That was what i needed.
Thanks! Worked just like the blog says.
Post a Comment