Passing system properties by default to java task

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Passing system properties by default to java task

Al Le
Hello,

I'd need an advice from the experts.

In my ant script, I run a java program several times (up to 20) via the
'java' task. The program opens a connection to some server and uses the
IAIK library for this (some Java security stuff).

The server requires a certain level of the security mechanism to be used
by the client which (the level) is NOT used by default. To force the
correct security level, one should specify some system properties when
calling the program (IIUC, the properties are interpreted by the IAIK
library).

If the java task is executed in the ant's JVM, i.e. if the 'fork' option
is set to 'false', then I can specify those options when starting ant,
and they are also visible to the program executed via 'java'.

But since the program has caused some memory problems, I have to execute
it each time in a new JVM which is discarded after each run so that the
memory problems do not accumulate.

When starting 'java' with the 'fork=true' option, the system properties
of the ant's JVM don't get passed to the JVM started by 'java' so that I
have to explicitly specify them using nested 'sysproperty' elements.

This I don't like because I think that this belongs to the 'environment'
and should not be explicitly present in the script.

How can I achieve that some system properties are passed to the JVM
started by the 'java' task with the 'fork=true' option without
specifying them explicitly in the script?

Thank you for any hints!

AL

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Passing system properties by default to java task

Stefan Bodewig
On 2017-08-17, Al Le wrote:

> How can I achieve that some system properties are passed to the JVM
> started by the 'java' task with the 'fork=true' option without
> specifying them explicitly in the script?

Setting clonevm to true will copy over all system properties - but a
bunch of other settings as well. Whether this is good enought for you is
unclear to me.

A nested

<syspropertyset>
  <propertyref builtin="system"/>
</syspropertyset>

will only copy the system properties.

As you say you are using similar <java> tasks several times during the
build it may be a good idea to <presetdef> a new task with all the
proper defaults already configured in.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]