views:

124

answers:

3

Hello. I created several web applications that use the same static files (css, js, images). When I use svn for version control, I use an external repository (svn: externals) to add files to the current project. For example:

- Project_1 
---- Webapp 
-------- Static (external to static's repo) 
- Project_2 
---- Webapp 
-------- Static (external to static's repo)

I could easily use it in their web pages by adding a link like /static/ ...

But now our company has moved to perforce. How can I support the current structure?

We also use maven, I think to pack these files as a jar and use as a dependency, but then my editor (idea) does not see that this dependence are js-scripts and styles. And i need to repackage and deploy jar file when create minor changes.

How to use maven correctly?

+2  A: 

For a Maven based solution, you could use WAR Overlays, sharing common resources across multiple web applications is exactly what overlays are for.

Pascal Thivent
I'm sorry - I saw perforce, I saw overlay, and assumed you were talking about Perforce overlays - I really should have followed your link. I could delete my comments, but that would leave a your comments looking out of place...
Douglas Leeder
I've posted my own answer to cover both kinds of overlays :-).
Douglas Leeder
I decided to use war overlays. But there one trouble for me. Is it possible to create and deploy war file from working dir, that created by maven for overlay? I need it, because i not only use, but also edit files. And i need to sync this sources between apps. I need to package it and deploy to artifactory.
Chupa
+3  A: 

Perforce has support for defining multiple mappings from the depot to your hard drive as part of the client spec. You could, for example, set the following:

Client Name: Sample_Maven
Client Root: c:\inetpub\wwwroot

//depot/Project_1/Webapp/... //Sample_Maven/Project_1/...
//depot/Project_2/Webapp/... //Sample_Maven/Project_2/...
//depot/Shared/static/... //Sample_Maven/static/...
... any other folder mappings you need to bring in and sync ...

Perforce won't handle multiple mapping of the shared static folder situation by itself, you will have to use junctions/symlinks in your file system to get the behavior you want. A word of caution though, make sure only one of the shared static folders is actually managed through Perforce. It can get slightly grumpy if resources get changed out from under it without it knowing about the changes.

Really though, you are probably better off (if you can) - having a single workspace/client spec per project - one for proj1 and one for proj2, each with their own mappings to the shared static folder. If you can structure things appropriately and just use maven to build each "project" things will go more smoothly.

Goyuix
It has one trouble. Perforce allow to map some folder one time per workspace.
Chupa
A: 

It seems you have a couple of choices, both called overlays:

a) Maven overlays as @Pascal suggests. Then you a struction like @Goyuix suggests to checkout the static content from Perforce.

b) Perforce overlays, which would allow you to have two different workspaces/client specs, one for each project, and in each import the static content into the expected place in the filesystem. This is the closest match to the subversion structure you were using before.

Douglas Leeder