Closed Arthurm1 closed 1 month ago
I've also extended the POJO constructor copying used in DefaultSourceSets to the language extensions. It's not needed for normal running but it's a pain when debugging as all the variables/watches just show the proxy classes.
There is an issue about this: https://github.com/microsoft/build-server-for-gradle/issues/175. I also did some investigation and turns out the copy constructor is not needed for running.
I'm thinking that, for debugging purpose, maybe override toString()
is a better approach than using the copy constructor?
Update:
The copy constructor is required. If we remove all the copy constructor, here:
The sourceset is a proxy wrapperred type, and it will encounter some problem
The copy constructor is required. If we remove all the copy constructor, here:
Shall I leave my changes to DefaultJavaExtension
/DefaultScalaExtension
then or do you want them gone?
Shall I leave my changes to DefaultJavaExtension/DefaultScalaExtension
I think you can leave as it is. Until we find a way to get rid of the copy constructor entirely
@Arthurm1
I think we should use javaCompile.getSourceCompatibility()
and javaCompile.getTargetCompatibility()
.
AFAIK, there are three different kind of ways to set the source/target level.
1.
java {
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_9
}
2.
tasks.withType(JavaCompile) {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_9
}
3.
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_9
The current approach cannot get the version in case 2. While using the JavaCompile
instance can cover all three cases.
Considering JavaCompile
is official API which no need to use reflection, I prefer to use it directly.
Hi @Arthurm1, would you like to update the PR?
Or do you have any concern about javaCompile.getSourceCompatibility()
and javaCompile.getTargetCompatibility()
@jdneo Will look at it this weekend and probably change the PR
@Arthurm1 Thank you.
My thought is that we can just simply get the source/target level from JavaCompile, no need to inspecting from compile args. (Correct me if this is working for any cases)
@jdneo I've changed it so that the source/target compatibility is populated purely from the JavaCompile
task. JavacOptions
are still passed back for BSP but they are ignored for compatibility settings.
This seems to reflect more how people use the Gradle settings, i.e. set source/target compatibility in JavaCompile
for IDE usage and the JavacOptions
for jar and release.
Thank you @Arthurm1
This will take into account the
java plugin
source/target compatibility settings. e.g. using...instead of
I'm not sure if this is enough to fix https://github.com/redhat-developer/vscode-java/issues/3721. The source/target compatibility in
JVMBuildTarget
will have changed but the javac options will still contain--release 8
. Hopefully that will be ok for the eclipse settings.I note that here it says to configure the
compileJava
task with source/target and not thejava
plugin when usingJabel
I've also extended the
POJO
constructor copying used inDefaultSourceSets
to the language extensions. It's not needed for normal running but it's a pain when debugging as all the variables/watches just show the proxy classes.