Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant use -source 7 or higher to enable diamond operator

Tags:

java

android

ant

I am sure this is pretty easy qoestion, but I am stuck with building Android app using Ant from commandline. I have got this message: (use -source 7 or higher to enable diamond operator). What do I add to buildfile to make it compile using Java 1.7?

like image 504
Heisenberg Avatar asked Apr 07 '14 13:04

Heisenberg


3 Answers

You need to set java.source and java.target. Either via -D:

ant release -Djava.source=7 -Djava.target=7

Or put it in ant.properties in your project:

# ant.properies contents:
java.source=7
java.target=7
like image 121
rzymek Avatar answered Nov 14 '22 07:11

rzymek


Solved it if anyone else is stuck on this one. I had to change <import file="${sdk.dir}/tools/ant/build.xml"/> file. There are properties <property name="java.target" value="1.5" /> <property name="java.source" value="1.5" /> and the values should be changed to 1.7

like image 17
Heisenberg Avatar answered Nov 14 '22 07:11

Heisenberg


Heisenberg's solution is correct (kudos and +1...) but not clean: you don't have to change the master build.xml file (bad!), what you need is to add the lines he suggested:

<property name="java.target" value="1.7" />
<property name="java.source" value="1.7" />

right before the line

<import file="${sdk.dir}/tools/ant/build.xml" />

in the local build.xml file, and the default options will be overridden.

Hope it helps!

like image 6
Rick77 Avatar answered Nov 14 '22 07:11

Rick77