maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kalle Korhonen <kalle.o.korho...@gmail.com>
Subject Re: Freaking out: javac works, maven-compiler-plugin does not
Date Fri, 07 May 2010 07:16:36 GMT
Are you absolutely positively sure your command-line javac is of the
same minor version as what Maven uses? 1.5 doesn't implement generics
captures so you'd get these kinds of problems if you tried to compile
the same with 1.6 - source is not version compatible even if binary
is.

Kalle


On Thu, May 6, 2010 at 1:27 PM, Matthew Adams <matthew@matthewadams.me> wrote:
> I have a class that compiles fine using javac, but does not compile
> when building with the maven-compiler-plugin.
>
> Here's the class source.  Basic java.
>
> import java.lang.annotation.ElementType;
> import java.lang.annotation.Retention;
> import java.lang.annotation.RetentionPolicy;
> import java.lang.annotation.Target;
>
> @Target( { ElementType.METHOD, ElementType.CONSTRUCTOR })
> @Retention(RetentionPolicy.RUNTIME)
> public @interface RequiresMutability {
>    boolean value() default true;
>
>    Class<? extends RuntimeException> throws_() default RuntimeException.class;
> }
>
> When compiling with the following command, everything works fine:
>
> javac -source 1.6 -target 1.6 src/main/java/.../RequiresMutability.java
>
> When I compile using Maven, it barfs:
>
> [INFO] -------------------------------------------------------------
> [ERROR] COMPILATION ERROR :
> [INFO] -------------------------------------------------------------
> [ERROR] /home/madams/dev/commons-trunk/domain/src/main/java/org/piercecountywa/commons/domain/annotations/RequiresMutability.java:[21,72]
> incompatible types
> found   : java.lang.Class<java.lang.RuntimeException>
> required: java.lang.Class<? extends java.lang.RuntimeException>
>
> [INFO] 1error
> [INFO] -------------------------------------------------------------
> [INFO] ------------------------------------------------------------------------
> [ERROR] BUILD FAILURE
> [INFO] ------------------------------------------------------------------------
> [INFO] Compilation failure
>
> This project's pom has almost nothing in it besides the declaration of
> its parent and a few of dependencies:  one on another
> application-specific artifact, one on OpenJPA, and one on junit (with
> scope of test).  Its parent pom configures the maven-compiler-plugin:
>
>      <plugin>
>        <groupId>org.apache.maven.plugins</groupId>
>        <artifactId>maven-compiler-plugin</artifactId>
>        <version>2.3</version>
>        <configuration>
>          <source>1.6</source>
>          <target>1.6</target>
>        </configuration>
>      </plugin>
>
> Can anyone tell me why maven-compiler-plugin barfs on the class above
> but javac likes it just fine?
>
> $ mvn -version
> Apache Maven 2.2.1 (r801777; 2009-08-06 12:16:01-0700)
> Java version: 1.6.0_18
> Java home: /home/madams/programs/java/jdk1.6.0_18/jre
> Default locale: en_US, platform encoding: UTF-8
> OS name: "linux" version: "2.6.32-22-generic" arch: "amd64" Family: "unix"
>
> -matthew
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Mime
View raw message