[GRADLE-2662] ant:scalac using target jvm-1.5 Created: 29/Jan/13  Updated: 23/Apr/13  Resolved: 30/Mar/13

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 1.5-rc-1

Type: Bug
Reporter: Gradle Forums Assignee: Peter Niederwieser
Resolution: Fixed Votes: 1


 Description   

Question: Is there a way to change the JDK version being used by scalac?
On Ubuntu 12.10, JDK 7 | Scala version: 2.10.0 | Gradle 1.3
...
When I run build, don't get any errors but get the warning:
:compileScala
[ant:scalac] warning: -target:jvm-1.5 is deprecated: use target for Java 1.6 or above.
[ant:scalac] one warning found
...
build file has Scala dependencies as:
scalaTools 'org.scala-lang:scala-compiler:2.10.0'
compile 'org.scala-lang:scala-library:2.10.0'
...
gradle -v gives:
Gradle build time: Tuesday, November 20, 2012 11:37:38 AM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.7.0_09 (Oracle Corporation 23.2-b09)
OS: Linux 3.5.0-21-generic amd64
...
Thank you for your help.



 Comments   
Comment by Gradle Forums [ 29/Jan/13 ]

The Gradle ANT task for scalac doesn't appear to respect global targetCompatibility...I couldn't trace down the exact issue, but did come up with this workaround:

tasks.withType(ScalaCompile) {
scalaCompileOptions.additionalParameters = ['-target:jvm-1.6']
}

Comment by Gradle Forums [ 29/Jan/13 ]

Until Scala 2.10, the `scalac` Ant task only supported `jvm-1.5` (and `msil`). Starting with Gradle 1.3 and Scala 2.10, `targetCompatibility` should take effect (otherwise it's a bug).

Comment by Sonny To [ 19/Feb/13 ]

targetCompatibility is still not respected. tested on gradle 1.4 and scala 2.10

however, your hack works:

tasks.withType(ScalaCompile)

{ scalaCompileOptions.additionalParameters = ['-target:jvm-1.6'] }
Generated at Wed Jun 30 12:28:01 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.