Extension works from lib/ext and CLI but not extensions.xml

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Extension works from lib/ext and CLI but not extensions.xml

J. Lewis Muir
Hello, all!

I'm trying to use the EL Profile Activation Maven Extension

  https://github.com/kpiwko/el-profile-activator-extension

to activate a profile when the foo_env system property is either not
set, or set to "development".  I'm using the "help:active-profiles" goal
of the Maven Help plugin and the "validate" phase to test whether or not
a profile is active.

The extension works when I install it in

  <maven-home>/lib/ext

and it works when I specify it on the command line with

  -Dmaven.ext.class.path=<paths-to-extension-jars>

but it does *not* work when I put it in the project's

  .mvn/extensions.xml

Does anyone know why?!

This is Maven 3.5.4, the latest Git snapshot of EL Profile Activation
Maven Extension, and MVEL 2.4.2.Final.

The el-profile-activator-extension artifact is not published in the
Central Repository, but I installed it into my local repository (i.e.,
~/.m2/repository) with

  git clone https://github.com/kpiwko/el-profile-activator-extension.git
  cd el-profile-activator-extension
  : JAVA_HOME has been set to a Java 8 SDK to compile
  mvn install

That should be fine, right?  My local repository will be searched first
for any artifacts listed in extensions.xml, and I don't get a warning
nor error about it not being found, so my understanding is that this is
OK.

For the case where the extension does not work, I have a test-01 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) || (isdef foo_env &amp;&amp; foo_env == "development")</value>
          </property>
        </activation>
      </profile>
    </profiles>
  </project>

and the following .mvn/extensions.xml file

  <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>com.redhat.jboss.maven</groupId>
      <artifactId>el-profile-activator-extension</artifactId>
      <version>1.0.0-SNAPSHOT</version>
    </extension>
  </extensions>

I invoke Maven like this

  mvn help:active-profiles validate

and it shows that the foo_env-development profile is not active (i.e.,
it lists no active profiles)

  The following profiles are active:

but it should be!

A transcript of this and with the "-X" option is attached as

  test-01-extensions-dot-xml.txt

Removing the .mvn directory and adding

  el-profile-activator-extension-1.0.0-SNAPSHOT.jar

and

  mvel2-2.4.2.Final.jar

to

  <maven-home>/lib/ext

works; i.e., it shows that the foo_env-development profile is active

  The following profiles are active:

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

A transcript of this and with the "-X" option is attached as

  test-01-maven-home-lib-ext.txt

Removing those JARs from

  <maven-home>/lib/ext

and instead specifying them on the command line by setting the

  maven.ext.class.path

system property works; i.e., it shows that the foo_env-development
profile is active

  The following profiles are active:

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

A transcript of this and with the "-X" option is attached as

  test-01-maven-ext-class-path.txt

Any help getting the extensions.xml case to work would be greatly
appreciated!  Thank you!

Lewis


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

test-01-extensions-dot-xml.txt (24K) Download Attachment
test-01-maven-home-lib-ext.txt (19K) Download Attachment
test-01-maven-ext-class-path.txt (20K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Extension works from lib/ext and CLI but not extensions.xml

Matthieu BROUILLARD-3
Not sure but I think the mechanism extension does not work for SNAPSHOT
versions.
Try to install a non SNAPSHOT version in your local maven repository.
I think I have already faced the same in the past while producing with my
own extension https://github.com/jgitver/jgitver-maven-plugin

Hope it helps.

Matthieu

On Fri, Oct 26, 2018 at 7:39 AM J. Lewis Muir <[hidden email]> wrote:

> Hello, all!
>
> I'm trying to use the EL Profile Activation Maven Extension
>
>   https://github.com/kpiwko/el-profile-activator-extension
>
> to activate a profile when the foo_env system property is either not
> set, or set to "development".  I'm using the "help:active-profiles" goal
> of the Maven Help plugin and the "validate" phase to test whether or not
> a profile is active.
>
> The extension works when I install it in
>
>   <maven-home>/lib/ext
>
> and it works when I specify it on the command line with
>
>   -Dmaven.ext.class.path=<paths-to-extension-jars>
>
> but it does *not* work when I put it in the project's
>
>   .mvn/extensions.xml
>
> Does anyone know why?!
>
> This is Maven 3.5.4, the latest Git snapshot of EL Profile Activation
> Maven Extension, and MVEL 2.4.2.Final.
>
> The el-profile-activator-extension artifact is not published in the
> Central Repository, but I installed it into my local repository (i.e.,
> ~/.m2/repository) with
>
>   git clone https://github.com/kpiwko/el-profile-activator-extension.git
>   cd el-profile-activator-extension
>   : JAVA_HOME has been set to a Java 8 SDK to compile
>   mvn install
>
> That should be fine, right?  My local repository will be searched first
> for any artifacts listed in extensions.xml, and I don't get a warning
> nor error about it not being found, so my understanding is that this is
> OK.
>
> For the case where the extension does not work, I have a test-01 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) || (isdef foo_env &amp;&amp; foo_env
> == "development")</value>
>           </property>
>         </activation>
>       </profile>
>     </profiles>
>   </project>
>
> and the following .mvn/extensions.xml file
>
>   <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>com.redhat.jboss.maven</groupId>
>       <artifactId>el-profile-activator-extension</artifactId>
>       <version>1.0.0-SNAPSHOT</version>
>     </extension>
>   </extensions>
>
> I invoke Maven like this
>
>   mvn help:active-profiles validate
>
> and it shows that the foo_env-development profile is not active (i.e.,
> it lists no active profiles)
>
>   The following profiles are active:
>
> but it should be!
>
> A transcript of this and with the "-X" option is attached as
>
>   test-01-extensions-dot-xml.txt
>
> Removing the .mvn directory and adding
>
>   el-profile-activator-extension-1.0.0-SNAPSHOT.jar
>
> and
>
>   mvel2-2.4.2.Final.jar
>
> to
>
>   <maven-home>/lib/ext
>
> works; i.e., it shows that the foo_env-development profile is active
>
>   The following profiles are active:
>
>    - foo_env-development (source: org.example.foo:foo:1.0.0)
>
> A transcript of this and with the "-X" option is attached as
>
>   test-01-maven-home-lib-ext.txt
>
> Removing those JARs from
>
>   <maven-home>/lib/ext
>
> and instead specifying them on the command line by setting the
>
>   maven.ext.class.path
>
> system property works; i.e., it shows that the foo_env-development
> profile is active
>
>   The following profiles are active:
>
>    - foo_env-development (source: org.example.foo:foo:1.0.0)
>
> A transcript of this and with the "-X" option is attached as
>
>   test-01-maven-ext-class-path.txt
>
> Any help getting the extensions.xml case to work would be greatly
> appreciated!  Thank you!
>
> Lewis
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Extension works from lib/ext and CLI but not extensions.xml

J. Lewis Muir
On 10/26, Matthieu BROUILLARD wrote:
> Not sure but I think the mechanism extension does not work for SNAPSHOT
> versions.
> Try to install a non SNAPSHOT version in your local maven repository.

Thank you for the suggestion!  I took "-SNAPSHOT" out of the version and
installed it in my local repository and used it in extensions.xml, but
no dice, it still doesn't work. :-(

Lewis

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

Reply | Threaded
Open this post in threaded view
|

Re: Extension works from lib/ext and CLI but not extensions.xml

Karl Heinz Marbaise-3
In reply to this post by Matthieu BROUILLARD-3
Hi,

On 26/10/18 10:16, Matthieu BROUILLARD wrote:
> Not sure but I think the mechanism extension does not work for SNAPSHOT
> versions.


No. There is something else different/wrong...


> Try to install a non SNAPSHOT version in your local maven repository.
> I think I have already faced the same in the past while producing with my
> own extension https://github.com/jgitver/jgitver-maven-plugin
>
> Hope it helps.
>
> Matthieu
>
> On Fri, Oct 26, 2018 at 7:39 AM J. Lewis Muir <[hidden email]> wrote:
>
>> Hello, all!
>>
>> I'm trying to use the EL Profile Activation Maven Extension
>>
>>    https://github.com/kpiwko/el-profile-activator-extension
>>
>> to activate a profile when the foo_env system property is either not
>> set, or set to "development".  I'm using the "help:active-profiles" goal
>> of the Maven Help plugin and the "validate" phase to test whether or not
>> a profile is active.
>>
>> The extension works when I install it in
>>
>>    <maven-home>/lib/ext
>>
>> and it works when I specify it on the command line with
>>
>>    -Dmaven.ext.class.path=<paths-to-extension-jars>
>>
>> but it does *not* work when I put it in the project's
>>
>>    .mvn/extensions.xml
>>
>> Does anyone know why?!
>>
>> This is Maven 3.5.4, the latest Git snapshot of EL Profile Activation
>> Maven Extension, and MVEL 2.4.2.Final.
>>
>> The el-profile-activator-extension artifact is not published in the
>> Central Repository, but I installed it into my local repository (i.e.,
>> ~/.m2/repository) with
>>
>>    git clone https://github.com/kpiwko/el-profile-activator-extension.git
>>    cd el-profile-activator-extension
>>    : JAVA_HOME has been set to a Java 8 SDK to compile
>>    mvn install
>>
>> That should be fine, right?  My local repository will be searched first
>> for any artifacts listed in extensions.xml, and I don't get a warning
>> nor error about it not being found, so my understanding is that this is
>> OK.
>>
>> For the case where the extension does not work, I have a test-01 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) || (isdef foo_env &amp;&amp; foo_env
>> == "development")</value>
>>            </property>
>>          </activation>
>>        </profile>
>>      </profiles>
>>    </project>
>>
>> and the following .mvn/extensions.xml file
>>
>>    <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>com.redhat.jboss.maven</groupId>
>>        <artifactId>el-profile-activator-extension</artifactId>
>>        <version>1.0.0-SNAPSHOT</version>
>>      </extension>
>>    </extensions>
>>
>> I invoke Maven like this
>>
>>    mvn help:active-profiles validate
>>
>> and it shows that the foo_env-development profile is not active (i.e.,
>> it lists no active profiles)
>>
>>    The following profiles are active:
>>
>> but it should be!
>>
>> A transcript of this and with the "-X" option is attached as
>>
>>    test-01-extensions-dot-xml.txt
>>
>> Removing the .mvn directory and adding
>>
>>    el-profile-activator-extension-1.0.0-SNAPSHOT.jar
>>
>> and
>>
>>    mvel2-2.4.2.Final.jar
>>
>> to
>>
>>    <maven-home>/lib/ext
>>
>> works; i.e., it shows that the foo_env-development profile is active
>>
>>    The following profiles are active:
>>
>>     - foo_env-development (source: org.example.foo:foo:1.0.0)
>>
>> A transcript of this and with the "-X" option is attached as
>>
>>    test-01-maven-home-lib-ext.txt
>>
>> Removing those JARs from
>>
>>    <maven-home>/lib/ext
>>
>> and instead specifying them on the command line by setting the
>>
>>    maven.ext.class.path
>>
>> system property works; i.e., it shows that the foo_env-development
>> profile is active
>>
>>    The following profiles are active:
>>
>>     - foo_env-development (source: org.example.foo:foo:1.0.0)
>>
>> A transcript of this and with the "-X" option is attached as
>>
>>    test-01-maven-ext-class-path.txt
>>
>> Any help getting the extensions.xml case to work would be greatly
>> appreciated!  Thank you!
>>
>> Lewis

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

Reply | Threaded
Open this post in threaded view
|

Re: Extension works from lib/ext and CLI but not extensions.xml

J. Lewis Muir
In reply to this post by J. Lewis Muir
On 10/26, J. Lewis Muir wrote:
> This is Maven 3.5.4, the latest Git snapshot of EL Profile Activation
> Maven Extension, and MVEL 2.4.2.Final.

To head off any confusion for anyone looking closely at the transcripts,
the Git snapshot of EL Profile Activation Maven Extension that I used
was c3b490a, but I realized I made one change after cloning: I changed
the version of the mvel2 dependency in pom.xml from "2.3.0.Final" to
"2.4.2.Final" (one of my many shot-in-the-dark attempts at getting it to
work).  So, the transcripts are with the el-profile-activator-extension
artifact built with this change.

Lewis

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

Reply | Threaded
Open this post in threaded view
|

Re: Extension works from lib/ext and CLI but not extensions.xml

Mirko Friedenhagen-5
In reply to this post by Karl Heinz Marbaise-3
Hello,

I think extensions are looked up in pluginRepositories, not the standard repositories. Maybe that’s your problem?

Best Regards
Mirko Friedenhagen

Sent from my mobile

Am 26.10.18 um 17:41 schrieb Karl Heinz Marbaise

> Hi,
>
> On 26/10/18 10:16, Matthieu BROUILLARD wrote:
> > Not sure but I think the mechanism extension does not work for SNAPSHOT
> > versions.
>
>
> No. There is something else different/wrong...
>
>
> > Try to install a non SNAPSHOT version in your local maven repository.
> > I think I have already faced the same in the past while producing with my
> > own extension https://github.com/jgitver/jgitver-maven-plugin
> >
> > Hope it helps.
> >
> > Matthieu
> >
> > On Fri, Oct 26, 2018 at 7:39 AM J. Lewis Muir <[hidden email]> wrote:
> >
> >> Hello, all!
> >>
> >> I'm trying to use the EL Profile Activation Maven Extension
> >>
> >>    https://github.com/kpiwko/el-profile-activator-extension
> >>
> >> to activate a profile when the foo_env system property is either not
> >> set, or set to "development".  I'm using the "help:active-profiles" goal
> >> of the Maven Help plugin and the "validate" phase to test whether or not
> >> a profile is active.
> >>
> >> The extension works when I install it in
> >>
> >>    <maven-home>/lib/ext
> >>
> >> and it works when I specify it on the command line with
> >>
> >>    -Dmaven.ext.class.path=<paths-to-extension-jars>
> >>
> >> but it does *not* work when I put it in the project's
> >>
> >>    .mvn/extensions.xml
> >>
> >> Does anyone know why?!
> >>
> >> This is Maven 3.5.4, the latest Git snapshot of EL Profile Activation
> >> Maven Extension, and MVEL 2.4.2.Final.
> >>
> >> The el-profile-activator-extension artifact is not published in the
> >> Central Repository, but I installed it into my local repository (i.e.,
> >> ~/.m2/repository) with
> >>
> >>    git clone https://github.com/kpiwko/el-profile-activator-extension.git
> >>    cd el-profile-activator-extension
> >>    : JAVA_HOME has been set to a Java 8 SDK to compile
> >>    mvn install
> >>
> >> That should be fine, right?  My local repository will be searched first
> >> for any artifacts listed in extensions.xml, and I don't get a warning
> >> nor error about it not being found, so my understanding is that this is
> >> OK.
> >>
> >> For the case where the extension does not work, I have a test-01 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) || (isdef foo_env &amp;&amp; foo_env
> >> == "development")</value>
> >>            </property>
> >>          </activation>
> >>        </profile>
> >>      </profiles>
> >>    </project>
> >>
> >> and the following .mvn/extensions.xml file
> >>
> >>    <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>com.redhat.jboss.maven</groupId>
> >>        <artifactId>el-profile-activator-extension</artifactId>
> >>        <version>1.0.0-SNAPSHOT</version>
> >>      </extension>
> >>    </extensions>
> >>
> >> I invoke Maven like this
> >>
> >>    mvn help:active-profiles validate
> >>
> >> and it shows that the foo_env-development profile is not active (i.e.,
> >> it lists no active profiles)
> >>
> >>    The following profiles are active:
> >>
> >> but it should be!
> >>
> >> A transcript of this and with the "-X" option is attached as
> >>
> >>    test-01-extensions-dot-xml.txt
> >>
> >> Removing the .mvn directory and adding
> >>
> >>    el-profile-activator-extension-1.0.0-SNAPSHOT.jar
> >>
> >> and
> >>
> >>    mvel2-2.4.2.Final.jar
> >>
> >> to
> >>
> >>    <maven-home>/lib/ext
> >>
> >> works; i.e., it shows that the foo_env-development profile is active
> >>
> >>    The following profiles are active:
> >>
> >>     - foo_env-development (source: org.example.foo:foo:1.0.0)
> >>
> >> A transcript of this and with the "-X" option is attached as
> >>
> >>    test-01-maven-home-lib-ext.txt
> >>
> >> Removing those JARs from
> >>
> >>    <maven-home>/lib/ext
> >>
> >> and instead specifying them on the command line by setting the
> >>
> >>    maven.ext.class.path
> >>
> >> system property works; i.e., it shows that the foo_env-development
> >> profile is active
> >>
> >>    The following profiles are active:
> >>
> >>     - foo_env-development (source: org.example.foo:foo:1.0.0)
> >>
> >> A transcript of this and with the "-X" option is attached as
> >>
> >>    test-01-maven-ext-class-path.txt
> >>
> >> Any help getting the extensions.xml case to work would be greatly
> >> appreciated!  Thank you!
> >>
> >> Lewis
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]

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

Reply | Threaded
Open this post in threaded view
|

Re: Extension works from lib/ext and CLI but not extensions.xml

J. Lewis Muir
On 10/26, Mirko Friedenhagen wrote:
> Hello,
>
> I think extensions are looked up in pluginRepositories, not the
> standard repositories. Maybe that’s your problem?
>
> Best Regards
> Mirko Friedenhagen

Thank you for your suggestion.  How can I test this hypothesis?
I do not have a ~/.m2/settings.xml file, so there are no custom
repositories there, and the test-01 project's pom.xml does not contain
any custom repositories.  I'm just depending on Maven being able to
find in my local repository (~/.m2/repository) the extension listed
in extensions.xml.  I don't see any errors in the transcript for the
"-X" invocation that would suggest it wasn't able to find the extension
artifact; it's just that the extension doesn't work when loaded from
extensions.xml.

I tried hacking

  ~/.m2/repository/com/redhat/jboss/maven/el-profile-activator-extension/1.0.0/_remote.repositories

which contained

  el-profile-activator-extension-1.0.0.pom>=
  el-profile-activator-extension-1.0.0.jar>=

by making it look like the artifact came from Maven Central

  el-profile-activator-extension-1.0.0.pom>central=
  el-profile-activator-extension-1.0.0.jar>central=

but that didn't help; the extension still didn't work when loaded via
extensions.xml.

Lewis

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