[PJUG Javamail] Groovy version of the ANT help (-p) target
James Lee
misttar at easystreet.net
Thu May 20 01:28:52 UTC 2010
I put this together today, for my own project. As I liked the idea of a
help target, but didn't want to rely on running an external process like was
used in the presentation.
<target name="help" description="Prints build usage information">
<groovy>
if (project.description != null)
project.log(project.description)
project.log("Main Targets:")
project.log("")
def filteredTargets = project.targets.values()
.groupBy { it.location }.collect { it.value.min{
it.name.size() } }
.findAll{ target ->
target != null &&
!target.name.equals("") &&
target.description != null &&
!target.description.equals("") }
def maxLen = filteredTargets.max { it.name.size() }.name.size()
filteredTargets.sort{ it.name }.each { target ->
project.log( " ${target.name}" + " " * (2 + maxLen -
target.name.size()) + "${target.description}" )
}
project.log( "Default target: " + project.defaultTarget )
</groovy>
</target>
Of course, you need the groovy task defined for this to work:
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" >
<classpath>
<pathelement location="${lib}/groovy-all-1.7.2.jar"/>
</classpath>
</taskdef>
Just grab the groovy binary distribution, and look for the "all" jar, and
you should be good.
Planning on adding some additional diagnostics to it as well. Maybe have
another that prints macrodefs, w/ attributes info. Kinda an auto-javadoc
style thing.
Thoughts/ideas welcome.
James Lee
Build & Automation Manager
Jive Software
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://javac.com/pipermail/javamail/attachments/20100519/4b819281/attachment-0002.html>
More information about the Javamail
mailing list