It’s possible that many of you already knew this but if not then here’ some basic info on Maven profiles. I have been using maven for over 2 and half years now, and have been copy pasting assembly and install files. I never bothered to know how Maven figures out how to read assembly and install file names. For example-
PROBLEM:
For all my projects I have been using assembly-jboss.xml to put the file/directory information and telling maven about my desired directory structure i.e. Pick files from a/b directory and put it in out directory c/d. The second file install-jboss.xml where I specify my panels, target files etc. It never occurred to me what happens if I change the file names to assembly-zzz.xml and intsall-zzz.xml.
Well to cut the story short I checked out a fellow developer code on my machine and the command
mvn clean install
threw build error which said -
[1] [INFO] Searching for file location: C:\Dinesh\workspace\prov-ld-anin-trunk\artifacts\src\assembly\assembly-jboss4.xml
[2] [INFO] File: C:\Dinesh\workspace\prov-ld-anin-trunk\artifacts\src\assembly\assembly-jboss4.xml does not exist.
[3] [INFO] File: C:\Dinesh\workspace\prov-ld-anin-trunk\src\assembly\assembly-jboss4.xml does not exist.
Now I was using IZPack plugin and always thought the assembly and install xmls are part of IZPack configuration, so for half an hour I was searching “IZPack assembly descriptor”. Needless to say I did not get any releveant search result. After scratching my head a little and doing a text search in Eclipse to figure out how am I telling maven to find the specific files (in my case the fellow developer had named them as assembly-wso2carbon40.xml and install-wso2carbon40.xml). No results.
SOLUTION:
In Maven you set up a profile in your .m2/settings.xml. For example my settings.xml looks like this
|
|
If you will notice I have specified that
So now the problem was that my developer friend had named the files as assembly-wso2Carbon40.xml and install-wso2Carbon40.xml. The first thing that came to my mind was let’s change the **
Here’s comes the neat part, you can have multiple profiles in your settings file. So I updated my .m2/settings.xml
|
|
Now when you build the project using Eclipse, just got to Run As ==> Maven Build … and enter Goals = clean install and Profile = wso2
That’s it!
~~Cheers!