On Tue, Dec 16, 2008 at 10:27 AM, Trevor Harmon <tre...@vocaro.com> wrote:

> I'm coming from the Ant world, where targets are fundamental. Need to
> generate the JavaDocs and a JAR? Write targets called "javadoc" and "jar"
> then do:
>
>  ant javadoc
>  ant jar
>
> In Maven, these particular tasks have built-in plugins, so there's no need
> to write a target. Instead you just invoke the plugin goal:
>
>  mvn javadoc:javadoc
>  mvn jar:jar
>
> But there are many scenarios in which no plugin is available. For instance,
> I use install4j to build an installer, and I use DocBook to translate XML
> into PDF. Accomplishing these tasks with the AntRun plugin is easy enough,
> but it's not clear how to actually invoke them. The Ant concept of a target
> does not exist in Maven.
>
> Maven does have profiles, however. I'm able to put the install4j stuff into
> a profile called "install4j" and the DocBook stuff into a profile called
> "docbook". Then I can do:
>
>  mvn -Pinstall4j
>  mvn -Pdocbook
>
> This works, but from an end-user standpoint it's a little confusing. For
> some things you invoke a plugin goal but for other things you invoke a
> profile. It's inconsistent. Also, the Build Profiles chapter of the Maven
> book mentions nothing about this use case. It only talks about profiles for
> the purpose of build portability.
>
> So... am I doing this right? Are profiles intended to play the role of Ant
> targets? Or is there some other mechanism for that?
>

I wouldn't say that profiles are analagous to Ant targets, no; you might be
able to make them react that way, but that's not really the intent.
The closest analog to an Ant target is a maven lifecycle phase, like
"install"; there's a pre-defined lifecycle that Maven follows, and you can
bind plugins of your choosing to that lifecycle.  This works well in many
'build' scenarios, but it's also true that Maven is tailored around those
kind of environments, and isn't as well suited for the world of "execute
some arbitrary work for me" as Ant would be.

That said, it's not hard to imagine using Maven to build an installer or
some Docbook documentation; each of these might be a module on a larger
multi-module project.

  - Geoffrey
-- 
Geoffrey Wiseman
http://www.geoffreywiseman.ca/

Reply via email to