Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Java 12 support #970

Merged
merged 1 commit into from Mar 26, 2019
Merged

Add Java 12 support #970

merged 1 commit into from Mar 26, 2019

Conversation

fbricon
Copy link
Contributor

@fbricon fbricon commented Mar 25, 2019

Signed-off-by: Fred Bricon fbricon@gmail.com

@fbricon fbricon force-pushed the java12 branch 5 times, most recently from 5bacbb5 to 7ffc0a5 Compare Mar 25, 2019
@fbricon
Copy link
Contributor Author

@fbricon fbricon commented Mar 25, 2019

So far, all kind of projects support Java 12, with some caveats. Experimental features (like advanced switch expressions - JEP-325) may need specific tuning:

  • default/invisible projects have features enabled features by default, without warnings

  • Maven projects need to have the --enable-preview added to the maven-compiler-plugin configuration, in pom.xml. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=545462#c0, warnings are disabled automatically.

  • Eclipse projects need to add the the following preferences to .settings/org.eclipse.jdt.core.prefs:

    org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=enabled
    org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
    
  • Gradle projects can also maintain the same .settings/org.eclipse.jdt.core.prefs. Alternatively adding an eclipse.jdt.file.withProperties hook is possible, but requires the gradle compileJdt task to be invoked manually, as buildship doesn't use those hooks :

plugins {
    // Apply the java-library plugin to add support for Java Library
    id 'java-library'
    id 'eclipse'
}
sourceCompatibility = JavaVersion.VERSION_12
targetCompatibility = JavaVersion.VERSION_12

repositories {
     jcenter()
}
compileJava {
    options.compilerArgs += ["--enable-preview"]
}
compileTestJava {
    options.compilerArgs += ["--enable-preview"]
}
//Buildship doesn't use that hooks (https://discuss.gradle.org/t/when-does-buildship-eclipse-customization-run/20781/2)
//you need to run `gradle eclipseJdt` separately
eclipse.jdt.file.withProperties { props ->
    props['org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures']= 'enabled'
    props['org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures']= 'ignore'
}

test {
    jvmArgs '--enable-preview'
}

@fbricon fbricon marked this pull request as ready for review Mar 25, 2019
@fbricon fbricon requested a review from snjeza Mar 25, 2019
@fbricon
Copy link
Contributor Author

@fbricon fbricon commented Mar 25, 2019

test this please

@fbricon fbricon force-pushed the java12 branch 2 times, most recently from 7f84f30 to 572d127 Compare Mar 25, 2019
fixes eclipse#959

Signed-off-by: Fred Bricon <fbricon@gmail.com>
snjeza
snjeza approved these changes Mar 25, 2019
@fbricon fbricon merged commit 9247f79 into eclipse:master Mar 26, 2019
2 checks passed
@fbricon fbricon deleted the java12 branch Mar 26, 2019
@fbricon fbricon mentioned this pull request Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants