kpiwko / el-profile-activator-extension

Support for expression languages in profile activation in Maven
16 stars 11 forks source link

No way to get value of property with dot in name #4

Open jlmuir opened 5 years ago

jlmuir commented 5 years ago

I tried to use the property foo.env to control profile activation, but the extension fails to evaluate the expression:

$ mvn -Dfoo.env=development validate
[INFO] Scanning for projects...
[WARNING] Unable to evaluate mvel property value ("if (isdef foo.env) {
  foo.env == "development";
} else {
  true;
}")
[INFO]
[INFO] ------------------------< org.example.foo:foo >-------------------------
[INFO] Building foo 1.0.0
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.230 s
[INFO] Finished at: 2018-10-19T17:27:51-05:00
[INFO] ------------------------------------------------------------------------

Is it treating foo.env as a property expression (i.e., an expression to extract the env property out of the foo variable or context object)?

This is with Maven 3.5.4, MVEL 2.4.2, and EL Profile Activation Maven Extension snapshot c3b490a.

The pom.xml file contains:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
        http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.example.foo</groupId>
  <artifactId>foo</artifactId>
  <version>1.0.0</version>
  <packaging>pom</packaging>
  <profiles>
    <profile>
      <id>foo.env-development</id>
      <activation>
        <property>
          <name>mvel</name>
          <value>
<![CDATA[
if (isdef foo.env) {
  foo.env == "development";
} else {
  true;
}
]]>
          </value>
        </property>
      </activation>
    </profile>
  </profiles>
</project>

How can I get the value of the foo.env property?

The Profile Activator Extension seems to have adopted the syntax value["foo.env"] for this situation.