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

0
14 comments

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?

0

Ismael,


Could you please post a screenshot of project settings (interested in Upsource properties section).

Thanks in advance.

0

I am using gradle.

0

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:

<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
   <output url="file://$PROJECT_DIR$/out" />
</component>


Please post yours one.

Thanks in advance.
0

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" />

0

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?

0

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?

0
Avatar
Permanently deleted user

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:

apply plugin: 'java'

sourceCompatibility = '1.7'
targetCompatibility = '1.7'

0

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:

  1. Open your Upsource project

  2. Click Browse code at the top of the revisions list

  3. Navigate to /.idea/gradle/gradle.out

If no such file exists:

  1. Navigate to /.idea/model.info

  2. Open model.info and copy the revision ID

  3. Using the search, locate that revision and open it up

  4. Click Browse code and navigate to /.idea/gradle/gradle.out

0
Avatar
Permanently deleted user

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".

0

Sergii,

By any chance, could you please share build.gradle and settings.gradle files with us?

Thanks in advance.

0
Avatar
Permanently deleted user

Hello,

I can't share the existing build files with you, but I'll try to prepare a reproducer project.

0
Avatar
Permanently deleted user

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
0

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.

0

Please sign in to leave a comment.