lattes and cappuccinos

hello all! been some time since i’ve last posted something eh? well, was busy exploring meteor and coffeescript for a while. and now came back to java with maven. (love how everywhere i find  coffee related terms.) 😋

since i’ve gotten in touch with maven again, i needed to work with profiling. what is profiling? well..

we need profiling because, when we build softwares, we might need to build the same application in different formats. simple example, a portal for developers and another portal for users. and these two aspects may use the same interfaces to interact with the application, all the while using different resources to back the application to deliver what they see.

basically, the developers see the technical and more deeper elements of the software, or even administrative aspects whilst the normal users won’t be bothered by the technical mumbo jumbo. 😎

so why not have one portal with all the elements, dependencies and add limitations using the user access levels? well, there will be elements which will be used commonly by both. but sometimes, some dependencies, packages won’t be needed for the functions of each party. or say you’re building a product that can be sold to multiple parties and you want each version to have look of it’s own to match the customer. these can be achieved by profiling as it’ll preserve the common aspects and will aid you in specifying what needs to be there.

to read more on profiling with maven, you can visit introduction to profiles on

well here, i shall explain how to include your own images, css files in a .war build of a project. because i found this to be a bit confusing and this accompanies maven war plugin. because even you do the profiling right, packaging has to be specified separately to get the expected outcome of a project.

so right now, i have build a webapp using maven. and the folder structure will look as follows.

├── main
│   ├── java
│   │   └── ..
│   │
│   ├── profile
│   │   │
│   │   └── webapp
│   │       │
│   │       ├── user
│   │       │   ├── css
│   │       │   │   └── custom.css
│   │       │   └── images
│   │       │       └── header.jpg
│   │       └── dev
│   │           ├── css
│   │           │   └── custom.css
│   │           └── images
│   │               └── header.jpg
│   │
│   ├── resources
│   │   └── ..
│   │
│   └── webapp
│       ├── css
│       │    └── custom.css
│       │
│       ├── images
│       │    └── header.jpg
│       │
│       ├── WEB-INF
│       │    └── ..
│       │
│       └── index.jsp
└── test
    └── ..

see the directory profile, by now, you may know this contains the content for each of the profiles. here we have two profiles, dev and user with their own css and header image file. our target is to overwrite the content in the webapp directory (in the main structure) and package the right content according to the profile selected.

to define the profiles, we have to have the following code in our pom file.


we have defined our two profiles, also we have set properties with the same name so we can use them later. this makes our life easier. 😉

now if you package this using maven, it’ll compile and package. but you will still find the default css and the header image. this is where we’ll need the maven war plugin.


now you see where the previous property comes into play, now when we package this, and when we specify the profile, it’ll look for the specific profile property and get the data accordingly for packaging. the packaging won’t have the rest of the unnecessary files clogging it. also, we have added <includeEmptyDirectories>true</includeEmptyDirectories> to have any empty folders that we might need in the packaging later. this will reduce any complications and do try to match the exact folder structure of the files/directories you’re trying to manipulate using profiling and have them that way in the profile directory. you can see the folder structure here and understand how it looks like.

mvn clean install -P dev


mvn clean install -P user

now will give the expected outcome with the correct css and images in the directories, overwriting the defaults. 👍

alrighty? cool. so, i’ll be off for today, got more exploring todo. until next time! ☕


spill a bit of coffee?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s