You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Brian E. Fox" <br...@reply.infinity.nu> on 2009/02/26 15:29:09 UTC

RE: Conditional plugin execution based on build time behavior - Maven profiles not sufficient?

Nothing immediate pops into my head, but what if you could hook your CI system to monitor these external xsds and use that to trigger the build?

The only way to stop the build currently is via the enforcer plugin, you could make a custom rule...but it would be seen to the CI as a build failure.

-----Original Message-----
From: les.hazlewood@anjinllc.com [mailto:les.hazlewood@anjinllc.com] On Behalf Of Les Hazlewood
Sent: Wednesday, February 25, 2009 5:56 PM
To: users@maven.apache.org
Subject: Conditional plugin execution based on build time behavior - Maven profiles not sufficient?

Hi folks,

Here's what I'm trying to achieve:

I have a build that must run every 5 minutes or so in a Continuous
Integration server.  It must do this because it downloads information that
exists outside of a Maven artifact repository or any build environment and
must regularly check to see if information has changed.  If the information
source has changed in any way, my Maven build must create a new SNAPSHOT
.jar to reflect the change.

If the information doesn't change, a new .jar should never be created or
deployed to the repository.  This is to avoid uploading a new snapshot .jar
every 5 minutes to the repository, and consequently having developers all
download this snapshot as a dependency every time they build (yuck).

Is there a way to pre-emptively stop a build in order to prevent the .jar
from being created/installed/deployed?  I don't want to fail the build,
because this case is not a failure - the build would have correctly stopped
short the lifecycle specifically because the .jar should not be created.

This behavior would exclude standard Maven profiles as a solution as I
understand them because they're only activated based on some condition when
the build starts.  The knowledge of if a build should be 'short circuited'
would only be available after this plugin finished executing.

------
Now, here's my very specific use case of why I'd like to do this (but should
probably work generically as described above), in case you're curious:

My plugin downloads .xsd files from well-known locations (not maven
repositories), auto-generates .java (and then .class) files representing
these .xsd files, creates a .jar file and deploys this .jar to a maven
repository.  Other applications consume this 'Java XSD stubs' .jar to call
web services and are quite happy, but they should automatically be updated
if the .XSD contracts change, so they can eagerly adapt to these points of
change, in true Continuous Integration fashion.

But I only want the .jar to be created and deployed to the maven repository
if one or more of the downloaded .xsd files are different compared to the
last time the build was executed.  If the files don't change between
5-minute cycles (verified by downloading them and comparing to the
previously retrieved files), nothing should happen

Everything is working except for the part where I pre-emptively exit the
build, but without Failing the build.

Anyone have any ideas?

Thanks SO much for feedback!

Cheers,

Les