alebu | 4 Jan 21:20 2010
Picon

How to include java code into freemarker's data model in fmpp?

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 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 
Daniel Dekany | 4 Jan 23:31 2010
Picon

Re: How to include java code into freemarker's data model in fmpp?

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

--

-- 
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 
Daniel Dekany | 5 Jan 09:41 2010
Picon

Re: How to include java code into freemarker's data model in fmpp?

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 
alebu | 5 Jan 09:47 2010
Picon

Re: How to include java code into freemarker's data model in fmpp?

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). 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 <ddekany <at> freemail.hu> 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
(Continue reading)

Daniel Dekany | 5 Jan 11:42 2010
Picon

Re: How to include java code into freemarker's data model in fmpp?

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 <ddekany <at> freemail.hu> 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
>>
(Continue reading)

alebu | 5 Jan 12:06 2010
Picon

Re: How to include java code into freemarker's data model in fmpp?

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. 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 <ddekany <at> freemail.hu> 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 <ddekany <at> freemail.hu> 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
(Continue reading)

Daniel Dekany | 5 Jan 14:11 2010
Picon

Re: How to include java code into freemarker's data model in fmpp?

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 <ddekany <at> freemail.hu> 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
(Continue reading)

alebu | 5 Jan 14:22 2010
Picon

Re: How to include java code into freemarker's data model in fmpp?

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 <ddekany <at> freemail.hu> 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 <ddekany <at> freemail.hu> 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
(Continue reading)

alebu | 9 Jan 13:38 2010
Picon

Re: How to include java code into freemarker's data model in fmpp?

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>
(Continue reading)


Gmane