You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mikhail Kalkov <mi...@purplescout.se> on 2012/07/26 14:37:37 UTC

JDT compiler compliance level as a parameter for eclipse:eclipse target of maven-eclipse-plugin

Hi,

I've tried to checkout Jenkins CI source code and generate an Eclipse project for it (see instructions in [1]). Unfortunately generated Eclipse projects seemed to contain errors, which I first reported as a Jenkins bug [2]. Further investigation revealed that even though Jenkins is build with "javac -source 1.5 -target 1.5" parameters, they use javac from JDK6u18 or later and rely on animal-sniffer plug-in to ensure that their code is java5-compliant. Unfortunately, it seems that neither Sun's javac nor Animal Sniffer noticed the presence of @Override annotations on methods implementing interfaces, which is not allowed in Java 5 and is ok in Java 6 [3]. On the other hand, Eclipse Java Compiler does notice them and mark each one as error.

Long story short, I tried to modify eclipse project generation so that in the .settings/org.eclipse.jdt.core.prefs instead of this:
    org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
    eclipse.preferences.version=1
    org.eclipse.jdt.core.compiler.source=1.5
    org.eclipse.jdt.core.compiler.compliance=1.5
I get this (look at the compliance):
    org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
    eclipse.preferences.version=1
    org.eclipse.jdt.core.compiler.source=1.5
    org.eclipse.jdt.core.compiler.compliance=1.6
but didn't find a way to configure maven-eclipse-plugin.

Has anybody else experienced this problem? Can you suggest any ideas?

[1] https://wiki.jenkins-ci.org/display/JENKINS/Building+Jenkins
[2] https://issues.jenkins-ci.org/browse/JENKINS-14579
[3] http://stackoverflow.com/questions/8220786/java-eclipse-override-error

Kind regards, 
Mikhail Kalkov 

Purple Scout AB 
Software Developer

Address: Ă–stra Hamngatan 31, SE- 41110 Gothenburg, Sweden
Phone:   +46 (0) 732 - 051405
E-mail:  mikhail.kalkov@purplescout.se
Web:     www.purplescout.se

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


Re: JDT compiler compliance level as a parameter for eclipse:eclipse target of maven-eclipse-plugin

Posted by Mikhail Kalkov <mi...@purplescout.se>.
Thanks for suggestions, Barrie and Wayne! I will have a look at maven-eclipse-plugin source code later.

To clarify,
  <source>1.5</source> corresponds to javac "-source" option and to ECJ "org.eclipse.jdt.core.compiler.source" setting
  <target>1.6</target> corresponds to javac "-target" option and to ECJ "org.eclipse.jdt.core.compiler.codegen.targetPlatform" setting
  org.eclipse.jdt.core.compiler.compliance is an ECJ setting, which doesn't have a direct counterpart either in javac options or in maven-compiler-plugin settings. I've really tried hard to figure out what exactly it means but Eclipse documentation [1] is vague about the meaning of this option. According to the JDT settings compatibility table [2], codegen.targetPlatform specifies the target VM version, and should never be less then the source version, whereas the source version and compliance settings are quite similar, but the former seems to be a refinement of the latter. After reading [3], [4] and [5] my best guess is that
   - compliance corresponds to Java language version,
   - source corresponds to Java class library version (see -bootclasspath option for javac),
   - target corresponds to Java VM version,
   - and Execution Environment setting would correspond to Java runtime version (see [6]).

At least, this explanation clarifies why I was able to use Java6 syntax sugar (@Override on interface implementation) with compliance set to 1.6, whereas source and target were set to 1.5. Still I may be wrong and the only way to get an authoritative answer is to ask on the JDT DEV mailing list. I'll ask them and hopefully come back later with an answer.

As for Sun's javac, it seems that compliance is always set to the jdk level, e.g. "javac -source 1.5 -target 1.5" with javac from jdk6u27 allows using @Override annotation on interface implementation.

[1] http://help.eclipse.org/juno/topic/org.eclipse.jdt.doc.user/reference/preferences/java/ref-preferences-compiler.htm
[2] Open http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Fguide%2Fjdt_api_options.htm , scroll down to "JDT Core options descriptions", click on "Builder options" and scroll a bit up to see the compatibility table
[3] https://bugs.eclipse.org/bugs/show_bug.cgi?id=323633#c23
[4] http://grepcode.com/file/repository.grepcode.com/java/eclipse.org/3.7/org.eclipse.jdt/core/3.7.0/org/eclipse/jdt/internal/compiler/batch/Main.java#Main.validateOptions%28boolean%29
[5] http://wiki.eclipse.org/index.php/Execution_Environment
[6] http://wiki.eclipse.org/PDE/Resources/Execution_Environments

Regards,
Mikhail

----- Original Message -----
From: "Barrie Treloar" <ba...@gmail.com>
To: "Maven Users List" <us...@maven.apache.org>
Sent: Friday, July 27, 2012 12:29:04 AM
Subject: Re: JDT compiler compliance level as a parameter for eclipse:eclipse target of maven-eclipse-plugin

On Fri, Jul 27, 2012 at 7:57 AM, Barrie Treloar <ba...@gmail.com> wrote:
> On Fri, Jul 27, 2012 at 7:13 AM, Wayne Fay <wa...@gmail.com> wrote:
>>> Long story short, I tried to modify eclipse project generation so that
>>> in the .settings/org.eclipse.jdt.core.prefs instead of this:
>>>     org.eclipse.jdt.core.compiler.compliance=1.5
>>> I get this (look at the compliance):
>>>     org.eclipse.jdt.core.compiler.compliance=1.6
>>> but didn't find a way to configure maven-eclipse-plugin.
>>
>> Most likely you are the first person to want this specific
>> configuration of the plugin, thus it does not currently exist. You'll
>> probably need to scratch your own itch.
>>
>> Pull down the source code for maven-eclipse-plugin, tweak it somehow
>> to add this feature, and contribute the code back for (possible)
>> inclusion in a future release.
>>
>> Here's a hint: you're going to want to adjust EclipseSettingsWriter
>> and probably some Eclipse plugin Mojo code too since this should be an
>> extra configuration item in the plugin...
>> http://maven.apache.org/plugins/maven-eclipse-plugin/xref/org/apache/maven/plugin/eclipse/writers/workspace/EclipseSettingsWriter.html
>
> Also remember, that the maven-eclipse-plugin reads the configuration
> of the maven-compiler-plugin.
> See http://maven.apache.org/plugins/maven-eclipse-plugin/trouble-shooting/jdk-being-used-is-different-than-expected.html
>
> So you ideally need to configure that the way you want.
> I'm not sure what
> org.eclipse.jdt.core.compiler.compliance=1.6
> actually does.
> Is this equivalent to
>
> <plugin>
>    <artifactId>maven-compiler-plugin</artifactId>
>    <version>2.0.2</version>
>    <configuration>
>        <source>1.5</source>
>        <target>1.6</target>
>    </configuration>
> </plugin>

Alternatively, you can fix your problem with the overrides and mark it
as something to worry about manually.
The time invested to fix this automatically may not be worth the effort.

---------------------------------------------------------------------
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


Re: JDT compiler compliance level as a parameter for eclipse:eclipse target of maven-eclipse-plugin

Posted by Barrie Treloar <ba...@gmail.com>.
On Fri, Jul 27, 2012 at 7:57 AM, Barrie Treloar <ba...@gmail.com> wrote:
> On Fri, Jul 27, 2012 at 7:13 AM, Wayne Fay <wa...@gmail.com> wrote:
>>> Long story short, I tried to modify eclipse project generation so that
>>> in the .settings/org.eclipse.jdt.core.prefs instead of this:
>>>     org.eclipse.jdt.core.compiler.compliance=1.5
>>> I get this (look at the compliance):
>>>     org.eclipse.jdt.core.compiler.compliance=1.6
>>> but didn't find a way to configure maven-eclipse-plugin.
>>
>> Most likely you are the first person to want this specific
>> configuration of the plugin, thus it does not currently exist. You'll
>> probably need to scratch your own itch.
>>
>> Pull down the source code for maven-eclipse-plugin, tweak it somehow
>> to add this feature, and contribute the code back for (possible)
>> inclusion in a future release.
>>
>> Here's a hint: you're going to want to adjust EclipseSettingsWriter
>> and probably some Eclipse plugin Mojo code too since this should be an
>> extra configuration item in the plugin...
>> http://maven.apache.org/plugins/maven-eclipse-plugin/xref/org/apache/maven/plugin/eclipse/writers/workspace/EclipseSettingsWriter.html
>
> Also remember, that the maven-eclipse-plugin reads the configuration
> of the maven-compiler-plugin.
> See http://maven.apache.org/plugins/maven-eclipse-plugin/trouble-shooting/jdk-being-used-is-different-than-expected.html
>
> So you ideally need to configure that the way you want.
> I'm not sure what
> org.eclipse.jdt.core.compiler.compliance=1.6
> actually does.
> Is this equivalent to
>
> <plugin>
>    <artifactId>maven-compiler-plugin</artifactId>
>    <version>2.0.2</version>
>    <configuration>
>        <source>1.5</source>
>        <target>1.6</target>
>    </configuration>
> </plugin>

Alternatively, you can fix your problem with the overrides and mark it
as something to worry about manually.
The time invested to fix this automatically may not be worth the effort.

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


Re: JDT compiler compliance level as a parameter for eclipse:eclipse target of maven-eclipse-plugin

Posted by Barrie Treloar <ba...@gmail.com>.
On Fri, Jul 27, 2012 at 7:13 AM, Wayne Fay <wa...@gmail.com> wrote:
>> Long story short, I tried to modify eclipse project generation so that
>> in the .settings/org.eclipse.jdt.core.prefs instead of this:
>>     org.eclipse.jdt.core.compiler.compliance=1.5
>> I get this (look at the compliance):
>>     org.eclipse.jdt.core.compiler.compliance=1.6
>> but didn't find a way to configure maven-eclipse-plugin.
>
> Most likely you are the first person to want this specific
> configuration of the plugin, thus it does not currently exist. You'll
> probably need to scratch your own itch.
>
> Pull down the source code for maven-eclipse-plugin, tweak it somehow
> to add this feature, and contribute the code back for (possible)
> inclusion in a future release.
>
> Here's a hint: you're going to want to adjust EclipseSettingsWriter
> and probably some Eclipse plugin Mojo code too since this should be an
> extra configuration item in the plugin...
> http://maven.apache.org/plugins/maven-eclipse-plugin/xref/org/apache/maven/plugin/eclipse/writers/workspace/EclipseSettingsWriter.html

Also remember, that the maven-eclipse-plugin reads the configuration
of the maven-compiler-plugin.
See http://maven.apache.org/plugins/maven-eclipse-plugin/trouble-shooting/jdk-being-used-is-different-than-expected.html

So you ideally need to configure that the way you want.
I'm not sure what
org.eclipse.jdt.core.compiler.compliance=1.6
actually does.
Is this equivalent to

<plugin>
   <artifactId>maven-compiler-plugin</artifactId>
   <version>2.0.2</version>
   <configuration>
       <source>1.5</source>
       <target>1.6</target>
   </configuration>
</plugin>

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


Re: JDT compiler compliance level as a parameter for eclipse:eclipse target of maven-eclipse-plugin

Posted by Wayne Fay <wa...@gmail.com>.
> Long story short, I tried to modify eclipse project generation so that
> in the .settings/org.eclipse.jdt.core.prefs instead of this:
>     org.eclipse.jdt.core.compiler.compliance=1.5
> I get this (look at the compliance):
>     org.eclipse.jdt.core.compiler.compliance=1.6
> but didn't find a way to configure maven-eclipse-plugin.

Most likely you are the first person to want this specific
configuration of the plugin, thus it does not currently exist. You'll
probably need to scratch your own itch.

Pull down the source code for maven-eclipse-plugin, tweak it somehow
to add this feature, and contribute the code back for (possible)
inclusion in a future release.

Here's a hint: you're going to want to adjust EclipseSettingsWriter
and probably some Eclipse plugin Mojo code too since this should be an
extra configuration item in the plugin...
http://maven.apache.org/plugins/maven-eclipse-plugin/xref/org/apache/maven/plugin/eclipse/writers/workspace/EclipseSettingsWriter.html

Wayne

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