Hello.

*About JSR223 support for activating Profiles*
I have a modified version of *PropertyProfileActivation.java* that allows
activate a profile evaluating a script.
I've done that with JSR223, and it is a minimal modification.
The idea is:

   - Keep the old funcionality for property profile activation.
   - Allow the evaluation of scripts in some of the JSR223 languages
   allowed.
   - Add to the context of the evaluation the *ProjectProperties*, the
   *UserProperties* and *SystemProperties*.

*An example of this:*

<profile>

    <activation>

        <property>

            <name>=JavaScript</name>

            <value>( projectProperty == 'value' &amp;&amp; systemProperty
== '45' )

|| ( userProperty == 'development' )</value>

        </property>

    </activation>

</profile>

The explanation

The key to get this without modifying the current model of pom and choose
an ScriptEngine is the name of the property.

It begins with "*=*" (equals) char, to indicate that value is a JSR223
script, and after the equals char the name of the script engine.

We write the script in the value tag.

You can see in the example that we use system properties, project
properties and user properties, *AND* and *OR* logical operators, so you
can write so complex scripts as you want.

The logical AND should be written as &amp;&amp; because of XML.

*IMPORTANT*: The new *PropertyProfileActivation.java* converts the name of
the project properties, system properties and user properties to a safe
name, to allow use them in the script, so if you have a project property
with the name "*my.project.property*" it will be replaced in the script
context to "*my_project_property*".

Question

Do you think this could be interesting for Maven 3?

Greetings.

Reply via email to