4

i managed to create my project structure using maven2. but when am compiling my project using mvn install getting error generics are not supported in -source 1.3

googled to build my project using jdk1.5 and added build tag

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.myProject</groupId>
  <artifactId>project</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>myapp</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>com.myProject</groupId>
           <artifactId>project</artifactId>
           <configuration>
               <source>1.5</source>
               <target>1.5</target>
           </configuration>
       </plugin>
     <plugins>
  </build>
</project>

but this is not working.

Any hints?

2 Answers 2

4

Add the maven-compiler-plugin to your build:

<build>
  <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
        <source>1.5</source>
        <target>1.5</target>
    </configuration>
    </plugin>
  </plugins>
</build>
Sign up to request clarification or add additional context in comments.

1 Comment

That's what I am doing, too. But is this really the easiest way? I thought Maven was all about "convention over configuration", but everyone must be using this (unintuitive) setting these days. Will they change the default one day (maybe with Maven 3)?
0

There's an "easier" way to accomplish this, without having to paste the same snippet all over your modules. You can set up a reactor and then you refer to it from all the other modules, like this:

  <parent>
    <groupId>com.foo.bar</groupId>
    <artifactId>reactor</artifactId>    
    <version>1.0-SNAPSHOT</version>
  </parent>

In the pom file of your reactor you have to put this:

<packaging>pom</packaging>

To let maven know that it's not a jar/war, etc.

Hope it helps

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.