maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Wiedmann <jochen.wiedm...@gmail.com>
Subject Proposal: Maven launchers in the POM
Date Wed, 16 Jun 2010 08:20:41 GMT
Hi,

I have already posted the same suggestion on the M2Eclipse mailing
list, with very limited response, so'd like to try it once more, and
with a wider audience.

In the times when I was using "make", or "ant", there have always been
some standard targets like "all", "install", "clean" and so on. These
are perfectly met by the respective lifecycle phases, or plugins.
However, quite frequently, make or build files also used to contain
some additional targets, which have been project specific and which
have also been invoked from the command line. Ant went so far as to
show these special targets by using "ant -projecthelp".

The requirement for these things is still there. For example, I've got
a project with some 30 modules. There are exactly 3 of them, in which
I frequently do the following:

    - Run "mvn dependency:copy-dependencies"
    - Copy these dependencies to a particular folder
    - Copy the projects jar file to the same folder
    - Possible remove some jar files, which have gone from the dependency list.

Quite obviously, this would be a perfect thing for such a "special
target" like above.

I can resolve this by writing a script. But that script wouldn't be
portable, or it introduces additional dependencies on some scripting
language, or the like. Why not do it with Maven? Besides, this would
me my personal solution. A much better solution would be if Maven
itself, or at least the tools gathering around the Maven world would
know my solution? For example "mvn help:projecthelp" might show me the
special targets. So could the "Run As..." dialog in a Eclipse or
NetBeans plugin.

A Maven launcher could invoke a certain Maven goal, enabling or
disabling certain profiles. In other words, the POM entry could look
something like this:

    <launcher>
        <id>copy-release-dependencies</id>
        <launchedItems>
             <launchedLifecyclePhase>package</launchedLifecyclePhase>
             <launchedPlugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <goal>copy-dependencies</goal>
                ... more properties possible here, roughly comparable
to a plugin execution
             </launchedPlugin>
             <launchedPlugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
             </launchedPlugin>
             ...
        </launchedItems>
        <enabledProfiles>
            <enabledProfile>release</enabledProfile>
        </enabledProfiles>
    </launcher>

The idea would be that I invoke Maven roughly like "mvn -launcher
cop-release-dependencies". Maven would iterate over the list of
launched plugins and, for every such plugin, invoke itself using the
Maven embedder and call the respective goal. In other words, this
would invoke

    mvn package
    mvn dependency:copy-dependencies
    mvn antrun:run
    ...

No lifecycle considerations, or stuff like that, so that the
implementation could be relatively simple.


Jochen

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


Mime
View raw message