File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Maven, war dependencies, and moving files around

 
Damon Silver
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Damon Silver
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic