[ 
https://jira.codehaus.org/browse/MRESOURCES-118?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=328349#comment-328349
 ] 

Emeric MARTINEAU edited comment on MRESOURCES-118 at 7/10/13 10:47 AM:
-----------------------------------------------------------------------

Hi,

I trie this,
{code:xml}
<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/maven-v4_0_0.xsd";>
        <modelVersion>4.0.0</modelVersion>
        <groupId>fr.emeric</groupId>
        <artifactId>titi</artifactId>
        <packaging>war</packaging>
        <version>0.0.1-SNAPSHOT</version>
        <name>Kiko lolo</name>

        <dependencies>
                <dependency>
                        <groupId>org.apache.maven</groupId>
                        <artifactId>maven-plugin-api</artifactId>
                        <version>2.0.6</version>
                </dependency>
        </dependencies>

        <properties>
                <myVar>${project.dependencies[0].artifactId}</myVar>
        </properties>

        <build>
                <resources>
                        <resource>
                                <directory>src/main/resources</directory>
                                <filtering>true</filtering>
                        </resource>
                </resources>
                
                <plugins>
                        <plugin>
                                <artifactId>maven-antrun-plugin</artifactId>
                                <executions>
                                        <execution>
                                                <phase>generate-sources</phase>
                                                <configuration>
                                                        <tasks>
                                                                
<echo>${project.compileClasspathElements}</echo>
                                                                
<echo>${project.dependencies[0].artifactId}</echo>
                                                                
<echo>${myVar}</echo>
                                                        </tasks>
                                                </configuration>
                                                <goals>
                                                        <goal>run</goal>
                                                </goals>
                                        </execution>
                                </executions>
                        </plugin>
                </plugins>
        </build>
</project>
{code:xml}

and I have the result :
[INFO] Executing tasks
     [echo] 
[D:\DONNEES\emeric\workspace_eclipse\generique-projet-js\target\classes, 
D:\DONNEES\emeric\workspace_eclipse\.m2\repository\org\apache\maven\maven-plugin-api\2.0.6\maven-plugin-api-2.0.6.jar]
     [echo] maven-plugin-api
     [echo] maven-plugin-api
[INFO] Executed tasks

In src/main/resources I have a file test.properties :
{code:txt}
project.compileClasspathElements=${project.compileClasspathElements}
project.dependencies[0].artifactId=${project.dependencies[0].artifactId}
myVar=${myVar}
{/code:txt}

I have result :
{code:txt}
project.compileClasspathElements=[D:\\DONNEES\\emeric\\workspace_eclipse\\generique-projet-js\\target\\classes]
project.dependencies[0].artifactId=${project.dependencies[0].artifactId}
myVar=${project.dependencies[0].artifactId}
{/code:txt}

I think project.dependencies anly avaible in pom file.

If you see http://jira.codehaus.org/browse/PLXUTILS-37
I understand this properties only scope on pom not a all access properties.

Can you explain your use case ?
Why want this properties to understand this issue and 
https://jira.codehaus.org/browse/MRESOURCES-31

PS : I think MRESOURCES-31 Is duplicate of this issue.
                
      was (Author: bubulemaster):
    Hi,

I trie this,
{code:xml}
<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/maven-v4_0_0.xsd";>
        <modelVersion>4.0.0</modelVersion>
        <groupId>fr.emeric</groupId>
        <artifactId>titi</artifactId>
        <packaging>war</packaging>
        <version>0.0.1-SNAPSHOT</version>
        <name>Kiko lolo</name>

        <dependencies>
                <dependency>
                        <groupId>org.apache.maven</groupId>
                        <artifactId>maven-plugin-api</artifactId>
                        <version>2.0.6</version>
                </dependency>
        </dependencies>

        <properties>
                <myVar>${project.dependencies[0].artifactId}</myVar>
        </properties>

        <build>
                <resources>
                        <resource>
                                <directory>src/main/resources</directory>
                                <filtering>true</filtering>
                        </resource>
                </resources>
                
                <plugins>
                        <plugin>
                                <artifactId>maven-antrun-plugin</artifactId>
                                <executions>
                                        <execution>
                                                <phase>generate-sources</phase>
                                                <configuration>
                                                        <tasks>
                                                                
<echo>${project.compileClasspathElements}</echo>
                                                                
<echo>${project.dependencies[0].artifactId}</echo>
                                                                
<echo>${myVar}</echo>
                                                        </tasks>
                                                </configuration>
                                                <goals>
                                                        <goal>run</goal>
                                                </goals>
                                        </execution>
                                </executions>
                        </plugin>
                </plugins>
        </build>
</project>
{code:xml}

and I have the result :
[INFO] Executing tasks
     [echo] 
[D:\DONNEES\emeric\workspace_eclipse\generique-projet-js\target\classes, 
D:\DONNEES\emeric\workspace_eclipse\.m2\repository\org\apache\maven\maven-plugin-api\2.0.6\maven-plugin-api-2.0.6.jar]
     [echo] maven-plugin-api
     [echo] maven-plugin-api
[INFO] Executed tasks

In src/main/resources I have a file test.properties :
{code:txt}
project.compileClasspathElements=${project.compileClasspathElements}
project.dependencies[0].artifactId=${project.dependencies[0].artifactId}
myVar=${myVar}
{code:txt}

I have result :
{code:txt}
project.compileClasspathElements=[D:\\DONNEES\\emeric\\workspace_eclipse\\generique-projet-js\\target\\classes]
project.dependencies[0].artifactId=${project.dependencies[0].artifactId}
myVar=${project.dependencies[0].artifactId}
{code:txt}

I think project.dependencies anly avaible in pom file.

If you see http://jira.codehaus.org/browse/PLXUTILS-37
I understand this properties only scope on pom not a all access properties.

Can you explain your use case ?
Why want this properties to understand this issue and 
https://jira.codehaus.org/browse/MRESOURCES-31

PS : I think MRESOURCES-31 Is duplicate of this issue.
                  
> ${project.dependencies[0].artifactId} is not expanded by resource filtering
> ---------------------------------------------------------------------------
>
>                 Key: MRESOURCES-118
>                 URL: https://jira.codehaus.org/browse/MRESOURCES-118
>             Project: Maven 2.x Resources Plugin
>          Issue Type: Bug
>          Components: interpolation
>    Affects Versions: 2.3, 2.4, 2.4.1
>         Environment: Maven 2.2.1, Ubuntu 9.10, Java 6u16 
>            Reporter: Pascal Thivent
>            Priority: Minor
>         Attachments: maven-resources-filtering-testcase.tar.bz2
>
>
> When filtering resources, ${project.dependencies[0].artifactId} is not 
> expanded (remains unchanged in the output file). 
> I've tried to define a property in my pom to workaround this issue:
> <properties>
>   <myartifact>${project.dependencies[0].artifactId}</myartifact>
> </properties>
> But, still, filtering the following file:
> {code:xml}
> <somenode>
>   <fileName>${project.dependencies[0].artifactId}</fileName>
>   <fileName>${myartifact}</fileName>
> </somenode>
> {code}
> Produces the following unexpected result:
> {code:xml}
> <somenode>
>   <fileName>${project.dependencies[0].artifactId}</fileName>
>   <fileName>${project.dependencies[0].artifactId}</fileName>
> </somenode>
> {code}
> The only working workaround I've found is to use the antrun plugin:
> {code:xml}
> <plugin>
>   <artifactId>maven-antrun-plugin</artifactId>
>   <executions>
>     <execution>
>       <phase>process-resources</phase>
>       <configuration>
>         <tasks>
>           <echo>${project.dependencies[0].artifactId}</echo>
>           <echo>${artifactId}</echo>
>           <replace file="${project.build.outputDirectory}/my.xml" token="@@@" 
> value="${project.dependencies[0].artifactId}"/> 
>         </tasks>
>       </configuration>
>       <goals>
>         <goal>run</goal>
>       </goals>
>     </execution>
>   </executions>
> </plugin>
> {code}
> I didn't test all cases but this problem may affect all "indexed" properties 
> (as defined in PLXUTILS-37).
> I'm attaching a sample project demonstrating this problem.

--
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

Reply via email to