-
Notifications
You must be signed in to change notification settings - Fork 821
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
Override gradle's compiler version from compiler args. #4711
Override gradle's compiler version from compiler args. #4711
Conversation
please label PRs before creating them. This will be important in future #4431, otherwise this PR would run no gradle jobs for example. |
I knew about the labeling and CI. I'll try to keep that in mind. I didn't think I was able to change/add labels. |
oh my mistake - disregard what i said. I was sure you were already committer since you are so active (which is great!). I think you have to have at least committer role to be able to label things. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the implementation is Ok. The place is not so much. This is a kind of de-serialization code. So I would rather fix this at the source:
Line 357 in d27cbbc
model.getInfo().put(propBase + lang + "_compiler_args", new ArrayList<>(compilerArgs)); |
or right before the usage:
netbeans/java/gradle.java/src/org/netbeans/modules/gradle/java/api/GradleJavaSourceSet.java
Line 137 in d27cbbc
return sourcesCompatibility.getOrDefault(type, DEFAULT_SOURCE_COMPATIBILITY); |
I thought a builder would be good; immutable description. Looking at your two proposed locations, couldn't get breakpoints to work in NbProjectInfoBuilder, so that made up my mind. |
if(sourceType == SourceType.JAVA) { // only fixup for java | ||
List<String> args = getCompilerArgs(sourceType); | ||
if(args != null && !args.isEmpty()) { | ||
String flag = compatibilityMap == sourcesCompatibility ? "-source" : "-target"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: maybe pass the flag source/target explicitly rather than comparing Map instances ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first implementation did that (the one that was in the wrong place). I'll make that change after any other suggested changes have time to roll in. Thanks for the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I'd reduce the number of ifs: getCompilerArgs() never returns with null
, so line 184 could go. The double if in line 188 and 190 could be combined...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember now why I compared to map instance; because -source/-target are/might-be specific to java. I'll change the method name to fixJavaCompatibility
. I'd like to take out the souceType argument, but then the check for JAVA would, would have to be in the caller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
K
i am no heavy gradle user. But there is also the |
Yikes. Thanks for something real/detectable. What to do if Arbitrarily use the value with |
it replaces both, if you mix, javac should complain and fail as far as I know. It is similar to setting both source and target to the same value, but more powerful since javac will use ct.sym files which are basically method/class signature diffs and check that your code could actually run on the target JDK APIs. The maven template uses the source/target tags too still, if we end up adding some kind of JDK or language level selector to the new maven project wizard we could let it use that too if java 9+ is selected. |
Any further suggestions, comments, questions? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @errael !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, thanks for making it aware of the --release
flag too
Fix #4704. This applies to both
-source
and-target
. This information is used by editor/hints.With this patch and the following build.gradle excerpt
There's
and the following has no errors in the editor.