How to specify Java versions since sourceCompatability is disregarded?


(Chris Dagnon) #1

Hello all,

I’m coming into an existing codebase. I’m working with one of several small projects, and I’m having problems running gradle. I’ve gotten “>gradle eclipse” to work okay, but even then it specifies Java version 1.6 in the generated eclipse files instead of 1.7.

When I do “>gradle fatJar” it gives me back this:

The ConfigurationContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
The TaskContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties.
Deprecated dynamic property: "sourceCompatability" on "root project 'api'", value: "1.7".
Deprecated dynamic property: "targetCompatability" on "root project 'api'", value: "1.7".

So I tried going to the described URL (http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html) but your website only gives me a 404. There also seems to be nothing on the web about how to update these things so they work (again, I assume).

This is my first time with Gradle, and this build.gradle just has these two lines after all the “apply plugin” lines, but no deeper block specification like I’ve seen in other forum posts:

sourceCompatability = 1.7
targetCompatability = 1.7

“> gradle -v” says: Gradle 1.8 Groovy: 1.8.6 JVM: 1.6.0_18 …

It looks like there’s no command-line options for specifying a JVM or Java version, either.

Any hints on how to make this work?

Thanks!


(Peter Niederwieser) #2

You misspelled the properties, and that’s why you got the warnings. (In Gradle 2.0 these will be errors.) The correct spelling is ‘sourceCompatibility’ and ‘targetCompatibility’.

So I tried going to the described URL (http://gradle.org/docs/current/dsl/or…) but your website only gives me a 404.

Works fine for me.