开发者

Project organization in perforce

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?


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜