How to react on file in path with property in maven?
I want to use some plugin executions of my maven project only when a certain file does not exist. The path to this file can change - that's why it must contain a property (and please correct me if that's not the case). A good way would be to use profile activation with the file, but because the path has a property this doesn't work (as stated in the Maven 'Introduction to build profiles').
That said, the question is: Do you know a way to achieve the desired behav开发者_开发问答iour only with one pom?
Of course the enforcer plugin offers a limited way of reacting on files but I don't want to necessarily fail or interrupt the build.
There's not really much you can do. Here are your options:
Live with the restrictions. The only way you can configure the file path is through a system property (user properties are evaluated using profiles, not the other way around):
<profile> <id>foobar</id> <activation> <file><exists>${file.path}</exists></file> </activation> </profile> mvn -Dfile.path=some/path/file.txt clean install
Invoke the executions programmatically, e.g with the Maven Invoker. Either
- write a custom plugin or
- write a main class and call it from Exec:Java or
- use an inline Groovy Script with GMaven
Either one of the above options will have to behave as a dispatcher that invokes mojos using the invoker depending on evaluation of properties.
精彩评论