Hey there,

I am currently in the process of defining a pom hierarchy of a hugh
project, which was formally developed using Maven 1. As one of the
benefits we'd like to accomplish a grouping of dependencies / features
and configurations. On a first look profiles seemed promising, but the
lack of runtime evaluation of properties defined in the pom.xml itself
made it impossible to use (we can't use the settings.xml because each
component has a different set of dependencies based on the
capabilities and using the command line would be too much of a hazel
and just plain awkward).

Anyway, the idea of having a profile as some sort of a mixin stuck to
my head. So, I am currently wondering if it is possible to activate
profiles based on a plug-in. I gave it a very basic try by doing the
following:

    /**
     * @parameter default-value="${project}"
     * @required
     */
    private MavenProject project;

    @Override
    public void execute()
        throws MojoExecutionException
    {
        // before check
        printActiveProfiles();

        Iterator<Profile> pIter =
project.getModel().getProfiles().iterator(); // parent pom profiles
ignored for now
        ArrayList l = new ArrayList();
        while(pIter.hasNext()){
            Profile p = pIter.next();
            l.add(p);
        }
        // set profiles active
        project.setActiveProfiles(l);

        // after check
        printActiveProfiles();
    }

The code above shows that it does in fact change the project, but the
"activated" profiles don't get used. I assume, I didn't "inject" the
altered project set-up correctly, so I was wondering if someone has a
clue what to do here?

My ultimate goal is to enable a set of profiles (and later generally
include pom dependencies) based on a plug-in configuration. With this
I would be able to define dependencies and configurations and assemble
them on a "as needed" basis like real mixins for cross cutting
concerns.

Cheers,
Mirko

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

Reply via email to