You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Xie Jilei <xj...@99jsj.com> on 2011/01/21 06:40:52 UTC

How to add a custom ProfileActivator in Maven3?

I'm create a new ProfileActivator like:

    @Component(role = ProfileActivator.class, hint = "ldap")
    public class LdapQueryProfileActivator
            implements ProfileActivator {
        // ...
        public LdapQueryProfileActivator() {
              System.err.println("xxx");
              FileUtil.writeFile("/tmp/mark123", "xyz");
              // ...
        }
    }

It seems like the new activator hasn't been installed into Maven.

However, run the example test:

    public class LdapProfileActivatorTest
            extends AbstractProfileActivatorTest<LdapProfileActivator> {

        public LdapProfileActivatorTest() {
            super(LdapProfileActivator.class);
        }

        Profile newProfile() {
            Activation activation = new Activation();

            Profile profile = new Profile();
            profile.setActivation(activation);

            return profile;
        }

        public void testDefault() {
            Profile profile = newProfile();
            ProfileActivationContext context = newContext(null, null);
            assertActivation(true, profile, context);
        }

    }

In this test, I can see the correct diagnostic output: "xxx" "xyz", etc.

Any idea? I'm using Maven 3.0.2.

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


Re: How to add a custom ProfileActivator in Maven3?

Posted by Benjamin Bentmann <be...@udo.edu>.
Xie Jilei wrote:

> I'm create a new ProfileActivator like:

You can't, it's not supported.


Benjamin

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


Re: How to add a custom ProfileActivator in Maven3?

Posted by Xie Jilei <xj...@99jsj.com>.
This is my user pom:

    <build>
        <extensions>
            <extension>
                <groupId>my.group.id</groupId>
                <artifactId>ldap-activator</artifactId>
                <version>0.0.1-SNAPSHOT</version>
            </extension>
        </extensions>
    </build>
    <profiles>
        <profile>
            <id>ldap-test</id>
            <activation />
            ...
        </profile>
    </profiles>

Maybe the profile activator should put somewhere else then <extension> tag?

Lenik

On Fri, Jan 21, 2011 at 1:40 PM, Xie Jilei <xj...@99jsj.com> wrote:
> I'm create a new ProfileActivator like:
>
>    @Component(role = ProfileActivator.class, hint = "ldap")
>    public class LdapQueryProfileActivator
>            implements ProfileActivator {
>        // ...
>        public LdapQueryProfileActivator() {
>              System.err.println("xxx");
>              FileUtil.writeFile("/tmp/mark123", "xyz");
>              // ...
>        }
>    }
>
> It seems like the new activator hasn't been installed into Maven.
>
> However, run the example test:
>
>    public class LdapProfileActivatorTest
>            extends AbstractProfileActivatorTest<LdapProfileActivator> {
>
>        public LdapProfileActivatorTest() {
>            super(LdapProfileActivator.class);
>        }
>
>        Profile newProfile() {
>            Activation activation = new Activation();
>
>            Profile profile = new Profile();
>            profile.setActivation(activation);
>
>            return profile;
>        }
>
>        public void testDefault() {
>            Profile profile = newProfile();
>            ProfileActivationContext context = newContext(null, null);
>            assertActivation(true, profile, context);
>        }
>
>    }
>
> In this test, I can see the correct diagnostic output: "xxx" "xyz", etc.
>
> Any idea? I'm using Maven 3.0.2.
>

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