Hi Chad,
no JIRA needed :-) I managed to work my way through the
Velocity-invocation ... I attached a patch which contains
the necessary changes in Cartridge.java and VelocityTemplateEngine.java.
It worked for me - please have a look at it and patch it in if you
agree - I don't have CVS write access.
Also I'm not shure where this feature should be documented, since it's
a property which applies to all cartridges (as far as I see it's the
first of these species).
Matthias
On Sun, 2004-08-22 at 17:29, Chad Brandon wrote:
> Good idea Matthias, like Wouter said. we have been discussing this, I do
> like the idea of defining a directory where it can decide to use those
> templates instead.
> of having to rejar the entire cartridge. If you can add an issue to jira:
> http://team.andromda.org:8080/jira so that we can keep track of this, that
> would be great. Put it under the CORE project.
>
> Thanks!
>
> Chad
>
> ----- Original Message -----
> From: "Matthias K�spert" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, August 22, 2004 10:25 AM
> Subject: [Andromda-user] Overriding cartridge resources
>
>
> > Hi everybody,
> >
> > First: thanks for this great tool!!
> >
> > Second: my question:
> >
> > Is there any other way to override cartridge-resources than copying
> > the whole cartridge code?
> >
> > In case I would like to change the content of only one or two templates,
> > pictures, etc., copying the hole cartridge seems a lot of overhead.
> >
> > I my eyes it seems very useful if there would be a way to provide custom
> > templates/resources to a cartridge, like:
> >
> > 1. the user defines a merge-property i.e.:
> > <merge>src/merge/cartridge-xxx</merge>
> > for the cartridge (in the users project.xml)
> >
> > 2. the cartridge checks this property at runtime and eventually loads
> > the user-defined resource from the given merge directory instead
> > of the default one in the cartridge-jar.
> >
> > This way a cartridge can be configured to produce project-specific
> > output.
> >
> > I looked at the sources and got the impression that it may not be
> > too difficult to implement - if somebody could spot the point
> > where the template-resource is loaded ... I didn't in time :-)
> >
> > Any comments?
> >
> >
> > Matthias
> >
> >
> >
> >
> >
> > -------------------------------------------------------
> > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
> > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
> > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
> > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
> > _______________________________________________
> > Andromda-user mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/andromda-user
> >
>
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
> 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
> Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
> http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
> _______________________________________________
> Andromda-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/andromda-user
>
Index: andromda/src/java/org/andromda/core/cartridge/Cartridge.java
===================================================================
RCS file: /cvsroot/andromda/andromda/src/java/org/andromda/core/cartridge/Cartridge.java,v
retrieving revision 1.33
diff -r1.33 Cartridge.java
357a358,366
> // put the merge-property into the context
> //
> Property mergeProperty = Namespaces.instance()
> .findNamespaceProperty(this.getName(),
> "merge",
> false);
> String mergeDir = mergeProperty != null ? mergeProperty.getValue() : "";
> templateContext.put("merge", mergeDir);
>
628c637
< }
\ No newline at end of file
---
> }
Index: templateengines/velocity/src/java/org/andromda/templateengines/velocity/VelocityTemplateEngine.java
===================================================================
RCS file: /cvsroot/andromda/templateengines/velocity/src/java/org/andromda/templateengines/velocity/VelocityTemplateEngine.java,v
retrieving revision 1.10
diff -r1.10 VelocityTemplateEngine.java
96c96,97
< "andromda.plugins,file");
---
> "file, andromda.plugins");
> // not: "andromda.plugins,file"); - so files will override jar'ed resources
100a102,105
> ep.setProperty("file.resource.loader.class",
> "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
>
>
207a213,219
> // eventually add the merge-property to the engine
> //
> if (null != velocityContext.get("merge"))
> {
> velocityEngine.addProperty("file.resource.loader.path", (String) (velocityContext.get("merge")));
> }
>
354c366
< }
\ No newline at end of file
---
> }