payara / ecosystem-support

Placeholder repository to handle community requests for the Payara Platform ecosystem tools
4 stars 2 forks source link

Bug Report: Maven regex-profile-activator extension seems not to work in Maven 3.9/FISH-9752 #93

Open sroughley opened 2 months ago

sroughley commented 2 months ago

Brief Summary

Regex-based profile activation appears not to work using regex-profile-activator with Mavn 3.9.9

Expected Outcome

A maven profile should be activated when using this plugin during compilation

Current Outcome

The profile activation appears not to be happening

Reproducer

Creating a simple empty Maven project with the following pom.xml file:

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.vernalis</groupId>
    <artifactId>bugreport</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <payara.version>0.5</payara.version>
        <keyword>5.2</keyword>
    </properties>

    <profiles>
        <profile>
            <id>test-keyword</id>
            <activation>
                <property>
                    <name>keyword</name>
                    <value>/test.*/</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <id>test-print</id>
                                <phase>clean</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <echo message="TEST Profile active" />
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>fish.payara.maven.extensions</groupId>
            <artifactId>regex-profile-activator</artifactId>
            <version>${payara.version}</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>version-print</id>
                        <phase>clean</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <echo message="Keyword: ${keyword}" />
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

and running the following command:

mvn clean -Dkeyword=testing

Should activate the test-keyword profile as shown by the phrase TEST Profile active appearing in the console output, however this does not happen, e.g.:

$ mvn clean -Dkeyword=testing
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< com.vernalis:bugreport >-----------------------
[INFO] Building bugreport 0.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- clean:3.2.0:clean (default-clean) @ bugreport ---
[INFO] Deleting E:\bugreport\target
[INFO]
[INFO] --- antrun:3.1.0:run (version-print) @ bugreport ---
[INFO] Executing tasks
[WARNING]      [echo] Keyword: testing
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.653 s
[INFO] Finished at: 2024-09-09T13:33:42+01:00
[INFO] ------------------------------------------------------------------------

However, changing the <value> entry to a simple <value>testing</value> in the pom.x,ml and repeating shows the profile activated by the conventional means:

$ mvn clean -Dkeyword=testing
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< com.vernalis:bugreport >-----------------------
[INFO] Building bugreport 0.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- clean:3.2.0:clean (default-clean) @ bugreport ---
[INFO] Deleting E:\bugreport\target
[INFO]
[INFO] --- antrun:3.1.0:run (version-print) @ bugreport ---
[INFO] Executing tasks
[WARNING]      [echo] Keyword: testing
[INFO] Executed tasks
[INFO]
[INFO] --- antrun:3.1.0:run (test-print) @ bugreport ---
[INFO] Executing tasks
[WARNING]      [echo] TEST Profile active
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.696 s
[INFO] Finished at: 2024-09-09T13:28:32+01:00
[INFO] ------------------------------------------------------------------------

Maven / JDK version as shown:

$ mvn --version
Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Maven home: C:\Program Files\Apache\apache-maven-3.9.6
Java version: 21.0.3, vendor: Eclipse Adoptium, runtime: C:\Program Files\Eclipse Adoptium\jdk-21.0.3.9-hotspot
Default locale: en_GB, platform encoding: UTF-8
OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"

Operating System

Win11 Pro 23H2

JDK Version

Eclips Adoptium 21.0.3

Ecosystem Tool

Maven Regex Extension

felixif commented 1 month ago

Hello @sroughley,

I can confirm that the plugin does not seem to function at all based on your reproducer. I tried using older versions of Mavenm an older JDK and different combinations of regular expressions, without any success. I have raised an internal issue, codename FISH-9752, and the Platform Development team will have a look into this issue.

Thank you very much for your report!

Best regards, Felix

sroughley commented 1 month ago

Hi Felix,

Thanks for the update!

Steve