Thanks for the link, I haven't made the jump to 1.8, yet, but quickly
read over the documentation you provided. You're right, It is very
close, I even have something very much like "onMissingExtensionPoint"
with pretty much the same values.
If had been present back in 1.6.5 days, I might have used it. Then
again, maybe not. I don't really care for the syntax of extension-point.
Perhaps, it's because I'm not used to it. It just seems a bit more
esoteric. I prefer the simplicity of something like this that is defined
at the task level. (I expect that this would be strange to someone used
to extension-points).
<run-target name="create-directory-layout" if="directory.required" />
<run-target name="generate-report" scope="all" unless="no.reports"
whenTargetNotFound="warn" />
I actually rarely use the if and unless atrributes, but they can be
handy sometimes. In a slightly more realistic case, I'd more likely do
something like this:
<target name="reports" description="generates any configured reports for
the project" depends="build" unless="no.reports">
<run-target name="generate-report" scope="all" whenTargetNotFound="warn" />
</target>
This would be in my base build, and then I would import my junit
"plugin", which could implement: run-tests, and generate-report. At any
rate that's the basic idea.
With extension-points, it's not clear (to me) how it would work if there
were multiple extensions present due to imports. This was one of the key
pieces of functionality I wanted to be able to support, because I wanted
to be able to easily layer on additional functionality. My guess is that
extension-points would be expecting someone to define a single extension
purely in the build script which imported the code with the
extension-point. My task goes beyond this.
Because the projects aren't all that complicated, there aren't too many
hooks that lend themselves to calling multiple implementations. The most
common cases I've run into:
- Running tests
- Generating reports
- Generating code (occasionally)
Anyhow, thanks for the tip - I've been meaning to read up on 1.8, but
haven't made time to do it, yet.
Rob
On 11/3/11 9:56 PM, Vimil Saju wrote:
Ant 1.8 has extension-points which provides something similar to your use-case
http://ant.apache.org/manual/targets.html
________________________________
From: Rob Seegel<robsee...@comcast.net>
To: Ant Users List<user@ant.apache.org>
Sent: Thursday, November 3, 2011 6:40 PM
Subject: Re: Checking if a Target Exists
Steve,
For my project I created a custom task that was basically an extension of
runtarget (from ant-contrib), which worked *almost* the way I wanted. I wanted
the following specific case:
- core skeleton build process in one script, that contained hooks I could use to
"extend" with one or more smaller utility scripts that are also imported to
enhance the core build process by taking advantage of those hooks very much like plug-ins.
The runtarget extension, can run every implementation of a particular target that it finds, or a few
variations. This allows me to define a task that looks for something like "run-test-suite" or
"generate-report" or "initialize" or whatever, and then add however many implementations
that are appropriate for that project. What this allows me to do, is wrap other custom ant tasks into small
utility modules where sensible defaults are established (that can be overridden). It allows for easier reuse
of ant processes.
The final project build script usually ends up being incredibly small, only
implementing small snippets that are absolutely specific to the one build. Most
times a scripts is between one and three imports, and maybe a few property
overrides.
Let me take a look at the code tomorrow - perhaps I can share it. It was
written for Ant 1.6.5, but I've also used it for 1.7.* The basic idea has
worked pretty well for me.
Rob
On 11/3/11 7:52 AM, Steve Amerige wrote:
Hi all,
I want to be able to check if a target exists and hope you can help. I'm
looking for a generic solution that doesn't rely any knowledge of the target
name to be checked. It is not possible to modify the target code. And, I'd
like to avoid any solutions that cause the entire JVM to be loaded (e.g., as
with antcall).
My environment is Ant 1.7 and allows for the use of Ant-Contrib and Groovy.
Any ideas on how to do this? Even better, any solutions anyone have to share?!
Thanks,
Steve Amerige
SAS Institute, Deployment Software Development
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org