Bug 420848 - maven-compiler-plugin source/target 1.8 not recognized
Summary: maven-compiler-plugin source/target 1.8 not recognized
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: m2e (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-01 04:58 EDT by Daniel Dietrich CLA
Modified: 2021-04-19 13:25 EDT (History)
6 users (show)

See Also:


Attachments
Proposed patch for m2e-core, adding java compiler settings for java 8 (2.70 KB, patch)
2013-11-01 16:49 EDT, Daniel Dietrich CLA
no flags Details | Diff
Unit test for compiler settings patch (2.91 KB, patch)
2013-11-01 16:50 EDT, Daniel Dietrich CLA
no flags Details | Diff
[UPDATE] Proposed patch for m2e-core, adding java compiler settings for java 8 (2.71 KB, patch)
2013-11-04 03:52 EST, Daniel Dietrich CLA
no flags Details | Diff
[UPDATE] Unit test for compiler settings patch (2.92 KB, patch)
2013-11-04 03:54 EST, Daniel Dietrich CLA
no flags Details | Diff
[UPDATE-2] Proposed patch for m2e-core, adding java compiler settings for java 8 (3.24 KB, patch)
2013-11-04 18:26 EST, Daniel Dietrich CLA
no flags Details | Diff
[UPDATE-2] Unit test for compiler settings patch (3.45 KB, patch)
2013-11-04 18:27 EST, Daniel Dietrich CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Dietrich CLA 2013-11-01 04:58:11 EDT
Eclipse sets JRE System Library to [J2SE-1.4] when importing a Java 8 maven project.

Example
-------
<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>my.group</groupId>
    <artifactId>test-project</artifactId>
    <packaging>jar</packaging>
    <version>1.0</version>
    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Building a project with Java 8 sources on the command line (mvn clean package) works fine.

Workaround
----------
Setting JRE System Library manually to JavaSE-1.8.

System configuration
--------------------
* Mac OS X 10.9 Mavericks
* Eclipse 4.3.1 Kepler
* BETA_JAVA8 Plugins (Update site: http://dist.springsource.com/snapshot/TOOLS/java8/e43)
* JDK8 early access build 112 (https://jdk8.java.net/download.html)
Comment 1 Igor Fedorenko CLA 2013-11-01 07:34:54 EDT
Although I plan to get to this eventually, I don't have immediate need for java8 support and unlikely to look at this in the next several months. Consider providing a quality patch (including an automated test) if you want this sooner. 


To see what's involved in the patch, see java 6/7 aliases support

http://git.eclipse.org/c/m2e/m2e-core.git/commit/?id=691af24c2b882426c1c544d213d481e2c0276d69

https://github.com/tesla/m2e-core-tests/commit/24e62f67a5e6d3cde607415d4c1d61e07cecd313

m2e development environment setup and contribution guidelines are explained in http://wiki.eclipse.org/M2E_Development_Environment
Comment 2 Daniel Dietrich CLA 2013-11-01 12:49:58 EDT
Thank you for the quick response and providing me with the details. I took a look at the source and will submit a patch.
Comment 3 Daniel Dietrich CLA 2013-11-01 16:49:18 EDT
Created attachment 237137 [details]
Proposed patch for m2e-core, adding java compiler settings for java 8
Comment 4 Daniel Dietrich CLA 2013-11-01 16:50:24 EDT
Created attachment 237138 [details]
Unit test for compiler settings patch
Comment 5 Daniel Dietrich CLA 2013-11-01 16:58:18 EDT
Btw - I had to build the local test repository 'm2e-core-tests/org.eclipse.m2e.tests/target/localrepo' by hand for the unit test. I had tons of missing dependencies (**/*.lastUpdated). After setting up the local repository the test was green.
It is my first contribution to an eclipse project, so it is likely to be my fault setting up the dev workspace the wrong way...
Comment 6 Daniel Dietrich CLA 2013-11-02 08:02:30 EDT
Here is an update site targeting eclipse 4.3 kepler for testing purpose
http://danieldietrich.net/p2/m2e/snapshot/java8/e43
Comment 7 Igor Fedorenko CLA 2013-11-03 22:15:39 EST
Can you please attach version of patches with correct author email? I can't accept patches (and git.eclipse.org wouldn't let me) unless commit author email is the same email you used to sign eclipse CLA. Otherwise look good.

Not sure why you had problems running the tests. They are expected to run without any extra configuration. I'll try to see if I can reproduce the problem with fresh/clean m2e sources close.
Comment 8 Daniel Dietrich CLA 2013-11-04 03:52:41 EST
Created attachment 237162 [details]
[UPDATE] Proposed patch for m2e-core, adding java compiler settings for java 8

Changed patch author email to be conform with CLA
Comment 9 Daniel Dietrich CLA 2013-11-04 03:54:00 EST
Created attachment 237163 [details]
[UPDATE] Unit test for compiler settings patch

Changed patch author email to be conform with CLA
Comment 10 Daniel Dietrich CLA 2013-11-04 04:25:28 EST
I updated the patches - the should be now ok regarding the CLA.

Also I re-ran the unit tests on a freshly checked out repo:
The are 64 Failures of 442 tests and 0 errors.

The message of failed tests seems always to be the same (for the tests I looked at):
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
junit.framework.AssertionFailedError: Unexpected error markers Type=org.eclipse.m2e.core.maven2Problem.mavenarchiver.error:Message=Failure to find org.apache.maven:maven-archiver:jar:2.3 in file:repositories/remoterepo was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced:LineNumber=1 expected:<0> but was:<1>
	at junit.framework.Assert.fail(Assert.java:57)
	at junit.framework.Assert.failNotEquals(Assert.java:329)
	at junit.framework.Assert.assertEquals(Assert.java:78)
	at junit.framework.Assert.assertEquals(Assert.java:234)
	at org.eclipse.m2e.tests.common.WorkspaceHelpers.assertNoErrors(WorkspaceHelpers.java:189)
	at org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase.assertNoErrors(AbstractMavenProjectTestCase.java:467)
	at ...
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

I run the unit tests from within eclipse by running m2e-core-tests/org.eclipse.m2e.tests as JUnit Plug-in test.

The maven settings are read from m2e-core-tests/org.eclipse.m2e.tests/settings.xml. The active profiles are
  <activeProfiles>
    <activeProfile>testrepo</activeProfile>
    <activeProfile>localcentral</activeProfile>
  </activeProfiles>

Perhaps these settings are the reason for the missing org.apache.maven:maven-archiver:jar:2.3 ??
Comment 11 Igor Fedorenko CLA 2013-11-04 09:28:33 EST
Apparently, you also need to "sign-off" your contribution to make git.eclipse.org happy http://wiki.eclipse.org/Development_Resources/Contributing_via_Git. Maybe it's me, but this "simplified" git contribution process feels more complicated compared to what we had before. Lets see how many more tries it'll take to get this in :-(
Comment 12 Daniel Dietrich CLA 2013-11-04 18:26:24 EST
Created attachment 237184 [details]
[UPDATE-2] Proposed patch for m2e-core, adding java compiler settings for java 8

Added sign-off entry in commit message footer
Comment 13 Daniel Dietrich CLA 2013-11-04 18:27:19 EST
Created attachment 237185 [details]
[UPDATE-2] Unit test for compiler settings patch

Added sign-off entry in commit message footer
Comment 14 Daniel Dietrich CLA 2013-11-04 18:36:01 EST
No problem! I'm thankful you take the time to guide me through these steps.

The commit message of the patch now contains the following, accordingly to the wiki page you mentioned:
---
<bug-no> - <short message>

<long description>

This contribution complies with http://www.eclipse.org/legal/CoO.php

Bug: <url>
Signed-off-by: <signed-off-by>
---

I've learned much so far - next time I will be faster :-)
Comment 15 Igor Fedorenko CLA 2013-11-04 19:13:14 EST
I was finally able to push these. Thank you for your contribution. 

http://git.eclipse.org/c/m2e/m2e-core.git/commit/?id=18efa30c0781afe093157fd0a22fb49d3e4643ec

https://github.com/tesla/m2e-core-tests/commit/84d401bc43173028b75e56c0135065a5fa3d32a2


I don't believe accepting a small (but very useful!) contribution should be this complicated, but this is the eclipse way unfortunately.
Comment 16 Daniel Dietrich CLA 2013-11-04 19:24:37 EST
Great to hear!

I will bookmark this url as reference for future commits ;-)
Comment 17 Scott Carey CLA 2014-03-12 19:34:31 EDT
I tried the latest Java8-BETA integration from 

http://build.eclipse.org/eclipse/builds/4P/siteDir/updates/4.3-P-builds

with m2e from

http://danieldietrich.net/p2/m2e/snapshot/java8/e43

and nothing maven + java-8 works.  It now properly seems to set all projects to use JRE-1.8, but most of them are still compiling with 1.4.

If I "quick fix" one of them, for example to 1.7 because of the use of the diamond operator, it will set 1.7, but no longer allow 'Use compliance from execution environment "JavaSE-1.8"' and only allow changing 'Compiler Compliance Level' back to 1.8, and then a project will work.

I can not get any project to automatically configure itself properly with m2e, either a fresh newly imported project or one that has been told to re-configure from pom.xml.


Am I using the right update sites to test out the beta Java-8 support with M2e? 

Will the eclipse Java 8 support for Kepler include a working m2e?
Comment 18 Daniel Dietrich CLA 2014-03-12 19:42:40 EDT
(In reply to Scott Carey from comment #17)

Hi Scott,

1) Please install 'Eclipse IDE for Java EE Developers' (Kepler 4.3.2). Other bundles of Eclipse seem not to work properly with my update site (see 3))

2) Install http://build.eclipse.org/eclipse/builds/4P/siteDir/updates/4.3-P-builds

3) Install http://danieldietrich.net/p2/m2e/snapshot/java8/e43

This works fine for me. Here is an example Java 1.8 maven project, which imports fine:

https://github.com/rocketscience-projects/javaslang
Comment 19 Scott Carey CLA 2014-03-12 20:09:00 EDT
About Eclipse dialog:

"Eclipse IDE for Java Developers

Version: Kepler Service Release 2
Build id: 20140224-0627"

I do not believe it is the "for Java-EE" flavor, but I do not want that one and all its baggage, and I would be surprised if the ordinary java components are not good enough, without WTP.

I have an aggregate project with over 50 sub-projects (several nested) that I am testing.  I am trying other things that might have an effect, since the UI claims that all the projects are configured for JavaSE-1.8 compliance (via the execution environment) but the error messages from affected projects are as if it is trying to compile with 1.4 (it does not know what an enum is, for example).

Since m2e configures the projects to get the 1.8 compliance settings "from" the JavaSE-1.8 execution environment, I'm going to try and remove and add the Java8 JVM and re-map it to the execution environment and see if that helps.

Note:  It appears as though only some projects are affected, not all of them.
Comment 20 Scott Carey CLA 2014-03-12 21:31:10 EDT
Ok, I was able to get it to work, but I had to blow away all project configurations and start over.

m2e's "Maven -> Update Project..." process does not seem to purge stale information and properly reconfigure this.

When I start from scratch and delete all the .project, .classpath, and .settings directories, it seems to be fine.
Comment 21 Scott Carey CLA 2014-03-18 16:10:26 EDT
Now that Kepler SR2 with Java 8 support is officially released, how does one get official Java 8 support for m2e on Kepler SR2?

http://download.eclipse.org/eclipse/updates/4.3-P-builds/  does not seem to have it, and http://danieldietrich.net/p2/m2e/snapshot/java8/e43 is not official.

http://eclipse.org/m2e/download/  and related content does not show any releases in the last ~ 6 months.   Will there be one soon to support Java 8?
Comment 22 Fred Bricon CLA 2014-03-18 16:18:18 EDT
m2e 1.5 M6, which supports Java 8, can be installed from http://download.eclipse.org/technology/m2e/milestones/1.5

However, if you're doing Java EE development, please note that no Java 8 Facet is available from WTP yet. See bug #430637
Comment 23 Olaf Krische CLA 2014-03-31 06:10:17 EDT
An inofficial patch for java8 facets is now available, see #430637
Comment 24 Denis Roy CLA 2021-04-19 13:25:54 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/