a tricky case of running an executable from an ant build script

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

a tricky case of running an executable from an ant build script

Alan Snyder-2
I have an ant script that runs an executable without specifying the full path of the executable.

If I run ant from the shell, then it finds the executable on my $PATH, which is what I want.
(I do not specify searchpath=“true”, so perhaps I do not understand what that does, or
the documentation is wrong.)

The case of interest is where I perform the build directly within a Java application process.
When I do this, the $PATH that the build script sees is the $PATH of the application, and presumably
that is the $PATH that is used to find the executable.

Unfortunately, if my application is a bundled macOS application, it has a minimal $PATH:
   /usr/bin:/bin:/usr/sbin:/sbin

Is there a way that within my application I can configure ant with a different $PATH to provide
to the build script, so that it will find the executable?


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

Reply | Threaded
Open this post in threaded view
|

AW: a tricky case of running an executable from an ant build script

Jan Matèrne (jhm)
If you know where the executable is located, you could set the "executable" attribute of <exec>.
Or set the "dir" attribute tot he directory containing the executable you want to start.
Or provide a nested <env key="Path" .../> element.

Jan

-----Ursprüngliche Nachricht-----
Von: Alan Snyder <[hidden email]>
Gesendet: Samstag, 19. Dezember 2020 22:46
An: Ant Users List <[hidden email]>
Betreff: a tricky case of running an executable from an ant build script

I have an ant script that runs an executable without specifying the full path of the executable.

If I run ant from the shell, then it finds the executable on my $PATH, which is what I want.
(I do not specify searchpath=“true”, so perhaps I do not understand what that does, or the documentation is wrong.)

The case of interest is where I perform the build directly within a Java application process.
When I do this, the $PATH that the build script sees is the $PATH of the application, and presumably that is the $PATH that is used to find the executable.

Unfortunately, if my application is a bundled macOS application, it has a minimal $PATH:
   /usr/bin:/bin:/usr/sbin:/sbin

Is there a way that within my application I can configure ant with a different $PATH to provide to the build script, so that it will find the executable?


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



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

Reply | Threaded
Open this post in threaded view
|

Re: a tricky case of running an executable from an ant build script

Alan Snyder-2
That’s not the point. I don’t want to change the build script, I want to change the environment in which it is run.

> On Dec 24, 2020, at 12:48 PM, <[hidden email]> <[hidden email]> wrote:
>
> If you know where the executable is located, you could set the "executable" attribute of <exec>.
> Or set the "dir" attribute tot he directory containing the executable you want to start.
> Or provide a nested <env key="Path" .../> element.
>
> Jan
>
> -----Ursprüngliche Nachricht-----
> Von: Alan Snyder <[hidden email]>
> Gesendet: Samstag, 19. Dezember 2020 22:46
> An: Ant Users List <[hidden email]>
> Betreff: a tricky case of running an executable from an ant build script
>
> I have an ant script that runs an executable without specifying the full path of the executable.
>
> If I run ant from the shell, then it finds the executable on my $PATH, which is what I want.
> (I do not specify searchpath=“true”, so perhaps I do not understand what that does, or the documentation is wrong.)
>
> The case of interest is where I perform the build directly within a Java application process.
> When I do this, the $PATH that the build script sees is the $PATH of the application, and presumably that is the $PATH that is used to find the executable.
>
> Unfortunately, if my application is a bundled macOS application, it has a minimal $PATH:
>   /usr/bin:/bin:/usr/sbin:/sbin
>
> Is there a way that within my application I can configure ant with a different $PATH to provide to the build script, so that it will find the executable?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


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

Reply | Threaded
Open this post in threaded view
|

Re: a tricky case of running an executable from an ant build script

Stefan Bodewig
In reply to this post by Alan Snyder-2
On 2020-12-19, Alan Snyder wrote:

> The case of interest is where I perform the build directly within a Java application process.

[...]

> Is there a way that within my application I can configure ant with a
> different $PATH to provide to the build script, so that it will find
> the executable?

Depends on the way you execute the build. If you are using Runtime.exec
or ProcessBuilder there are ways to specify a custom environment for the
forked process. If you are invoking Ant via its Java API then there is
no way I can think of right now.

Stefan

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