Hi everyone! I have some problems with a project I hope someone could help me to resolve them.
We are in the middle of a big refactor in a project where there are different approaches for the same logic. Each approach is supposed to include only the view layer of the application so they only contain Spring MVC controllers, tiles xml configuration and jsps. There is also a main web project with the login logic, filters and the other web stuff.
What we want to do is to create these approaches in a way they could be included or not in the final project (the main web project) as maven dependencies. The problem is we don't know how to define these modules so, when creating the final artifact, the webContent will be copied into the webContent of the web application. Also, there is another question. Should the java binaries for the controllers be copied with the other binaries of the web app or they should be inside a jar file as a dependency?Which should we use to create these modules, war or jar?
I've being reading about the assembly plugin but I don't know exactly how to use it to do this or if may be another option.
You can use maven war pluginto merge a war module into another module. I think the plugin cannot merge resource files like web.xml together. It just copies the files from one war module into another war module. So, what you can do is have one war module that contains your main web project with login etc. You can have a war module for each approach. Then at build time you can include the approaches that you want to bundle together. Maven will copy all the jps, classes, dependent jars from your approach module into the main module and package it as a war
This might work for you, but personally I wouldn't do it this way. I would just bundle all the approaches with the main war, and then use configuration to drive which approach is available for the user. Having parts of the webapps in differrent modules might be asking for trouble. For one, you might run into "Jar hell". Let's say approach1 uses hibernate 3.X and approach2 uses hibernate 4.x. Your final main war will contain both hibernate versions, and then you might run into a problem that code that works in the approach module suddenly doesn't work when you bundle them into the main module. If I do this, I would make sure I put something in place where everyone uses the same version of 3rd party libraries
Joined: Feb 24, 2010
Thank you! That was what I was looking for.
Thanks for the tip. In our case, these modules will be bundle all together at first because in the first release it's necessary. This is intended to avoid the inclusion of elements that won't be use in next releases. Each approach will only include the view layer and they won't have shared dependencies.
Another question I have is about development. We are using STS as our IDE with VMWare vFabric as server. This works fine when we want to create the artifact but, is there any way to instruct STS to deploy the project the same way in our development server?
The way most people do it is developers use the IDE to develop and deploy code to their local web server. When the developers are do e wi a particular change they check in the source into a change control repository, for example SVN. all the source code lives in the change control repo. Then, there is a CI server like Hudson that builds and runs the checked in source code on a nightly basis, and installs the code that it builds on the dev server.
The installation to the dev server is done via maven itself, or shell scripts, not through an IDE. IDE is a dev tool not an installation tool
Joined: Feb 24, 2010
I think I wasn't clear when I asked the question
What I meant was what I had to do to deploy to my development server embedded in my IDE, not to a final server. I asked it because in STS 2.9.2 it didn't work, it just deployed the files from the dependency war without extension to the deploy folder. I changed to STS 3.1 and know it works. I think there is a bug in that version, that's why I asked the question in the first place.
But thank you anyway!
subject: How to split a web project into different web modules with maven?