Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Java version mismatch between maven settings and formatting settings file may cause inconsistent results #24

Closed
Legioth opened this issue Jan 30, 2017 · 3 comments

Comments

@Legioth
Copy link

Legioth commented Jan 30, 2017

This issue occurs when using a legacy formatting settings file that defines an older Java version for org.eclipse.jdt.core.compiler.codegen.targetPlatform, org.eclipse.jdt.core.compiler.compliance or org.eclipse.jdt.core.compiler.source.

It seems like the Java version number configured through Maven will still be used for the main parsing of the java files since most new Java syntax features are processed and formatted without problems. One case where this causes issues is when using _ in numeric literals (introduced in Java 7). Any such occurrence will cause the entire method containing the numeric literal to become misformatted (see #20).

This appears to be different than how things work in Eclipse where the Java version configured for the project seems to override the version in the formatter settings. One indication of this behaviour is the Java version settings are updated when exporting settings that have been imported from a file with older versions.

I would suggest that the the plugin either automatically overrides those settings based on the Maven configuration, or alternatively outputs a warning if the settings are not in sync.

@velo
Copy link
Owner

velo commented Jan 30, 2017

You could use compilerSource, compilerCompliance and compilerTargetPlatform to override this settings.

The plugin takes the default from maven.compiler.source and maven.compiler.target, which may or may not be available.

Ideal it would read the compiler plugin section, that that ain't that easy.

velo added a commit that referenced this issue Feb 10, 2017
@velo velo closed this as completed Feb 10, 2017
@velo
Copy link
Owner

velo commented Feb 10, 2017

Please try it on 1.9.1.RC2

@Legioth
Copy link
Author

Legioth commented Feb 14, 2017

Yes, now it works as expected even if using legacy formatting setting files. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants