Re: [FMPP] How to include java code into freemarker's data model in fmpp?
Brought to you by:
ddekany
From: alebu <al...@gm...> - 2010-01-09 12:45:51
|
Well, I tried to specify maven classpath and it looks like maven classpath includes my custom code, but FMPP still can not see it. While running maven build, ant-run prints it classpath and classes I need to have in FMPP are included. But Freemarker instance used by FMPP can't see them. I used Freemarker's new() modifier to create an object, like: <#assign AA="my.functionObject.full.ClassName"?new()> and got build error like: [fmpp] Task aborted: FMPP processing session failed. [fmpp] Caused by: freemarker.template.TemplateException: java.lang.ClassNotFoundException: my.functionObject.full.ClassName [fmpp] Caused by: java.lang.ClassNotFoundException: my.functionObject.full.ClassName In general, I wanted to add some custom complex logic into template environment. This time only as custom freemarker function, but if this strategy will work, then more logic will be possible to add. Constructing that object in beanshell also failed with ClassNotFoundException. It seems that FMPP freemarker instance classpath is not the same as is passed to FMPP itself, or Maven ant-run-plugin does not passes correct classpath. Is there any chances that such a behaviour will be fixed in the nearest furure? For those who interested, here is my configuration of maven ant run: <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <phase>prepare-package</phase> <configuration> <tasks> <property name="compile_classpath" refid="maven.compile.classpath"/> <echo message="compile classpath: ${compile_classpath}"/> <taskdef name="fmpp" classname="fmpp.tools.AntTask" classpathref="maven.compile.classpath" /> <fmpp sourceRoot="src/main/resources/fmpp" outputRoot="${project.build.directory}/fmpp-output"> <data> doc:xml(data/TRUTH.xml, {namespaceAware:false}) </data> <modes> ignore(**/*.bsh) ignore(data/**/*) execute(templates/MAIN.txt.ftl) </modes> </fmpp> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>net.sourceforge.fmpp</groupId> <artifactId>fmpp</artifactId> <version>0.9.14</version> </dependency> </dependencies> </plugin> </plugins> </build> On Tue, Jan 5, 2010 at 3:22 PM, alebu <al...@gm...> wrote: > Defininion of custom ant tasks in maven-ant-run plugin is described > here: http://maven.apache.org/plugins/maven-antrun-plugin/examples/customTasks.html > In general, configuration looks like <taskdef name="myTask" > classname="com.acme.MyTask" classpathref="maven.plugin.classpath"/> > This 'maven.plugin.classpath' is defined by maven and is plugin > classpath. Perhaps I need to play with it to get what I want. At least > it worth to try. Thanks for hint! > > > On Tue, Jan 5, 2010 at 3:11 PM, Daniel Dekany <dd...@fr...> wrote: >> Tuesday, January 5, 2010, 12:06:59 PM, alebu wrote: >> >>> I think that under Ant. Maven-ant-run plugin allows to pass maven >>> classpath to Ant. At least that is stated in documentation. But I >>> can't find how to specify any class path to FMPP it self from ant. And >>> that is the problem. >> >> How did you define the fmpp task? Because it wouldn't work unless you >> have put it into the "Ant classpath" somehow. Can't you add your >> classes to the "Ant classpath" one the same way? (The Ant "taskdef" >> element has optional "classpath" and "classpathref" attributes, also I >> believe it supports nested "classpath" element too.) >> >>> I am thinking about possible maven FMPP plugin >>> but first I need to find some free time for it :( >> >>> On Tue, Jan 5, 2010 at 12:42 PM, Daniel Dekany <dd...@fr...> wrote: >>>> Tuesday, January 5, 2010, 9:47:26 AM, alebu wrote: >>>> >>>>> Thanks, I found this one be seeking discussion. Unfortunately, I am >>>>> not sure is it helpful, because I am running FMPP from Ant (actually >>>>> from maven using maven-ant-run plugin). >>>> >>>> This issue might not be FMPP-specific. Sounds like it's just about >>>> setting up the "class path" under Maven (or maybe under Ant). >>>> >>>>> So, I can't manipulate >>>>> classpath of fmpp, because I even have no installation of it, FMPP >>>>> code comes from maven repository. During the week, I will try to play >>>>> with it (now I am at work and have no access to code where I want to >>>>> apply such approach. In success I will write in this discussion. >>>>> >>>>> On Tue, Jan 5, 2010 at 10:41 AM, Daniel Dekany <dd...@fr...> wrote: >>>>>> Monday, January 4, 2010, 11:31:27 PM, Daniel Dekany wrote: >>>>>> >>>>>>> Monday, January 4, 2010, 9:20:18 PM, alebu wrote: >>>>>>> >>>>>>>> Hi all, >>>>>>>> How can I specify FMPP to include some compiled java code or jar files >>>>>>>> in the freemarker classpath? I need it because I want to use some of >>>>>>>> the functions written with java from freemarker templates and because >>>>>>>> FMPP instanciates freemarker instance, I can't affect a classpath it >>>>>>>> passes to it. >>>>>>> >>>>>>> This may helps: >>>>>>> http://thread.gmane.org/gmane.comp.text.fmpp/133/focus=138 >>>>>> >>>>>> Sorry, I mean this: >>>>>> http://article.gmane.org/gmane.comp.text.fmpp/135 >>>>>> >>>>>> >>>>>> -- >>>>>> Best regards, >>>>>> Daniel Dekany >>>>>> >>>>>> >>>>>> ------------------------------------------------------------------------------ >>>>>> This SF.Net email is sponsored by the Verizon Developer Community >>>>>> Take advantage of Verizon's best-in-class app development support >>>>>> A streamlined, 14 day to market process makes app distribution fast and easy >>>>>> Join now and get one step closer to millions of Verizon customers >>>>>> http://p.sf.net/sfu/verizon-dev2dev >>>>>> _______________________________________________ >>>>>> fmpp-open mailing list >>>>>> fmp...@li... >>>>>> https://lists.sourceforge.net/lists/listinfo/fmpp-open >>>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> This SF.Net email is sponsored by the Verizon Developer Community >>>>> Take advantage of Verizon's best-in-class app development support >>>>> A streamlined, 14 day to market process makes app distribution fast and easy >>>>> Join now and get one step closer to millions of Verizon customers >>>>> http://p.sf.net/sfu/verizon-dev2dev >>>>> _______________________________________________ >>>>> fmpp-open mailing list >>>>> fmp...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/fmpp-open >>>>> >>>> >>>> -- >>>> Best regards, >>>> Daniel Dekany >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> This SF.Net email is sponsored by the Verizon Developer Community >>>> Take advantage of Verizon's best-in-class app development support >>>> A streamlined, 14 day to market process makes app distribution fast and easy >>>> Join now and get one step closer to millions of Verizon customers >>>> http://p.sf.net/sfu/verizon-dev2dev >>>> _______________________________________________ >>>> fmpp-open mailing list >>>> fmp...@li... >>>> https://lists.sourceforge.net/lists/listinfo/fmpp-open >>>> >>> >>> ------------------------------------------------------------------------------ >>> This SF.Net email is sponsored by the Verizon Developer Community >>> Take advantage of Verizon's best-in-class app development support >>> A streamlined, 14 day to market process makes app distribution fast and easy >>> Join now and get one step closer to millions of Verizon customers >>> http://p.sf.net/sfu/verizon-dev2dev >>> _______________________________________________ >>> fmpp-open mailing list >>> fmp...@li... >>> https://lists.sourceforge.net/lists/listinfo/fmpp-open >>> >> >> -- >> Best regards, >> Daniel Dekany >> >> >> ------------------------------------------------------------------------------ >> This SF.Net email is sponsored by the Verizon Developer Community >> Take advantage of Verizon's best-in-class app development support >> A streamlined, 14 day to market process makes app distribution fast and easy >> Join now and get one step closer to millions of Verizon customers >> http://p.sf.net/sfu/verizon-dev2dev >> _______________________________________________ >> fmpp-open mailing list >> fmp...@li... >> https://lists.sourceforge.net/lists/listinfo/fmpp-open >> > |