ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dani Zweig" <d...@laminarsoft.com>
Subject Withdraw question (was: -v flag affects property?)
Date Fri, 28 Sep 2001 20:41:48 GMT
Sorry, my question arose from faulty experimental design:  I was alternating
between trying the command with and without the -v flag.  If had had simply
run the same way multiple times, the script outlined below would have failed
on even-numbered tries and succeeded on odd-numbered tries.  (How
embarrassing!)

-----Original Message-----
From: Dani Zweig [mailto:dani@laminarsoft.com]
Sent: Wednesday, September 26, 2001 10:00 AM
To: ant-user@jakarta.apache.org
Subject: -v flag affects property?


I have a costly setup task that I don't want to perform unless it's needed.
The following (simplified) combination of targets fails if I invoke "ant
clean task1" and succeeds if I invoke "ant -v clean task1".  (By 'fails', I
mean that "do_setup" is not invoked, and that this leads task1 to fail.)  Is
this a known problem?  Is there a known workaround?

	<target name="init">
		<available file="setup_dir" property="setup_done" />
	</target>

	<target name="have_setup" depends="init" unless="setup_done">
	     <antcall target="do_setup" />
	</target>

	<target name="task1" depends="have_setup">
		<antcall target="do_task1" />
	</target>

	 <target name="clean" depends="init">
		<delete dir="setup_dir" />
	</target>

advTHANKSance for any light you can shed.

- Dani Zweig
  dani@laminarsoft.com


-----Original Message-----
From: Robert Seeger [mailto:rseeger@nortelnetworks.com]
Sent: Wednesday, September 26, 2001 7:53 AM
To: ant-user@jakarta.apache.org
Subject: Re: Javascript errors


Unfortunately, this defeats the idea of what I'm trying to do. The basic
concept comes down to, which I'll describe:

- There are many subprojects of a large project, each with their own
build.xml file
- There is a primary build.xml file that is included by all the sub
probject's build.xml files
- Each sub build.xml includes the main build.xml file and then "depends" on
"init", which is defined in the main file
- Each sub build.xml defines a variable DEPENDENCIES, which is a list of
other subpackages it depends on
- The init target in the main build.xml uses this variable to construct
things like the classpath, the various dependencies, and the like

As an example, here's some pseudo code showing whatI want to do:

---- Sub project build.xml ---
<include file="main.xml"/>
<property name="DEPENDECIES" value="package1,package2,package3"/>
<target name="build" depends="init">
  <do somestuff/>
</target>

---- Main build.xml ----------
<target name="init">
  <property name="basePkgPath" value="/base/pkg/path"
  <path>
    <foreach elem in "${DEPENDENCIES}">
      <pathelement location="${basePkgPath}/${elem}/java"/>
    </foreach>
  </path>
</target>

Since there isn't a foreach task in Ant, I'm using javascript to obtain
this functionality. If anyone can come up with a better way to do this,
I'll happily listen. I'm converting things over from a fairly complex
makefile system, so it's possible I'm not thinking about it all in the
right way for Ant.

Thanks again,
Rob Seeger


At 03:03 PM 9/25/01 -0400, you wrote:
>Put it in it's own .xml file.  Each xml file has it's own
>project name.  You can then use the "<ant>" task to call a
>task from another build file.
>
>ie.
>
>build.xml
>--------------
>
><target name="calltest">
> <ant antfile="common.xml" target="test" basedir="." />
></target>
>
>common.xml
>-------------
>
><project name="Common" ... >
>
><target name="test">
> <script language="JavaScript"><![CDATA[
>   var val = Common.getProperty("propertyName");
>  ]]>
> </script>
></target>
>
>On Tue, 2001-09-25 at 14:31, Robert Seeger wrote:
>> Much appreciated. Changing it to use the project name works great. This
>> does leave me with one problem however. The code is included in a variety
>> of build.xml files, each with a different project name. Is there a way to
>> get the current project name from within the javascript code?
>>
>> Thanks again,
>> Rob Seeger
>>
>> At 02:08 PM 9/25/01 -0400, you wrote:
>> >because you cannot get a property on a target
>> >i believe (correct me if i'm wrong about this
>> >in ant 1.4).  what you really need to do
>> >is to call this:
>> >
>> >Project.getProperty(propName)
>> >
>> >(of course Project is replaced by the name attribute of
>> > your project)
>> >
>> >
>> >On Tue, 2001-09-25 at 13:38, Robert Seeger wrote:
>> >> I'm having a problem with the script task, and I was hoping someone
might
>> >> be able to point me in the right direction. Since I can't seem to find
a
>> >> good reference on how to use javascript with ant, I've been pulling
pieces
>> >> from here and there, with little success.
>> >>
>> >> I downloaded bsf.jar and js.jar and put them in $ANT_HOME/lib. I
tried to
>> >> find rhino.jar, but js.jar was the best I could come up with (*looks
>> >> confused*)
>> >>
>> >> I then tried a variety of scripting pieces, and came up with the
following:
>> >>
>> >> <target name="testme" id="testme">
>> >>   <property name="prefix" value="/bin/"/>
>> >>   <property name="suffix" value="/notbin/"/>
>> >>   <script language="javascript"> <![CDATA[
>> >>     function makePath(prefix, path, suffix) {
>> >>       var newPath = prefix + path + suffix;
>> >>       return makePath;
>> >>     }
>> >>     var prefix = testme.getProperty("prefix");
>> >>     var suffix = testme.getProperty("suffix");
>> >>     var path = makePath(prefix, "WUIadmin", suffix);
>> >>     path = path + ":" + makePath(prefix, "SLTools", suffix);
>> >>     testme.setProperty("pkg.classpath", path);
>> >>   ]]> </script>
>> >>   <echo message="${pkg.classpath}"/>
>> >> </target>
>> >>
>> >> However, when I run it, I get the following error message:
>> >>
>> >>
>>
d:\Java\TestPrograms\TestAnt\tree.slsrc.SLGEN3.java.com.nortelnetworks.servi
>> >> celink.datasource.build.xml:69: undefined: getProperty is not a
function.
>> >> (<ANT>; line 5)
>> >>
>> >> Can anyone either tell me what I'm doing wrong, or point me in the
>> >> direction of a source with good information about using javascript
from
>> >> within Ant?
>> >>
>> >> Thanks in advance,
>> >> Rob Seeger
>> >> ========================================
>> >> Robert Seeger
>> >> Network Engineer
>> >> Nortel Networks
>> >>
>> >> Telephone:	(518)237-2087
>> >> Pager:		(800)SKY-8888  Pin#1264792
>> >> Fax:		(518)237-4190
>> >> Email:		rseeger@nortelnetworks.com
>> >> Address:	224 5th Ave, Apt#2
>> >> 		Lansingburgh, NY 12182
>> >> ========================================
>> >--
>> >Matt Inger (matt.inger@sedonacorp.com)
>> >Sedona Corporation
>> >455 S. Gulph Road, Suite 300
>> >King of Prussia, PA 19406
>> >(484) 679-2213
>> >"Self-respect - the secure feeling that no one,
>> > as yet, is suspicious." -H.L. Mencken
>> >
>> >
>> ========================================
>> Robert Seeger
>> Network Engineer
>> Nortel Networks
>>
>> Telephone:	(518)237-2087
>> Pager:		(800)SKY-8888  Pin#1264792
>> Fax:		(518)237-4190
>> Email:		rseeger@nortelnetworks.com
>> Address:	224 5th Ave, Apt#2
>> 		Lansingburgh, NY 12182
>> ========================================
>--
>Matt Inger (matt.inger@sedonacorp.com)
>Sedona Corporation
>455 S. Gulph Road, Suite 300
>King of Prussia, PA 19406
>(484) 679-2213
>"Self-respect - the secure feeling that no one,
> as yet, is suspicious." -H.L. Mencken
>
>
========================================
Robert Seeger
Network Engineer
Nortel Networks

Telephone:	(518)237-2087
Pager:		(800)SKY-8888  Pin#1264792
Fax:		(518)237-4190
Email:		rseeger@nortelnetworks.com
Address:	224 5th Ave, Apt#2
		Lansingburgh, NY 12182
========================================



Mime
View raw message