I think that there is currently a serious problem in maven and a number
of plugins, in that 'attainGoal' is being used in various places (goals,
preGoals, and postGoals) with the expectation that the goal being named
to be attained will be part of the dependency graph of the main build
itself, and will be attained only once. However, due to the way the
werkz 'attainGoal' tag is implemented, there is no integration into the
main maven dependency session, and each invocation of attainGoal with a
specific goal will call that goal again including all its dependencies,
becoming more of a subroutine call. At best, I would say it's confusing
as hell, since the name 'attainGoal' implies something; certainly there
is some code which is using the tag with the expectation that it is
integrating into the dependency graph, and there is other code which is
using it like a subroutine call. I would also suggest there need to be
clearly named, different mechanisms, to handle both usage semantics.
To explain in better detail, consider the following maven.xml file:
<project
xmlns:j="jelly:core"
xmlns:maven="jelly:maven"
xmlns:log="jelly:log"
>
<preGoal name="java:compile">
<attainGoal name="my:goal"/>
</preGoal>
<preGoal name="java:jar">
<attainGoal name="my:goal"/>
</preGoal>
<goal name="my:goal">
<log:info>this is my:goal!</log:info>
</goal>
</project>
A number of plugins (and presumably user maven.xml files) are written in
a similar fashion, doing an attainGoal on something like 'java:compile',
etc. with the expectation that they are inserting themselves into the
main dependency chain. What they are really doing is calling the goal in
question again, including all of its dependencies. In the case above,
the my:goal goal is called twice, if I invoke
maven java:jar
The issue stems from the fact that werkz's attainGoal tag doesn't know
anything about the main Maven goals session. It is mean to be used as a
child of the attain tag, as follows:
<attain>
<attainGoal name="aGoal">
<attainGoal name="anotherGoal">
<attainGoal name="aThirdGoal">
</attain>
In this usage, the dependency session is stored by the attain tag, and
each of the attainGoal tags will use the session from the parent attain
tag, so all the goals will use the same dependency session, and a goal
will only be called once.
When attainGoal is used by itself in a jelly script in Maven, as it is
commonly used, a new session is created just for that invocation. The
goal in question, and all of its dependencies, is simply called again,
regardless of whether or not that goal or any dependent goals have
already been attained in the build session.
My suggested solution is to create a maven tag which essentially calls
werkz's attainGoal, but uses the parent maven goal session. For people
that want to call goals in a subroutine like fashion (as the current
attainGoal usage does), another tag with another name (invokeGoal) would
be created, which exists just to have a clearer name, and would delegate
to the existing attainGoal tag. I would however discourage usage of
goals as subroutines, this should be handled by some other mechanism,
such as defining custom tags and invoking them. I think it's a lot
clearer if goals are generally part of the dependency graph...
Any comments?
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
- Re: goals are broken, let's fix it Colin Sampaleanu
- Re: goals are broken, let's fix it bob mcwhirter
- Re: goals are broken, let's fix it Colin Sampaleanu
- Re: goals are broken, let's fix it Peter Lynch
