aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes How to define an ant task for java version is 1.6.0_05 or higher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How to define an ant task for java version is 1.6.0_05 or higher" Watch "How to define an ant task for java version is 1.6.0_05 or higher" New topic
Author

How to define an ant task for java version is 1.6.0_05 or higher

albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245
How to define an Ant task to enforce that the java version should be 1.6.0_05 or higher?

The following build.xml fails with the error message:
BUILD FAILED
C:\workspace\Test_TIJ4\build.xml:51: The following error occurred while executing this line:
C:\workspace\Test_TIJ4\object\build.xml:29: J2SE6 required

build.xml (partial, not the entire file)
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

On line 9, the "unless" clause should check for "version1.6" - that is the property that the condition sets.

If you want to allow any 1.6 or 1.7 JVM, you could use this condition:



According to the docs, the ant.java.version property is only two parts: http://ant.apache.org/manual/properties.html#built-in-props

Why do you want to disallow a 1.6 JVM prior to 1.6.0_05?


JBoss In Action
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245
I want to allow any 1.6 or 1.7 JVM for jdk 1.6.0_05 or higher.
The ant version is 1.7.0 (I can't use a newer version).
The build.xml file is changed as per your advice and the error message is now:
BUILD FAILED
C:\workspace\Test_TIJ4\build.xml:51: The following error occurred while executing this line:
C:\workspace\Test_TIJ4\object\build.xml:21: equals doesn't support the "string" attribute

albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245
The build.xml file can be compiled by changing to:
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

Oops, sorry, when I started to write the code I meant to use the <substring> condition but switched to <equals> and then forgot to change the property names.

By the way, it is very distracting to quote the entire previous post when replying, so I removed the quotes for you.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to define an ant task for java version is 1.6.0_05 or higher