You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Nick Bonatsakis <nb...@gmail.com> on 2010/12/10 16:18:49 UTC

alternating plugin executions in the same phase

Hi Everyone,

I'm attempting the first step of migrating a project from ant to maven and
am running into an issue. Note that I'd ultimately like to solve this by
improving the modularity of the project, but for now, I'm trying to closely
mimic what ant was doing.

I have a collection of SQL scripts and several Java command line utilities.
I need to have these executed all in the pre-integration-tests phase in an
alternating pattern, i.e:

   - maven-sql-plugin - run scripts
   - maven-exec-plugin - run java util
   - maven-sql-plugin - run some more scripts
   - maven-exec-plugin - run a different java util

The problem is that maven will always execute the plugin executions in
groups, all the sqls, then all the execs. I know this entire thing is
counter to the "maven way", but can anyone suggest a way to accomplish this?

This is under Maven 2.2.1.

Thanks!

-- 
Nicholas Bonatsakis
Software Engineer

Re: alternating plugin executions in the same phase

Posted by Hilco Wijbenga <hi...@gmail.com>.
On 10 December 2010 07:18, Nick Bonatsakis <nb...@gmail.com> wrote:
> I'm attempting the first step of migrating a project from ant to maven and
> am running into an issue. Note that I'd ultimately like to solve this by
> improving the modularity of the project, but for now, I'm trying to closely
> mimic what ant was doing.

I tried this strategy when I was doing what you're trying to do. In my
opinion, for any fairly sizable project moving from Ant to Maven
directly is much harder than (at least partially) modularizing your
code base first. What we did was extract the "easy" modules first and
break up the build that way. Eventually, the "hard" modules became
easy (or at least easier) too.

The very first step is to simply call your Ant build from Maven. Then
you add the Maven Ant tasks to your Ant build so you can depend on the
modules/JARs/projects that you are going to extract. As you progress,
you'll have less and less Ant and more and more Maven.

You have a number of options. You can either build a multi-module
build with Maven or have your modules be separate projects with their
own release cycles. I very much prefer the latter but it's totally up
to you. Naturally, you can combine the two approaches: some single
module projects and some multi-module projects.

With this small-steps approach, I believe you'll be much more likely
to succeed than with a big-bang approach where you all of a sudden do
everything in Maven. I started with the big-bang approach but was
quickly overwhelmed by the complexity of the build. So I created a
script that could run the current build and the current build + a
small change to compare the results. From then on, I could make
changes to the build and be reasonably sure I had not broken anything.
An added benefit was that everybody was using the same build so
everything was out in the open and I could easily keep up with any
other changes that were occasionally needed.

> I have a collection of SQL scripts and several Java command line utilities.
> I need to have these executed all in the pre-integration-tests phase in an
> alternating pattern, i.e:
>
>   - maven-sql-plugin - run scripts
>   - maven-exec-plugin - run java util
>   - maven-sql-plugin - run some more scripts
>   - maven-exec-plugin - run a different java util
>
> The problem is that maven will always execute the plugin executions in
> groups, all the sqls, then all the execs. I know this entire thing is
> counter to the "maven way", but can anyone suggest a way to accomplish this?

If you follow my suggestions above, this should no longer be an issue.
Otherwise, there's always the maven-antrun-plugin.

Good luck,
Hilco

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