ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: Setting Properties for Scripts
Date Thu, 14 Feb 2002 15:43:10 GMT
Well, I don't think you can change the environment of the java process
running ANT by forking a child process running cmd.exe /c set name=value
(which is what would need to happen for your echo task to give the result
your hoping). What you can do an the other hand is change the environment of
the child process your start from ANT using <env> sub-elements of the <exec>
task. Below is an example that sets the Path (Note that the case is
important. Using PATH doesn't work on W2K and other Windows version I
suppose, and I banged my head on this one!), and other variables before
starting MS Visual Studio.

Also note that you should rely on the Path (that you adjust yourself in the
<env> element to find your executable, instead of specifying the absolute
path to it in the executable attribute, because in case that absolute path
contains a space, it doesn't work (ANT bug???).

I hope this helps. --DD

    <exec executable="msdev.exe"
        dir="${env.MOWI_HOME}"
          vmlauncher="false"
          failonerror="true">

      <arg value="/USEENV" />
      <arg value="build/msdev/MoWI.dsw" />

      <env key="Path"    path="${mowi.msdev.PATH};${env.Path}" />
      <env key="LIB"     path="${mowi.msdev.LIB}" />
      <env key="INCLUDE" path="${mowi.msdev.INCLUDE}" />

      <env key="DS_HOME"   file="${tahoe.home}" />
      <env key="JAVA_HOME" file="${java-dev-kit.home}" />

    </exec>

 -----Original Message-----
From: 	Koegel, Michael [mailto:Michael.Koegel@partner.commerzbank.com] 
Sent:	Thursday, February 14, 2002 9:31 AM
To:	Ant Users List
Subject:	AW: Setting Properties for Scripts

Hi,

maybe this works on Unix, but not on M$ or did I do it wrong?

    <target name="props">
	<property environment="env"/>
	<exec executable="cmd.exe">
	  <arg line="/c set foo2=bar2"/>
	</exec>
	<echo message="foo2=${env.foo2}"/>
    </target>

Regards,
 Michael

-----Ursprüngliche Nachricht-----
Von: Broderick, Kevin [mailto:kevin.broderick@iona.com]
Gesendet am: Mittwoch, 13. Februar 2002 15:33
An: Ant Users List
Betreff: RE: Setting Properties for Scripts

How about using the exec task to set and export your environment
variables ?
Regards
Kevin

-----Original Message-----
From: Koegel, Michael [mailto:Michael.Koegel@partner.commerzbank.com]
Sent: 13 February 2002 13:29
To: Ant Users List
Subject: AW: Setting Properties for Scripts


Hi,

life can be so simple ;-) That one worked fine.

But there is more to come:
Some of the 3rd-party-objects I use in the scripts read some values
from the system-environment.
How can I change the system environment from within my build.xml?
Using ANT_OPTS (-Dfoo=bar) works, but I would like to have everything in
my build.properties.

Regards,
 Michael


-----Ursprüngliche Nachricht-----
Von: Broderick, Kevin [mailto:kevin.broderick@iona.com]
Gesendet am: Mittwoch, 13. Februar 2002 12:59
An: Ant Users List
Betreff: RE: Setting Properties for Scripts

Hi,
Not sure what you're trying to do, sounds a bit techie for me :)
How about the low tech approach ?
When you start your server (start-Target) why not touch a flag file
(ServerStarted.flg ?),
then when you want to know if the server has been started just use the
"available" task to check if it's there! You could delete it then when
you're stopping your server (stop-Target). I guess you could check if
it's there
and delete it in an "init" target when your script starts up ?

Regards
Kevin Broderick

-----Original Message-----
From: Koegel, Michael [mailto:Michael.Koegel@partner.commerzbank.com]
Sent: 13 February 2002 11:50
To: ANT User Mailinglist (E-Mail)
Subject: Setting Properties for Scripts


Hello,

I'm doing some jacl-Scripts in my build.xml for deployment. 
I want to check if the AppServer is running. If not I need to start it
and
remember that I did.
Then a test-target is run. After that the stop-Target needs to stop the
AppServer if it was started earlier.
How can I transfer this information from one target to another?
The only way I found is via System Properties like shown below.
Isn't there an easier way to do this?

<project name="Test JACL" default="env_test" basedir=".">

    <target name="env_test" depends="set_env, get_env">
	    <property environment="env"/>
    </target>

    <target name="set_env">
	<property environment="env"/>
	<script language="jacl"> <![CDATA[
		package require java
		puts [java::call java.lang.System setProperty "foo"
"bar"]
	]]> </script>
    </target>

    <target name="get_env">
	<property environment="env"/>
	<property name="foo" value="bar"/>
	<script language="jacl"> <![CDATA[
		package require java
		puts [java::call java.lang.System getProperty "foo"]
	]]> </script>
    </target>
</project>

Kind Regards,
 Michael Kögel


--
To unsubscribe, e-mail:
<mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:ant-user-help@jakarta.apache.org>


--
To unsubscribe, e-mail:
<mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:
<mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:ant-user-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message