You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Dean Schulze <de...@yahoo.com> on 2011/01/13 23:10:04 UTC

Using profiles to control execution of a maven build (conditional execution)

                I need to modify the maven build for a large project 
to skip certain steps during typical development builds (i.e. don't 
build the *-source.jar files).  I've searched for "conditional 
execution" for maven, but haven't found anything.

A dev profile sounds like the intuitive way to do this - but I don't 
know how intuitive maven is.  The docs for profiles show how to set 
different properties (i.e. database connection parameters) for different
 profiles.  I suppose I could set a property and then test if that 
property is set in the maven-source-plugin - executions - execution tag.

Is this the right way to do conditional execution in maven?

What's the "right" way to do this in maven?

Thanks.

            


      

Re: Using profiles to control execution of a maven build (conditional execution)

Posted by Anders Hammar <an...@hammar.net>.
Please also understand that having the sources jars for releases is actually
very good. Anyone using your artifacts would have great use of them when
debugging for example.
What is the actual problem? Is it that sources jars exist, or something
completely different (the build taking too long?)?

/Anders

On Thu, Jan 13, 2011 at 23:41, Jason van Zyl <ja...@maven.org> wrote:

> On Jan 13, 2011, at 5:10 PM, Dean Schulze wrote:
>
> >
> >                I need to modify the maven build for a large project
> > to skip certain steps during typical development builds (i.e. don't
> > build the *-source.jar files).  I've searched for "conditional
> > execution" for maven, but haven't found anything.
> >
>
> Building the source JARs is not something that happens by default,
> typically this happens in a release profile that is triggered by the release
> plugin. Conditional logic is generally frowned upon in Maven whereas
> layering the functionality you need in profiles that can be activated
> conditionally is the way to go.
>
> > A dev profile sounds like the intuitive way to do this - but I don't
> > know how intuitive maven is.  The docs for profiles show how to set
> > different properties (i.e. database connection parameters) for different
> > profiles.  I suppose I could set a property and then test if that
> > property is set in the maven-source-plugin - executions - execution tag.
>
> You can specify plugins in profiles too, which is typically where the
> maven-source-plugin is configured.
>
> >
> > Is this the right way to do conditional execution in maven?
> >
>
> Profiles that are activated explicitly, with a property, the presence of a
> specific file.
>
> > What's the "right" way to do this in maven?
> >
>
> If the source JARs are being created then you need to find out which POM
> it's in and if it's in a profile that is activated by default, then
> activating another profile will deactivate that profile which should knock
> out the source JAR generation. If it's not in a profile then that POM will
> need to be changed so that it is in a profile so that behaviour can be
> conditionally activated.
>
> > Thanks.
> >
> >
> >
> >
>
> Thanks,
>
> Jason
>
> ----------------------------------------------------------
> Jason van Zyl
> Founder,  Apache Maven
> http://twitter.com/jvanzyl
> ---------------------------------------------------------
>
> A party which is not afraid of letting culture,
> business, and welfare go to ruin completely can
> be omnipotent for a while.
>
>  -- Jakob Burckhardt
>
>
>
>

Re: Using profiles to control execution of a maven build (conditional execution)

Posted by Jason van Zyl <ja...@maven.org>.
On Jan 13, 2011, at 5:10 PM, Dean Schulze wrote:

> 
>                I need to modify the maven build for a large project 
> to skip certain steps during typical development builds (i.e. don't 
> build the *-source.jar files).  I've searched for "conditional 
> execution" for maven, but haven't found anything.
> 

Building the source JARs is not something that happens by default, typically this happens in a release profile that is triggered by the release plugin. Conditional logic is generally frowned upon in Maven whereas layering the functionality you need in profiles that can be activated conditionally is the way to go.

> A dev profile sounds like the intuitive way to do this - but I don't 
> know how intuitive maven is.  The docs for profiles show how to set 
> different properties (i.e. database connection parameters) for different
> profiles.  I suppose I could set a property and then test if that 
> property is set in the maven-source-plugin - executions - execution tag.

You can specify plugins in profiles too, which is typically where the maven-source-plugin is configured.

> 
> Is this the right way to do conditional execution in maven?
> 

Profiles that are activated explicitly, with a property, the presence of a specific file.

> What's the "right" way to do this in maven?
> 

If the source JARs are being created then you need to find out which POM it's in and if it's in a profile that is activated by default, then activating another profile will deactivate that profile which should knock out the source JAR generation. If it's not in a profile then that POM will need to be changed so that it is in a profile so that behaviour can be conditionally activated.

> Thanks.
> 
> 
> 
> 

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
http://twitter.com/jvanzyl
---------------------------------------------------------

A party which is not afraid of letting culture,
business, and welfare go to ruin completely can
be omnipotent for a while.

  -- Jakob Burckhardt




Re: Using profiles to control execution of a maven build (conditional execution)

Posted by Dean Schulze <de...@yahoo.com>.
Could you elaborate some more on "using Maven correctly".  I've inherited a large maven build where things apparently done correctly and I don't want to add any more "incorrect" things to it.


--- On Thu, 1/13/11, Brian Topping <to...@codehaus.org> wrote:

From: Brian Topping <to...@codehaus.org>
Subject: Re: Using profiles to control execution of a maven build (conditional execution)
To: "Maven Users List" <us...@maven.apache.org>
Date: Thursday, January 13, 2011, 3:19 PM

You might want to look in the list archives, there was a discussion in which I learned a lot from others on the list about the pros and cons of using profiles versus using separate (nearly identical) POMs.  My takeaway was that if one just jumps on profiles as the solution to every conditional situation, the build will grow a second head like a hydra in a bad horror flick and you'll really regret it.

The point is that profiles are often an expedient substitute for using Maven correctly.  They should always be considered "last resort" unless you know what you are getting yourself into.  

In my situation, I wanted to have a whole subtree of sources compiled if they were there, otherwise fetched from Nexus if needed.  Profiles work great for that, but I can see exactly where the hydra head fits on the beast now and don't intend on doing anything more with them unless absolutely necessary.

$0.02... 


On Jan 13, 2011, at 5:10 PM, Dean Schulze wrote:

> 
>                I need to modify the maven build for a large project 
> to skip certain steps during typical development builds (i.e. don't 
> build the *-source.jar files).  I've searched for "conditional 
> execution" for maven, but haven't found anything.
> 
> A dev profile sounds like the intuitive way to do this - but I don't 
> know how intuitive maven is.  The docs for profiles show how to set 
> different properties (i.e. database connection parameters) for different
> profiles.  I suppose I could set a property and then test if that 
> property is set in the maven-source-plugin - executions - execution tag.
> 
> Is this the right way to do conditional execution in maven?
> 
> What's the "right" way to do this in maven?
> 
> Thanks.
> 
> 
> 
> 


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




      

Re: Using profiles to control execution of a maven build (conditional execution)

Posted by Brian Topping <to...@codehaus.org>.
You might want to look in the list archives, there was a discussion in which I learned a lot from others on the list about the pros and cons of using profiles versus using separate (nearly identical) POMs.  My takeaway was that if one just jumps on profiles as the solution to every conditional situation, the build will grow a second head like a hydra in a bad horror flick and you'll really regret it.

The point is that profiles are often an expedient substitute for using Maven correctly.  They should always be considered "last resort" unless you know what you are getting yourself into.  

In my situation, I wanted to have a whole subtree of sources compiled if they were there, otherwise fetched from Nexus if needed.  Profiles work great for that, but I can see exactly where the hydra head fits on the beast now and don't intend on doing anything more with them unless absolutely necessary.

$0.02... 


On Jan 13, 2011, at 5:10 PM, Dean Schulze wrote:

> 
>                I need to modify the maven build for a large project 
> to skip certain steps during typical development builds (i.e. don't 
> build the *-source.jar files).  I've searched for "conditional 
> execution" for maven, but haven't found anything.
> 
> A dev profile sounds like the intuitive way to do this - but I don't 
> know how intuitive maven is.  The docs for profiles show how to set 
> different properties (i.e. database connection parameters) for different
> profiles.  I suppose I could set a property and then test if that 
> property is set in the maven-source-plugin - executions - execution tag.
> 
> Is this the right way to do conditional execution in maven?
> 
> What's the "right" way to do this in maven?
> 
> Thanks.
> 
> 
> 
> 


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