views:

31

answers:

2

Does anyone have a list, or even better a target that normalizes, the environment variables that are common on Linux, Windows, and OSX that would enable cross-platform, consistent Apache Ant builds? For example: On OSX, you can specify env.HOME and perform file operations, like loading a property file, from the user's home directory, /Users/michaelprescott. On Windows, env.HOME isn't available. Instead, you have to specify env.HOMEDRIVE env.HOMEPATH .

+3  A: 

A lot of that is built into Java. Definitely check out user.dir and similar from System.getProperties() which Ant will use.

Here's a list of some of the more interesting ones:

  • file.encoding = MacRoman
  • file.separator = /
  • java.class.path = ./
  • java.class.version = 50.0
  • java.endorsed.dirs = /System/Library/Frameworks/JavaVM.fram...
  • java.ext.dirs = /Library/Java/Extensions:/System/Library/Ja...
  • java.home = /System/Library/Frameworks/JavaVM.framework/Ver...
  • java.io.tmpdir = /var/folders/Kp/KpmOujsB2RWdqE+BYnAOX++++T...
  • java.library.path = .:/Library/Java/Extensions:/System/Libr...
  • java.specification.version = 1.6
  • java.vendor = Apple Inc.
  • java.version = 1.6.0_20
  • line.separator =
  • os.arch = x86_64
  • os.name = Mac OS X
  • os.version = 10.6.3
  • path.separator = :
  • user.country = US
  • user.dir = /private/tmp/properties-test
  • user.home = /Users/dblevins
  • user.language = en
  • user.name = dblevins
  • user.timezone =
David Blevins
Thanks! Those are good enough for me and consistent across the platforms I tested. It is curious that the Apache Ant documented method of using environment properties is inconsistent, whilst these are consistent. This is the first time I've seen that java makes them available. So, I could write a little java app that prints the results of System.getProperties() and see all the properties made available through file., java., path., and user.?
Michael Prescott
A: 

You can always run:

$ ant -diagnostics

It will spew a lot of information, that you are looking for, to your console.

Alexander Pogrebnyak