You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Eric Giguere <er...@videotron.ca> on 2004/03/12 19:38:13 UTC

Checking from a plugin for the existance of a goal

Hi all

A quick one, is there a way using jelly scripting to check for the 
existance of a goal in a project or a plugin?

Some context information... Lets say I'm building a plugin that acts a 
little like the xdoc plugin, that is based on registration from either 
other plugins or projects. At some point, the "generic plugin" will call 
a goal in those that registered with the plugin. But what if I want to 
include in the generic plugin some placeholder code that can be executed 
if the registree doesn't provide specific functionnality? In xdoc 
context, that would mean providing some jelly code for a report plugin 
that doen't provide the report goal. Right now, if we call a non 
existing goal, we'll have a build failure, and that's perfectly normal. 
But it would be nice to check for the goal existance before calling it.

Any idea on how to do this, if its possible in the first place?

thx
Eric.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Checking from a plugin for the existance of a goal

Posted by Eric Giguere <er...@videotron.ca>.
Solved :)

So for all to see if that can help someone else. Here is some modified 
jelly code extracted from the maven-shell plugin :

<!-- Get all maven goals -->
        <j:set var="mavenSession" value="${context.getMavenSession()}"/>
        <j:set var="allGoals" value="${mavenSession.getAllGoalNames()}"/>
        <j:new var="modList" className="java.util.ArrayList"/>
        <j:set var="dummy" value="${modList.addAll(allGoals)}"/>
<!-- Sort them -->
        <j:invokeStatic method="sort" className="java.util.Collections" 
var="dummy">
            <j:arg type="java.util.List" value="${modList}" />
        </j:invokeStatic>
<!-- Print them for me to see -->
        <j:forEach var="goal" items="${modList.iterator()}">
            <echo>goal: ${goal}</echo>
        </j:forEach>

context is a quite nice bean, once you know it exists in the first place.
On the subject, is there anywhere we can look to get a list of all 
"build-in" beans that exists and that we can use in our code?

Eric.

Eric Giguere wrote:

> Hi all
>
> A quick one, is there a way using jelly scripting to check for the 
> existance of a goal in a project or a plugin?
>
> Some context information... Lets say I'm building a plugin that acts a 
> little like the xdoc plugin, that is based on registration from either 
> other plugins or projects. At some point, the "generic plugin" will 
> call a goal in those that registered with the plugin. But what if I 
> want to include in the generic plugin some placeholder code that can 
> be executed if the registree doesn't provide specific functionnality? 
> In xdoc context, that would mean providing some jelly code for a 
> report plugin that doen't provide the report goal. Right now, if we 
> call a non existing goal, we'll have a build failure, and that's 
> perfectly normal. But it would be nice to check for the goal existance 
> before calling it.
>
> Any idea on how to do this, if its possible in the first place?
>
> thx
> Eric.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org