Reputation: 352
I'm modifying some maven3 plugin and I just need to filter with file using some properties already defined in the pom starting the whole process.
I haven't found much doc/examples on the topic and all my attempts failed.
First one :
/**
* @component
* @required
* @readonly
*/
private MavenFileFilter mavenFileFilter;
and then in my code :
mavenFileFilter.copyFile(tempFile, resultingFile, true, getProject(), Collections.<String> emptyList(), true, "utf-8", session);
However nothing happens : the replacement isn't done.
Then I saw various examples evolving around
MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution(resources, outputDirectory, getProject(), "utf-8", null, nonFilteredFileExtensions, session);
However I don't get how to put in there the file I want... Resource has no constructor with actual content...
Any help welcome!
Best
EDIT (more context) : The context is the following : we built a web app deployed at many customers' servers.
On one hand, the folder hierarchy depends from customer to customer.
On the other hand, we have some default logback.xml config file, which needs to be filtered (to use the correct folder hierarchy of the given customer server). This file sits in some common project. We would also like to be able to specialize this logback.xml, when we wish so, on a per customer basis. We've put these files in the source folders of the respective common project/customer project.
As such, the plugin doing the packaging now looks into each artifact, by order of dependencies, and pick up the first logback.xml and put it where needed. It also needs to do the filtering to put the right folders.
It all works apart the last bit...
Does it make sense ? Any better way ?
Thanks again
Upvotes: 2
Views: 209
Reputation: 97427
I would suggest to take a look at this:
<project>
...
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/extra-resources</outputDirectory>
<resources>
<resource>
<directory>src/non-packaged-resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
...
</build>
...
</project>
Why do you need to implement a plugin which only copies resources within an other life cyclce phase.
Upvotes: 2