[
https://jira.codehaus.org/browse/MRESOURCES-193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=355947#comment-355947
]
John Harvey commented on MRESOURCES-193:
----------------------------------------
I'd like to note that a workaround was found, but it's a little ugly.
Instead of doing this:
<resources>
<resource>
<filtering>false</filtering>
<directory>${basedir}/</directory>
<targetPath>${project.build.directory}/${target.version.encoded}</targetPath>
</resource>
</resources>
I can do the following, and it works:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources_1</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${target.version.encoded}</outputDirectory>
<resources>
<resource>
<filtering>false</filtering>
<directory>${basedir}/</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
This demonstrates to me that the maven resources plugin DOES work--- when
invoked directly.
However, the issue is with the <resources> section of a pom. I don't know what
version of the maven-resources-plugin it uses by default, but it exhibits this
problem.
Obviously, I'd prefer to just put my stuff in a <resources> block for
cleanliness instead of having redundant <resources> blocks under every
execution, but I can deal for now. I hope this update helps pinpoint the
problem.
> 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 (attached), 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.
> The pom is attached to preserve formatting.
> 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)