Extension does not work from .mvn/extensions.xml

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Extension does not work from .mvn/extensions.xml

J. Lewis Muir
Hello, all!

I little under two weeks ago, I posted with the subject "Extension works
from lib/ext and CLI but not extensions.xml"

  https://lists.apache.org/thread.html/23bea6ae06f17a3f256465e2c27a04ee9f90de3f49f21d20a627b85f@%3Cusers.maven.apache.org%3E

Now I have reluctantly forked that extension to create my own

  https://github.com/imca-cat/profile-activation-advanced

and have published to the Central Repository.

Unfortunately, the same problem persists.  But at least now there can
be no question about trying to use an extension fetched from my local
repository that had not been published to the Central Repository, and
hopefully it will be easier for someone to try this and help figure out
what's wrong (i.e., no need to build the extension).

The extension works if I put its JAR in Maven's lib/ext directory, but
it does not work when loaded via a project's .mvn/extensions.xml file.
Having it work from .mvn/extensions.xml is critical for my intended use.
Does anyone know why it doesn't work or what I could do to figure out
why it doesn't work?

To reproduce the problem, simply create a new Maven project directory
containing the following pom.xml file:

===
<?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>(!isdef foo_env) || foo_env == "development"</value>
        </property>
      </activation>
    </profile>
  </profiles>
</project>
===

Then create .mvn/extensions.xml:

===
<?xml version="1.0" encoding="UTF-8"?>
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0
        http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
  <extension>
    <groupId>org.imca-cat.maven</groupId>
    <artifactId>profile-activation-advanced</artifactId>
    <version>0.1.0</version>
  </extension>
</extensions>
===

Then run the following command:

===
$ mvn help:active-profiles validate
===

It should report that the foo_env-development profile is active

===
The following profiles are active:

 - foo_env-development (source: org.example.foo:foo:1.0.0)
===

but it does not

===
The following profiles are active:
===

If I place the extension's JAR file (and the JAR file for its mvel2
dependency) in Maven's lib/ext directory, it works: the command reports
that the foo_env-development profile is active, which is the correct
behavior.

Thank you to anyone who can help!

Lewis

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