How to specify java source code compatibility to 1.7
In our code we use java 1.7 source but upsource seems to be using 1.6. Is there a way to change this ?
We are using jdk 8
In the analyzer info we see errors like
Diamond types are not supported at this language level
Please sign in to leave a comment.
Hi Ismael,
Upsource 2.0 uses java 1.8 by default, so what you described sounds like wrong behavior.
Could you please clarify what build system are you using?
Ismael,
Could you please post a screenshot of project settings (interested in Upsource properties section).
Thanks in advance.
I am using gradle.
Ismael,
Could you please go to Upsource -> Browse Code, in the opened tree navigate to .idea folder, open misc.xml file and at the bottom of the file find a block, that should look like this:
<output url="file://$PROJECT_DIR$/out" />
</component>
Please post yours one.
Thanks in advance.
It seems that is taking wrong version
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-type="JavaSDK" assert-jdk-15="true" project-jdk-name="1.8">
<output url="file://$PROJECT_DIR$/out" />
Thanks! As you could see language level is set to JDK_1_6. Could you please clarify how you set up language level for your Gradle project?
Thanks! As you could see language level is set to JDK_1_6.
Could you please clarify how you do set up JDK version in your Gradle project?
Hi,
Although I'm not the original author, I have exatly the same question: how can one configure the language level for a gradle project?
Following your info from above posts i went into .idea/misc.xml
The line you asked about contained:
/component><component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-type="JavaSDK" assert-jdk-15="true" project-jdk-name="1.8">
As you can see - upsource is using the jdk-1.8, but the project language level is configured to be 1.6.
I have a strong feeling that the wrong language level configuration is related to the issue I filed more than a year ago.
The issue also contains the description of how the source and target compatibility versions are set in the build file:
Hi,
While converting gradle model to idea one we don't use IDEA engine, but gradle_idea plugin, so most likely it's not that bug. Convertation process is fully logged in gradle.out file you might check it for errors that happened during this convertation if any.
To find gradle.out file:
Open your Upsource project
Click Browse code at the top of the revisions list
Navigate to /.idea/gradle/gradle.out
If no such file exists:
Navigate to /.idea/model.info
Open model.info and copy the revision ID
Using the search, locate that revision and open it up
Click Browse code and navigate to /.idea/gradle/gradle.out
I just checked: there are no errors in the gradle.out. The project model is built successfuly, but the language level is set to "JDK_1_6".
Sergii,
By any chance, could you please share build.gradle and settings.gradle files with us?
Thanks in advance.
Hello,
I can't share the existing build files with you, but I'll try to prepare a reproducer project.
Hello,
I've created a reproducer project: https://github.com/svozniuk/upsource-gradle
Add this project to your upsource. Have the project model built and project indexed (it should not take a lot of time, since the project is almost empty).
Then check misc.xml - JDK_1_6 is configured regardless the 1.7 set in the gradle build files.
Another way to verify it - go to the com.test.one.Client - the 1.7 diamond operator <> is considered invalid by the analyzer.
Regards,
Sergii
Project config is attached
Attachment(s):
Screenshot from 2015-06-08 12:30:03.png
Hi Sergii,
Thank you very much for reproducing it!
Here is a corresponding bug in our tracker https://youtrack.jetbrains.com/issue/UP-4246 Please watch it for any updates.
Thanks in advance.