[GRADLE-2198] Tooling API: Deduce project language level from the java plugin properties via the Tooling API Created: 27/Mar/12 Updated: 11/Mar/16 Resolved: 17/Feb/16 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 1.0-milestone-9 |
Fix Version/s: | 2.11-rc-1 |
Type: | Bug | ||
Reporter: | Denis Zhdanov | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 37 |
Attachments: | スクリーンショット 2016-03-06 22.05.52.png |
Description |
Consider the following simple script: build.gradle apply plugin: 'java' configurations { all*.exclude group: 'commons-logging', module: 'commons-logging' } repositories { mavenLocal() } dependencies {} test { useTestNG() } compileJava { sourceCompatibility = '1.7' targetCompatibility = '1.7' options.encoding = 'UTF-8' options.compilerArgs = ['-Xlint', '-Xlint:-serial', '-Xlint:-path'] } compileTestJava { sourceCompatibility = '1.7' targetCompatibility = '1.7' options.encoding = 'UTF-8' options.compilerArgs = ['-Xlint', '-Xlint:-serial', '-Xlint:-path'] } We're expecting to see language level '1.7' from org.gradle.tooling.model.idea.IdeaProject.getLanguageLevel() built against the script. Unfortunately, it always returns 1.6 (default value?). |
Comments |
Comment by Szczepan Faber [ 24/Apr/12 ] |
Hey, You should configure the compatibility outside of the tasks, i.e. as top-level elements of the build.gradle: apply plugin: 'java' sourceCompatibility = '1.7' targetCompatibility = '1.7' |
Comment by Szczepan Faber [ 24/Apr/12 ] |
Denis, If the users prefers different language level than the one assigned by Gradle he can configure it: http://gradle.org/docs/current/dsl/org.gradle.plugins.ide.idea.model.IdeaProject.html#org.gradle.plugins.ide.idea.model.IdeaProject After configuring it, the tooling api will use that setting. I'll close this issue if that's ok. Please reopen if necessary! |
Comment by Szczepan Faber [ 18/May/12 ] |
Yet another incarnation of somewhat poor support for language level in the Gradle's idea plugin. Blocking this JetGradle feature: http://youtrack.jetbrains.com/issue/IDEA-83528 |
Comment by Dimitar Dimitrov [ 03/Mar/15 ] |
There is still no way to set language level per module (as opposed to globally for the project). A use case would be, where we have a project that has multiple modules, some of them API libraries, shared with other applications. We need the whole project to use 1.8, except for the API we need to keep to 1.6. Our Gradle build does proper cross-compilation, and we can hack the IDEA projects generated from Gradle, but the IDEA tooling can not access the per module language level as it is not exposed by the tooling api. |
Comment by Asaf Mesika [ 30/Nov/15 ] |
I have a multi module projects. I've placed the attributes as specified in the top level build.gradle file, and still IDEA looks at my module as if it is Java 6 instead of java 8: sourceCompatibility = 1.8 targetCompatibility = 1.8 |
Comment by Maciej Łabędzki [ 03/Dec/15 ] |
Hi Guys, For time being, can you suggest some work-around for this issue? |
Comment by Michel Jung [ 16/Jan/16 ] |
Is this project dead? Almost 4 years later, no solution? |
Comment by Vasiliy Kudriyavtsev [ 12/Feb/16 ] |
Can any one clarify the status of this issue? It had been targeted for gradel 2.11-rc1, then reopened, but gradle 2.11 final Release Notes (https://docs.gradle.org/current/release-notes#enhanced-support-for-developing-java-projects-in-intellij-idea-and-eclipse) mention it like implemented. |
Comment by Jacob Ilsø [ 12/Feb/16 ] |
From reading the 2.11 release notes I think IDEA needs a change as well to support this. |
Comment by J Q [ 06/Mar/16 ] |
This issue has not been fixed yet. I have a gradle Java project. The build.gradle file is here,
apply plugin: 'java'
...
sourceCompatibility = 1.8
targetCompatibility = 1.8
...
When i run gradle in command line, the sourceCompatibility/targetCompatibility property does works. Then, i use IntelliJ IDEA 15 to import this gradle project, it generates some configuration files in .idea dir. <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/classes" /> </component> Once i change IDEA's Default Project Structure's Project Language Level to 8, (see above screenshot, change 6 to 8), <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/classes" /> </component> |
Comment by nabarun nag [ 11/Mar/16 ] |
I am still facing the same issue with language level defaulting back to 6 while the gradle file had the setting [ Gradle 2.11 and IntelliJ 15CE] javac.configure { sourceCompatibility '1.8' targetCompatibility '1.8' options.encoding = 'UTF-8' } After reading through the 2.11 release docs,
I tried setting the languageLevel as 1.8 but IntelliJ threw an error idea { project{ languageLevel = '1.8' } module { downloadSources = true scopes.PROVIDED.plus += [ configurations.provided ] } } Error :
Any updates or code modification are welcomed. |