Getting the Path of an Included Build File

View: New views
7 Messages — Rating Filter:   Alert me  

Getting the Path of an Included Build File

by jnewton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I would like to create a common include file that several of my builds use. It would setup a few global directorise and properties. Then my build files would just use the <include> element. However, I am trying to use the project::get-buildfile-path() function inside my include file to get the current path of that include file. This property will then be used to build up other paths.

The problem is that this function returns the path to the build file including the include file. Since this method doesn't work, is there a better approach? Another function I should use?

Thanks

Re: Getting the Path of an Included Build File

by Bob Archer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I would like to create a common include file that several of my builds
> use.
> It would setup a few global directorise and properties. Then my build
> files
> would just use the <include> element. However, I am trying to use the
> project::get-buildfile-path() function inside my include file to get
> the
> current path of that include file. This property will then be used to
> build
> up other paths.
>
> The problem is that this function returns the path to the build file
> including the include file. Since this method doesn't work, is there a
> better approach? Another function I should use?

It seems to me that the calling script knows the path to the included script since you are calling it. Set a property to hold the path which you can reference in the included script.

BOb

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
NAnt-users mailing list
NAnt-users@...
https://lists.sourceforge.net/lists/listinfo/nant-users

Re: Getting the Path of an Included Build File

by Michael Pento :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If I understand you correctly, you want the path without the filename.
get-buildfile-path() returns the path and file of the currently running
build script.

If all you need is the path portion, you could just parse that out
yourself:

<!-- get the full path + build file -->
                <property name="_full_path"
value="${project::get-buildfile-path()}" />
                <!-- find the index of the last '\' -->
                <property name="_index"
value="${string::last-index-of(_full_path, '\')}" />
                <!-- return a string containing the path up to
len(_index) -->
                <property name="_path"
value="${string::substring(_full_path, 0, _index)}" />

For example, my build file is C:\RelEng\Scripts\default.build

Running this returns C:\RelEng\Scripts

I am not sure if this helps or not, I may have misunderstood what you
are looking to accomplish.

Thanks,
Mike

-----Original Message-----
From: jnewton [mailto:Jonathan.Newton@...]
Sent: Tuesday, August 18, 2009 10:03 AM
To: nant-users@...
Subject: [NAnt-users] Getting the Path of an Included Build File


I would like to create a common include file that several of my builds
use.
It would setup a few global directorise and properties. Then my build
files
would just use the <include> element. However, I am trying to use the
project::get-buildfile-path() function inside my include file to get the
current path of that include file. This property will then be used to
build
up other paths.

The problem is that this function returns the path to the build file
including the include file. Since this method doesn't work, is there a
better approach? Another function I should use?

Thanks
--
View this message in context:
http://www.nabble.com/Getting-the-Path-of-an-Included-Build-File-tp25025
552p25025552.html
Sent from the NAnt - Users mailing list archive at Nabble.com.


------------------------------------------------------------------------
------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008
30-Day
trial. Simplify your report design, integration and deployment - and
focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
NAnt-users mailing list
NAnt-users@...
https://lists.sourceforge.net/lists/listinfo/nant-users


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
NAnt-users mailing list
NAnt-users@...
https://lists.sourceforge.net/lists/listinfo/nant-users

Re: Getting the Path of an Included Build File

by jnewton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The actual problem is that I have some top-level include file that contains stuff like:

<property name="dir.root" value="${path::get-full-path('..\')}" />
<property name="dir.imports" value="${dir.root}Imports" />
<property name="dir.trunk" value="${dir.root}Trunk" />
.....

I want these properties set when I include them in my build files.  There is a variety of top-level directories that my build scripts will need to know about.  Basically these properties need to be set based on the current directory of the include file, not the build file that includes this file.


Re: Getting the Path of an Included Build File

by Bob Archer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> The actual problem is that I have some top-level include file that
> contains
> stuff like:
>
> <property name="dir.root" value="${path::get-full-path('..\')}" />
> <property name="dir.imports" value="${dir.root}Imports" />
> <property name="dir.trunk" value="${dir.root}Trunk" />
> .....
>
> I want these properties set when I include them in my build files.
> There is
> a variety of top-level directories that my build scripts will need to
> know
> about.  Basically these properties need to be set based on the current
> directory of the include file, not the build file that includes this
> file.

Hows does your build file know the path to the include file?

BOb

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
NAnt-users mailing list
NAnt-users@...
https://lists.sourceforge.net/lists/listinfo/nant-users

Re: Getting the Path of an Included Build File

by jnewton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am planning on just using a relative path to the main include file. I'm just trying to avoid specifiying all these properties in all of my top-level build files. Like I have a structure like:

Trunk
   ADE
      ade.build
   RTE
      rte.build
   Blah
     blah.build

The ADE, RTE, Blah, etc folders are all products that can be built independently but they all will share a variety of directory paths (i.e. paths to build tools).

So in my ade.build file for example, I would do something like:
include buildfile="..\..\global.include" />

Re: Getting the Path of an Included Build File

by Bob Archer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> build files. Like I have a structure like:
>
> Trunk
>    ADE
>       ade.build
>    RTE
>       rte.build
>    Blah
>      blah.build
>
> The ADE, RTE, Blah, etc folders are all products that can be built
> independently but they all will share a variety of directory paths
> (i.e.
> paths to build tools).
>
> So in my ade.build file for example, I would do something like:
> include buildfile="..\..\global.include" />

So, do something like:

<property name="includefilepath" value="${path::get-full-path('..\..\')}" />
<include buildfile="${includefilepath}\global.include" />

Then you can use includefilepath in your include file.

BOb

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
NAnt-users mailing list
NAnt-users@...
https://lists.sourceforge.net/lists/listinfo/nant-users