[
https://jira.codehaus.org/browse/MRESOURCES-193?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
John Harvey updated MRESOURCES-193:
-----------------------------------
Attachment: pom.xml
Pom-file that produces the issue
> Generated properties appear to be ignored by the resources plugin
> -----------------------------------------------------------------
>
> Key: MRESOURCES-193
> URL: https://jira.codehaus.org/browse/MRESOURCES-193
> Project: Maven Resources Plugin
> Issue Type: Bug
> Components: copy
> Affects Versions: 2.3, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.5, 2.6, 2.7
> Environment: Running on Mac OS X
> Apache Maven 3.2.3
> Java version: 1.6.0_65, vendor: Apple Inc.
> Reporter: John Harvey
> Attachments: pom.xml
>
>
> There are currently two plugins that I'm aware of that can generate a
> property; one is the build-helper-maven-plugin from org.codehaus.mojo, and
> the other is
> gmaven-plugin from org.codehaus.groovy.maven. What these plugins do is allow
> you to run a regex on a pre-defined property and therefore generate a new
> property.
> For my project, I'm trying to transform the 1.6.0-SNAPSHOT project.version
> into a simpler new string, essentially v1p6p0. I'm doing this with a regex,
> and the variable this will be stored in is called target.version.encoded.
> I'd like to use that property name to create a directory with that name
> during resources:resources execution. Note that I can easily do this with a
> hardcoded property.
> The regex happens at the validate phase of the build.
> The resources copy happens at the process-resources phase of the build.
> I have an ANT task that runs in-between these two processes during the
> initialize phase of the build, in order to print out the variable, which
> verifies that it was created properly. Unfortunately, when the
> resources:resources phase runs, the newly-generated property is ignored, and
> a directory called ${target.version.encoded} is created. My pom is below,
> followed by the important part of the log that I see.
> In the pom-file, you can comment out the "TEST 1" plugin section and replace
> it with the "TEST2" and you'll see similar results. If you don't run the pom
> with the "prod" profile, you can also see everything work with the hard-coded
> property for target.version.encoded.
> Here is the pom:
> <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>com.fake</groupId>
> <artifactId>fake-parent</artifactId>
> <version>1.6.0-SNAPSHOT</version>
> <packaging>jar</packaging>
> <name>fake parent pom</name>
> <description>Fake Parent pom</description>
> <profiles>
> <profile>
> <id>dev</id>
> <activation>
> <activeByDefault>true</activeByDefault>
> </activation>
> <properties>
> <target.version.encoded>dev</target.version.encoded>
> </properties>
> </profile>
> <profile>
> <id>prod</id>
> <activation>
> <activeByDefault>false</activeByDefault>
> </activation>
> <build>
> <plugins>
> <!-- TEST 1 (enabled) -->
> <plugin>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>build-helper-maven-plugin</artifactId>
> <version>1.9.1</version>
> <executions>
> <execution>
> <id>regex-target.version.encoded</id>
> <phase>validate</phase>
> <goals>
> <goal>regex-property</goal>
> </goals>
> <configuration>
> <name>target.version.encoded</name>
> <value>${project.version}</value>
>
> <regex>^([0-9]+)\.([0-9]+)\.([0-9]+)(-SNAPSHOT)?$</regex>
> <replacement>v$1p$2p$3</replacement>
> <failIfNoMatch>true</failIfNoMatch>
> </configuration>
> </execution>
> </executions>
> </plugin>
> <!-- TEST 2 (disabled for now)
> <plugin>
> <groupId>org.codehaus.groovy.maven</groupId>
> <artifactId>gmaven-plugin</artifactId>
> <executions>
> <execution>
> <phase>validate</phase>
> <goals>
> <goal>execute</goal>
> </goals>
> <configuration>
> <source>
>
> System.setProperty("target.version.encoded",
> "${version}".replace('-SNAPSHOT', ''))
>
> project.properties.setProperty("target.version.encoded",
> "${version}".replace('-SNAPSHOT', ''))
> </source>
> </configuration>
> </execution>
> </executions>
> </plugin>
> -->
> </plugins>
> </build>
> </profile>
> </profiles>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-antrun-plugin</artifactId>
> <version>1.1</version>
> <executions>
> <execution>
> <phase>initialize</phase>
> <goals>
> <goal>run</goal>
> </goals>
> <configuration>
> <tasks>
>
> <echo>=======================================</echo>
> <echo>DYNAMIC VARIABLES</echo>
>
> <echo>=======================================</echo>
> <echo>[target.version.encoded]
> ${target.version.encoded}</echo>
>
> <echo>=======================================</echo>
> </tasks>
> </configuration>
> </execution>
> </executions>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-resources-plugin</artifactId>
> <version>2.3</version>
> <configuration>
> <param>${target.version.encoded}</param>
> </configuration>
> </plugin>
> </plugins>
> <resources>
> <resource>
> <filtering>false</filtering>
> <directory>${basedir}/</directory>
>
> <targetPath>${project.build.directory}/${target.version.encoded}</targetPath>
> </resource>
> </resources>
> </build>
> <repositories>
> <repository>
> <id>Maven Central</id>
> <url>http://repo1.maven.org/maven2</url>
> </repository>
> </repositories>
> </project>
> Command: mvn -Pprod clean install
> Log:
> [INFO] --- build-helper-maven-plugin:1.9.1:regex-property
> (regex-target.version.encoded) @ fake-parent ---
> [INFO]
> [INFO] --- maven-antrun-plugin:1.1:run (default) @ fake-parent ---
> [INFO] Executing tasks
> [echo] =======================================
> [echo] DYNAMIC VARIABLES
> [echo] =======================================
> [echo] [target.version.encoded] v1p6p0
> [echo] =======================================
> [INFO] Executed tasks
> [INFO]
> [INFO] --- maven-resources-plugin:2.3:resources (default-resources) @
> fake-parent ---
> [WARNING] Using platform encoding (MacRoman actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 1 resource to
> /Users/user/git/example2/target/${target.version.encoded}
> Result:
> - You can see that the ant task clearly knows target.version.encoded,
> whereas the replacer version does not. When I look in target/, I see a
> directory called "${target.version.encoded}".
> Note that if you run the command without the -Pprod profile,
> target.version.encoded becomes "dev", and the target/dev directory is created
> appropriately.
> I tried with versions 2.3 through 2.7 of the resources plugin, and with both
> property-creator plugins. Since both produce the same result, I am
> suspicious of the resources plugin. However, the issue could be that those
> plugins produce non-standard output, although that does not seem to be the
> case based on the fact that the ant script works fine with the newly-created
> property.
> Any help would be appreciated.
--
This message was sent by Atlassian JIRA
(v6.1.6#6162)