[ https://jira.codehaus.org/browse/MRESOURCES-31?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=332282#comment-332282
]
Emeric MARTINEAU commented on MRESOURCES-31:
--------------------------------------------
Hi,
you can't use :
{code}
${project.dependencies[0].artifactId}
${project.dependencies["org.mvel:mvel"].version}
{code}
Why ?
Two things.
You must make difference between, filtering (in file) and replace in pom.
In pom file, $\{project.dependencies[0].artifactId} work (exemple below) because, is use class
called org.apache.maven.plugin.PluginParameterExpressionEvaluator that use org.codehaus.plexus.util.introspection.ReflectionValueExtractor
that support index properties
{code:xml}
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<tasks>
<echo>${project.dependencies[0].artifactId}</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
{code}
when your are in filtering, is use class org.codehaus.plexus.interpolation.PrefixedObjectValueSource
that use org.codehaus.plexus.interpolation.ObjectBasedValueSource that org.codehaus.plexus.interpolation.reflection.ReflectionValueExtractor
that not support index properties.
You can see that exemple :
{code}
project.dependencies=${project.dependencies}
give :
project.dependencies=[Dependency {groupId=org.apache.maven, artifactId=maven-plugin-api, version=2.0.6,
type=jar}, Dependency {groupId=org.apache.maven, artifactId=maven-model, version=3.0.5, type=jar}]
project.dependencies[0].artifactId=${project.dependencies[0].artifactId}
give :
project.dependencies[0].artifactId=${project.dependencies[0].artifactId}
{code}
to change this way, org.apache.maven.shared.filtering.DefaultMavenFileFilter (method getReader)
must be change.
I don't know if easy to change that (what are side effect ?).
Maybe someone of maven team may provide his point of view ?
> Dependency resolution for resource filtering
> --------------------------------------------
>
> Key: MRESOURCES-31
> URL: https://jira.codehaus.org/browse/MRESOURCES-31
> Project: Maven Resources Plugin
> Issue Type: Wish
> Affects Versions: 2.2
> Reporter: Daniel Holmen
> Priority: Minor
>
> I've been trying to use the project.compileClasspathElements property in a filtered
resource, but discovered that Resources plugin isn't set up to require dependency resolution.
The result of this is that i cannot use any of the classpath properties in my filtered resources.
> The solution is quite simple, just add a @requiresDependencyResolution annotation to
ResourcesMojo. I have no idea if this causes any bad side-effects - but it seemed to work
properly when I tested it locally.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
|