File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven, war dependencies, and moving files around Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Maven, war dependencies, and moving files around" Watch "Maven, war dependencies, and moving files around" New topic
Author

Maven, war dependencies, and moving files around

Damon Silver
Greenhorn

Joined: May 27, 2009
Posts: 4
I've got a common "stub" war that I don't intend to deploy, but which I intend to use as a dependency in one or more other deployable wars. I have files in the dependency in a directory foo/bar/ that I'd like to wind up in the deployable war under directory baz/ (relative to the base directory).

In maven 2.0.9, I'm able to get the dependency to overlay on the packaged war via:

However, the included files wind up in baz/foo/bar/ instead of baz/. Is there some way to do a war overlay using <targetPath> and strip the original directory path simultaneously? This seems like a common-enough problem that there's likely to be a widely available way to do it, but the solution escapes me.

Am I using the wrong plugin? I've also tried various combinations of maven-assembly-plugin and maven-dependency-plugin with no success thus far.

Many thanks in advance.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Damon and welcome to Javaranch!

I confess I'm a little confused by your use case. Are you saying that you've got a common (stub) WAR that your other WARs are dependent on? I assume in your deploy directory it looks like this:

<app server dir structure>/deploy/stub.war
<app server dir structure>/deploy/y_is_reliant_on_stub.war
<app server dir structure>/deploy/x_is_reliant_on_stub.war

Is that right?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Damon Silver
Greenhorn

Joined: May 27, 2009
Posts: 4
Martijn Verburg wrote:Hi Damon and welcome to Javaranch!

I confess I'm a little confused by your use case. Are you saying that you've got a common (stub) WAR that your other WARs are dependent on? I assume in your deploy directory it looks like this:

<app server dir structure>/deploy/stub.war
<app server dir structure>/deploy/y_is_reliant_on_stub.war
<app server dir structure>/deploy/x_is_reliant_on_stub.war

Is that right?


Not quite. I'd like to have stub.war be packaged already and available at compilation/packaging time when y_is_reliant_on_stub.war and x_is_reliant_on_stub.war are built, then deploy those two but not stub.war. Essentially, stub.war contains JSP's and JSP fragments that are common to several deployable wars. I need each of those wars to have the common bits available without having to deploy stub.war itself, since it won't work in absentia (it requires certain war-specific elements that are filled in by individual deployable wars). The pathing for the common JSP's must be allowed to vary from deployable war to deployable war depending on each war's needs.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Ah, I think I see. Well if you're never actually deploying stub.war, can you not just have 'copy' tasks (assembly plugin) to copy the JSP fragments etc into the WAR you are building? Or have the WAR you are building refer to an extra source section that references the stub/src/main/<code> area.
Damon Silver
Greenhorn

Joined: May 27, 2009
Posts: 4
Martijn Verburg wrote:Ah, I think I see. Well if you're never actually deploying stub.war, can you not just have 'copy' tasks (assembly plugin) to copy the JSP fragments etc into the WAR you are building? Or have the WAR you are building refer to an extra source section that references the stub/src/main/<code> area.


Yes, and I'm already able to accomplish that, i.e., I can wind up with baz/some.jsp in the deployable war, but I was hoping to avoid the additional baz/foo/bar/some.jsp, since that just leads to war bloat.
Damon Silver
Greenhorn

Joined: May 27, 2009
Posts: 4
I should mention also that the deployable wars are not being built as part of a multimodule setup, so it should be possible to package them in isolation (e.g., pull the stub.war out of the repository, use that as a dependency, package depends-on-stub.war).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Maven, war dependencies, and moving files around