Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven - How to perform conditional execution

Is there a way to perform conditional execution of snippet in pom.xml? my requirement is to copy a file/directory to deploy structure based on variable defined in pom.xml...

eg:

< if >
    < equals arg1="package" arg2="package"/>
       < then>
              ....
           < /then>
     < /if>

Not sure how can I achieve this!

Any pointers would be highly appreciated.

Thanks, SR

like image 494
user1450759 Avatar asked Jun 12 '12 09:06

user1450759


1 Answers

Probably you'll need to use Maven AntRun Plugin for that.

In general, there's no conditional expressions in POM. The only thing similar somehow to this are build profiles that can be activated on some specified conditions, however they probably don't fit into your current case.

And, at the end, my suggestion here. We don't know exactly what your case is about and don't even have any real code snippet, however from my experience it's really unusual to have to use such hackin' stuff in Maven. For me it smells like some problems with Maven understanding, project structure or stuff like that. I may be wrong and maybe your case really needs that, but consider other options to fit into Maven default approach and conventions instead.

like image 82
Michał Kalinowski Avatar answered Oct 13 '22 11:10

Michał Kalinowski