tags:

views:

101

answers:

3

I would like to get the number of availableProcessors from with my Ant build script (i.e. value that is returned from Runtime.getRuntime().availableProcessors(). Is there an existing property that contains this value or do I have to write a custom ant task?

A: 

I never heard about such a property, thus I think you should write your custom task.

Manu

Manuel Selva
A: 

The JVM does not provide such a property and neither does ant. Instead of writing a custom task you could do one of the following:

  1. Write a Java class that prints the number of processors to standard output. Use the java task with the outputproperty attribute to set the value to a property for use in ant.
  2. If you are only ever building one a single platform use the exec task to call something native that prints the number of processors to standard output. As above use the outputproperty attribute to set the value to a property for use in ant.
Mark
Runtime.getRuntime().availableProcessors() is provided by the JVM
dfa
A method call is not a property, hence you need code to get to it.
Thorbjørn Ravn Andersen
+1  A: 

write your custom ant task, is simple as write a class

dfa