You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Arulazi Dhesiaseelan <ar...@india.hp.com> on 2001/10/18 17:03:08 UTC
retrieve env vars thru ant
Hi
I would like to retrieve the enviroment variables that are already set.
How to retrieve it through Ant. For example, I need to retrieve
JAVA_HOME enviroment variable, which has been set to
JAVA_HOME=C:\jdk1.31.
Thanx in advance.
With regards
Arul
Re: retrieve env vars thru ant
Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 19 Oct 2001, Phil Surette <ph...@home.com> wrote:
> Could the Property task doco be updated to mention the
> case-sensitivity under windows?
I think we need it to be case sensitive as env vars are case sensitive
on Unix systems. And "normal" Ant properties are so as well, I even
know some build files that rely on this behavior.
Documentation has been patched.
Stefan
Re: retrieve env vars thru ant
Posted by Phil Surette <ph...@home.com>.
Ugh! Didn't notice that.
Looking at the ant source it looks like this is ultimately
because the Project class has a 'properties' member variable
that is in fact a Hashtable! Too bad, cuz Properties objects
are case-insensitive but hashes are not.
Could the Property task doco be updated to mention the
case-sensitivity under windows?
Anyway, it's still a great feature!
Conor MacNeill wrote:
>
> It is case sensitive and under Win2k, the Path is actually env.Path :-(
>
> > -----Original Message-----
> > From: Phil Surette [mailto:philsurette@home.com]
> > Sent: Friday, 19 October 2001 4:41 PM
> > To: ant-user@jakarta.apache.org
> > Subject: Re: retrieve env vars thru ant
> >
> >
> > Since there is no way to get at environment variables from
> > java, I was stunned to see that you could do it and ran
> > off to create a test script.
> >
> > ...catch is it doesn't work under Windows 2000.
> >
> > <project default='echoenv'>
> > <property environment='env'/>
> > <property name="test" value="hello whirled"/>
> >
> > <target name='echoenv'>
> > <echo>path = ${env.PATH}
> > test = ${test}</echo>
> > </target>
> > </project>
> >
> > output:
> > Buildfile: build.xml
> >
> > echoenv:
> > [echo] path = ${env.PATH}
> > test = hello whirled
> >
> > BUILD SUCCESSFUL
> >
> > Total time: 2 seconds
> >
> > I guess Win2000 is not one of the 'select' platforms
> > that the task works under...
> >
> > Steve Loughran wrote:
> > >
> > > ----- Original Message -----
> > > From: "Erik Hatcher" <ja...@ehatchersolutions.com>
> > > To: <an...@jakarta.apache.org>
> > > Sent: Thursday, October 18, 2001 09:06
> > > Subject: Re: retrieve env vars thru ant
> > >
> > > > As for JAVA_HOME, you can access it already with
> > ${java.home}. (although
> > > > it'll likely have "jre" appended to what the environment
> > variable actually
> > > > says.)
> > >
> > > I am not sure they are the same. JAVA_HOME usually points to
> > the JDK base,
> > > but java.home can refer to wherever the current JRE is, right? So if you
> > > have the JDK but run off a JRE under Program Files then
> > java.home can be a
> > > long way from JAVA_HOME
> > >
> > > > For other environment variables, have a look at <property
> > > environment=".....
> > > > />
> > > >
> > >
> > > that's what I use.
> >
Re: example ANT scripts
Posted by T Master <tm...@iknowledgeinc.com>.
Ant user manual...
weblogic comes with one, so does ant.
netbeans too.
----- Original Message -----
From: "Bob Aiello" <su...@email.msn.com>
To: <an...@jakarta.apache.org>
Sent: Wednesday, October 24, 2001 7:52 AM
Subject: example ANT scripts
> does anyone know of a good site for example ANT
> scripts (Unix or NT)?
>
> Bob
>
RE: example ANT scripts
Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
Bob,
Look here for a large list of projects all built with Ant
http://jakarta.apache.org/builds/gump/latest/
You should be able to navigate to the project home, CVS, etc and then the
individual buildfiles from there.
You can find a description of Gump here
http://jakarta.apache.org/gump/
Conor
> -----Original Message-----
> From: Bob Aiello [mailto:surfer72@email.msn.com]
> Sent: Wednesday, 24 October 2001 11:53 PM
> To: ant-user@jakarta.apache.org
> Subject: example ANT scripts
>
>
> does anyone know of a good site for example ANT
> scripts (Unix or NT)?
>
> Bob
>
>
RE: example ANT scripts
Posted by Ylan Segal <yl...@digiworks.tv>.
Do you mean a build file? What are you developing? A build file for tomcat
develping looks very different that one for a stand-alone application.
Ylan Segal
-- Failure is not an option, it comes bundled with your Micro$oft product
> -----Original Message-----
> From: Bob Aiello [mailto:surfer72@email.msn.com]
> Sent: Wednesday, October 24, 2001 7:53 AM
> To: ant-user@jakarta.apache.org
> Subject: example ANT scripts
>
>
> does anyone know of a good site for example ANT
> scripts (Unix or NT)?
>
> Bob
>
>
example ANT scripts
Posted by Bob Aiello <su...@email.msn.com>.
does anyone know of a good site for example ANT
scripts (Unix or NT)?
Bob
Re: Please Help me!!!
Posted by Diane Holt <ho...@yahoo.com>.
Your <fileset>'s in your <jar> task look like they're probably wrong. You
have:
> <fileset dir="${PATH_ArqEJBReg}/util/">
> <include name="util/MappingValue.class"/>
> </fileset>
which would have it looking for:
${PATH_ArqEJBReg}/util/util/MappingValue.class
which probably isn't what you want. That's true for all your <fileset>'s.
You should either not include that final subdir in the "dir" attribute, or
not include it in the <include>'s -- which you choose to do will depend on
whether you want the files in your jar-file to include the subdir or just
be the name of the file.
Once you get the <jar> task fixed, if your <java> task still has trouble,
try running 'ant -verbose' so you can see what the actual 'java'
command-line looks like and verify that all the jars you've specified for
the classpath are getting included.
Diane
--- Vincent Croft <ve...@yahoo.com> wrote:
> Hi Diane,
>
> Thank you to have the time to help me...
>
> Well the first thing you are mentioning about, why I
> didn't use de ejbc bside the java, it was because when
> I first take a look to Ant, I didn't undestand many
> things about it, I've never worked with a deploy
> before, so I asked to all the list members and kindly
> you answer my questions, there were many replies using
> the ejbc, java, etc, and only the java seems to worked
> perfectly, so I start to use it, this are the lines
> used to my <java> task after making the jar with a
> <jar> task:
>
> <java classname="weblogic.ejbc" fork="yes">
> <arg line="-compiler javac ${DEST}/EJBTEMP.jar
> ${DEST}/recEJB.jar"/>
> <classpath>
> <pathelement path="${CLASSPATHRec}"/>
> </classpath>
> </java>
>
> this worked for me, at the moment.. but some times
> when I tried to run the <java> task with all this, a
> message of error show up, telling me, there is a
> missing file in the jar EJBTEMP.jar(e.g.), so when I
> put into the jar with a <fileset> task the missing
> file, the problem seems to be resolved, this has not
> been a good practice, coz I make a big jar file, when
> it really needs only a few files in there, and the
> rest of the files need it are in a previous jar file.
>
> That was why I was looking the way to tell my <jar>
> task to use a classpath an tell it there is a jar file
> which has already the file of other module that it
> needs.
>
> I thing maybe is not the classpath in a jar task
> where it be, bside that, it has to be in the <java>
> task, as you see I'm using a classpath definition in
> my java task, but it seems that the java task doesn't
> care about it.
>
> <classpath>
> <pathelement path="${CLASSPATHRec}"/>
> </classpath>
>
> CLASSPATHRec property--> has different jars in it..
> here is fragment of the line:
>
> <property name="CLASSPATHRec"
>
Value="${DIR_JARS}/segUtil.jar;${DIR_JARS}/arqUtil.jar......;d:/j2sdkee1.2.1/lib/j2ee.jar;%CLASSPATH%"/>
>
> Where DIR_JARS has the jars from different modules
> wich the jar to be created need.
>
>
> and for the last.... here it is a fragment of my
> <jar> task, which had included all the files need to
> make the error gone:
>
>
> <jar jarfile="${DEST}/fachadaReglasEJBTEMP.jar">
> <fileset dir="${PATH_ArqEJBReg}/util/">
> <include name="util/MappingValue.class"/>
> </fileset>
>
> <fileset dir="${PATH_ArqEJBReg}/EJB/">
> <include name="EJB/FachadaGeneralHome.class"/>
> <include name="EJB/FachadaGeneral.class"/>
> </fileset>
>
> <fileset dir="${PATH_CatEJBReg}/EJB/">
> <include name="EJB/CatalogosHome.class"/>
> <include name="EJB/Catalogos.class"/>
> </fileset>
>
> <fileset dir="${PATH_ExEJBReg}/EJB/">
> <include name="EJB/ReglasComercial.class"/>
> <include name="EJB/ReglasComercialBean.class"/>
> <include name="EJB/FachadaComercialHome.class"/>
> <include name="EJB/ManagerDespachador.class"/>
> <include name="EJB/ManagerReglasHome.class"/>
> <include name="EJB/ManagerImpuestosHome.class"/>
> <include name="EJB/InformacionValue.class"/>
> <include name="EJB/BloquesValue.class"/>
> <include name="exce/Excepcio.class"/>
>
> <include name="excep/Excepcionacion.class"/>
> </fileset>
>
> <fileset dir="${RUTA_PADRE}/">
> <include name="swing/FactorCboValue.class"/>
> </fileset>
>
> <fileset dir="${PATH_ExEJBReg}/EJB/">
> <include name="META-INF/*.xml"/>
> </fileset>
> </jar>
>
> Some files, for example in the big <fileset> task,
> it must not go there, coz those files are already
> compiled in a jar called RulesEJB.jar
>
>
>
> I Hope hasn't bored you and give you view of what is
> my problem...
>
> Thank you very much for all your help
>
> VIN
>
> =====
>
> _________________________________________________________________
>
> "Puedes sentirte desilusionado si fallas, pero est�s condenado si no lo
> intentas."
>
> "You can get disappointed if you fail down, but you are doomed if you do
> not try it."
>
> ICQ # 22338121
>
>
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.yahoo.com
=====
(holtdl@yahoo.com)
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
Re: Please Help me!!!
Posted by Vincent Croft <ve...@yahoo.com>.
Hi Diane,
Thank you to have the time to help me...
Well the first thing you are mentioning about, why I
didn't use de ejbc bside the java, it was because when
I first take a look to Ant, I didn't undestand many
things about it, I've never worked with a deploy
before, so I asked to all the list members and kindly
you answer my questions, there were many replies using
the ejbc, java, etc, and only the java seems to worked
perfectly, so I start to use it, this are the lines
used to my <java> task after making the jar with a
<jar> task:
<java classname="weblogic.ejbc" fork="yes">
<arg line="-compiler javac ${DEST}/EJBTEMP.jar
${DEST}/recEJB.jar"/>
<classpath>
<pathelement path="${CLASSPATHRec}"/>
</classpath>
</java>
this worked for me, at the moment.. but some times
when I tried to run the <java> task with all this, a
message of error show up, telling me, there is a
missing file in the jar EJBTEMP.jar(e.g.), so when I
put into the jar with a <fileset> task the missing
file, the problem seems to be resolved, this has not
been a good practice, coz I make a big jar file, when
it really needs only a few files in there, and the
rest of the files need it are in a previous jar file.
That was why I was looking the way to tell my <jar>
task to use a classpath an tell it there is a jar file
which has already the file of other module that it
needs.
I thing maybe is not the classpath in a jar task
where it be, bside that, it has to be in the <java>
task, as you see I'm using a classpath definition in
my java task, but it seems that the java task doesn't
care about it.
<classpath>
<pathelement path="${CLASSPATHRec}"/>
</classpath>
CLASSPATHRec property--> has different jars in it..
here is fragment of the line:
<property name="CLASSPATHRec"
Value="${DIR_JARS}/segUtil.jar;${DIR_JARS}/arqUtil.jar......;d:/j2sdkee1.2.1/lib/j2ee.jar;%CLASSPATH%"/>
Where DIR_JARS has the jars from different modules
wich the jar to be created need.
and for the last.... here it is a fragment of my
<jar> task, which had included all the files need to
make the error gone:
<jar jarfile="${DEST}/fachadaReglasEJBTEMP.jar">
<fileset dir="${PATH_ArqEJBReg}/util/">
<include name="util/MappingValue.class"/>
</fileset>
<fileset dir="${PATH_ArqEJBReg}/EJB/">
<include name="EJB/FachadaGeneralHome.class"/>
<include name="EJB/FachadaGeneral.class"/>
</fileset>
<fileset dir="${PATH_CatEJBReg}/EJB/">
<include name="EJB/CatalogosHome.class"/>
<include name="EJB/Catalogos.class"/>
</fileset>
<fileset dir="${PATH_ExEJBReg}/EJB/">
<include name="EJB/ReglasComercial.class"/>
<include name="EJB/ReglasComercialBean.class"/>
<include name="EJB/FachadaComercialHome.class"/>
<include name="EJB/ManagerDespachador.class"/>
<include name="EJB/ManagerReglasHome.class"/>
<include name="EJB/ManagerImpuestosHome.class"/>
<include name="EJB/InformacionValue.class"/>
<include name="EJB/BloquesValue.class"/>
<include name="exce/Excepcio.class"/>
<include name="excep/Excepcionacion.class"/>
</fileset>
<fileset dir="${RUTA_PADRE}/">
<include name="swing/FactorCboValue.class"/>
</fileset>
<fileset dir="${PATH_ExEJBReg}/EJB/">
<include name="META-INF/*.xml"/>
</fileset>
</jar>
Some files, for example in the big <fileset> task,
it must not go there, coz those files are already
compiled in a jar called RulesEJB.jar
I Hope hasn't bored you and give you view of what is
my problem...
Thank you very much for all your help
VIN
=====
_________________________________________________________________
"Puedes sentirte desilusionado si fallas, pero est�s condenado si no lo intentas."
"You can get disappointed if you fail down, but you are doomed if you do not try it."
ICQ # 22338121
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
Re: Please Help me!!!
Posted by Diane Holt <ho...@yahoo.com>.
Hi Vincent,
There's a couple of things I'm not sure I understand. One is why you're
using the <java> task to run ejbc -- have you looked at the <ejbc> task
that's available as an optional task?
The other is what you'd expect including a classpath for the <jar> task to
do. All the <jar> task does is jar up whatever files you tell it to, just
like running 'jar' at the command line.
Diane
--- Vincent Croft <ve...@yahoo.com> wrote:
> Hi list members...
>
> I've been looking through the mail list, searching
> for something related to the jar task and Classpath
> but nothing was found there.
>
> Also the documentation related to the jar task
> wasn't good enough...
>
> I've been having troubles using the java task when
> using the weblogic.ejbc classname...
>
> Sometimes an error came out saying that in the jar
> created before the java taks there is a .class
> missing, this one which is in a jar already builded
> it. So, I use a fileset task to put the missing file
> into the building jar
>
> This is my point... is there a way to put a
> classpath property in ant to tell the jar task to use
> it?
>
> Thank you.
>
> =====
>
> _________________________________________________________________
>
> "Puedes sentirte desilusionado si fallas, pero est�s condenado si no lo
> intentas."
>
> "You can get disappointed if you fail down, but you are doomed if you do
> not try it."
>
> ICQ # 22338121
>
>
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.yahoo.com
=====
(holtdl@yahoo.com)
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
Please Help me!!!
Posted by Vincent Croft <ve...@yahoo.com>.
Hi list members...
I've been looking through the mail list, searching
for something related to the jar task and Classpath
but nothing was found there.
Also the documentation related to the jar task
wasn't good enough...
I've been having troubles using the java task when
using the weblogic.ejbc classname...
Sometimes an error came out saying that in the jar
created before the java taks there is a .class
missing, this one which is in a jar already builded
it. So, I use a fileset task to put the missing file
into the building jar
This is my point... is there a way to put a
classpath property in ant to tell the jar task to use
it?
Thank you.
=====
_________________________________________________________________
"Puedes sentirte desilusionado si fallas, pero est�s condenado si no lo intentas."
"You can get disappointed if you fail down, but you are doomed if you do not try it."
ICQ # 22338121
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
RE: retrieve env vars thru ant
Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
It is case sensitive and under Win2k, the Path is actually env.Path :-(
> -----Original Message-----
> From: Phil Surette [mailto:philsurette@home.com]
> Sent: Friday, 19 October 2001 4:41 PM
> To: ant-user@jakarta.apache.org
> Subject: Re: retrieve env vars thru ant
>
>
> Since there is no way to get at environment variables from
> java, I was stunned to see that you could do it and ran
> off to create a test script.
>
> ...catch is it doesn't work under Windows 2000.
>
> <project default='echoenv'>
> <property environment='env'/>
> <property name="test" value="hello whirled"/>
>
> <target name='echoenv'>
> <echo>path = ${env.PATH}
> test = ${test}</echo>
> </target>
> </project>
>
> output:
> Buildfile: build.xml
>
> echoenv:
> [echo] path = ${env.PATH}
> test = hello whirled
>
> BUILD SUCCESSFUL
>
> Total time: 2 seconds
>
> I guess Win2000 is not one of the 'select' platforms
> that the task works under...
>
> Steve Loughran wrote:
> >
> > ----- Original Message -----
> > From: "Erik Hatcher" <ja...@ehatchersolutions.com>
> > To: <an...@jakarta.apache.org>
> > Sent: Thursday, October 18, 2001 09:06
> > Subject: Re: retrieve env vars thru ant
> >
> > > As for JAVA_HOME, you can access it already with
> ${java.home}. (although
> > > it'll likely have "jre" appended to what the environment
> variable actually
> > > says.)
> >
> > I am not sure they are the same. JAVA_HOME usually points to
> the JDK base,
> > but java.home can refer to wherever the current JRE is, right? So if you
> > have the JDK but run off a JRE under Program Files then
> java.home can be a
> > long way from JAVA_HOME
> >
> > > For other environment variables, have a look at <property
> > environment=".....
> > > />
> > >
> >
> > that's what I use.
>
Re: retrieve env vars thru ant
Posted by Phil Surette <ph...@home.com>.
Since there is no way to get at environment variables from
java, I was stunned to see that you could do it and ran
off to create a test script.
...catch is it doesn't work under Windows 2000.
<project default='echoenv'>
<property environment='env'/>
<property name="test" value="hello whirled"/>
<target name='echoenv'>
<echo>path = ${env.PATH}
test = ${test}</echo>
</target>
</project>
output:
Buildfile: build.xml
echoenv:
[echo] path = ${env.PATH}
test = hello whirled
BUILD SUCCESSFUL
Total time: 2 seconds
I guess Win2000 is not one of the 'select' platforms
that the task works under...
Steve Loughran wrote:
>
> ----- Original Message -----
> From: "Erik Hatcher" <ja...@ehatchersolutions.com>
> To: <an...@jakarta.apache.org>
> Sent: Thursday, October 18, 2001 09:06
> Subject: Re: retrieve env vars thru ant
>
> > As for JAVA_HOME, you can access it already with ${java.home}. (although
> > it'll likely have "jre" appended to what the environment variable actually
> > says.)
>
> I am not sure they are the same. JAVA_HOME usually points to the JDK base,
> but java.home can refer to wherever the current JRE is, right? So if you
> have the JDK but run off a JRE under Program Files then java.home can be a
> long way from JAVA_HOME
>
> > For other environment variables, have a look at <property
> environment=".....
> > />
> >
>
> that's what I use.
Re: retrieve env vars thru ant
Posted by Steve Loughran <st...@iseran.com>.
----- Original Message -----
From: "Erik Hatcher" <ja...@ehatchersolutions.com>
To: <an...@jakarta.apache.org>
Sent: Thursday, October 18, 2001 09:06
Subject: Re: retrieve env vars thru ant
> As for JAVA_HOME, you can access it already with ${java.home}. (although
> it'll likely have "jre" appended to what the environment variable actually
> says.)
I am not sure they are the same. JAVA_HOME usually points to the JDK base,
but java.home can refer to wherever the current JRE is, right? So if you
have the JDK but run off a JRE under Program Files then java.home can be a
long way from JAVA_HOME
> For other environment variables, have a look at <property
environment=".....
> />
>
that's what I use.
Re: retrieve env vars thru ant
Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
As for JAVA_HOME, you can access it already with ${java.home}. (although
it'll likely have "jre" appended to what the environment variable actually
says.)
For other environment variables, have a look at <property environment=".....
/>
Erik
----- Original Message -----
From: "Arulazi Dhesiaseelan" <ar...@india.hp.com>
To: <an...@jakarta.apache.org>
Sent: Thursday, October 18, 2001 11:03 AM
Subject: retrieve env vars thru ant
> Hi
> I would like to retrieve the enviroment variables that are already set.
> How to retrieve it through Ant. For example, I need to retrieve
> JAVA_HOME enviroment variable, which has been set to
> JAVA_HOME=C:\jdk1.31.
>
> Thanx in advance.
>
> With regards
> Arul
>
>