Dunstan, Tom (SACE Board) wrote:

> Hi all
>  
> We're trying to set up a set of maven projects which can be used with both
> spring 2.5.x and spring 3.0.x. Mostly our applications are currently using
> 2.5.6 atm, but we'd like to gradually move them over to 3.0.x as time goes
> on.
>  
> Rather than have our libraries and apps hard-code the versions of the
> various spring modules, spring security modules and the compatible junit
> library, I'm trying to put those version numbers into our parent pom under
> spring2/spring3 profiles with <dependencyManagement> sections which can
> then be activated project by project.

If the difference is only the vesion number I'd define onyle the versions in 
the profiles using properties. Trims down the clutter ...

> This only works if specifying that
> profile on the command line, though. There appears to be no other way to
> activate the parent pom profile:
> 
>  - I've tried creating a profiles.xml and adding the id to the
>  <activeProfiles> section, but this appears not to work unless the profile
>  is also declared in that file, and if I declare it, the information from
>  the parent pom is then ignored. Having this setup working would be the
>  ideal, as I don't want the profile getting switched off if I happen to
>  activate another profile.

Profiles.xml is deprecated and IIRC not supported in M3.

>  - I've tried defining the profile again the child pom and marking it
>  <activeByDefault>. This wouldn't be ideal, since activating any other
>  profile would switch it off, but it doesn't work anyway.
>
>  - I've tried creating a file and activating the profile by file
>  existence.

This does not activate the profile in the parent.

>  - I've even tried setting a property in the child pom, but it seems that
>  this is read too late in the process.

You cannot use properties defined in the POM. The profiles in every POMs are 
resolved first locally for the POM only and the profile activation is not 
inherited.

> I really *don't* want to have to specify the profile name on the command
> line every time. It's not something that is going to change often, and
> it's easy for one of our devs (including me!) to accidentally leave off.
> We've considered having the different spring settings in different
> intermediate pom projects, but we plan to have other children of our
> parent on an orthogonal axis (e.g. one for web apps etc, one for webstart
> etc). Lack of mixins or an equivalent in maven is kinda hurting us.
> 
> Is there any way to activate this parent profile for every build of a
> dependent project?
> 
> Am I going about this the wrong way? Surely we aren't the only people
> trying to define a coherent set of dependencies in a non-hardcoded
> fashion...
> 
> Any suggestions gratefully accepted!

Active the profile directly in the settings.xml. This behaves similar to the 
command line activation.

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to