You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Matt Koss <m....@open.ac.uk> on 2002/05/27 11:46:38 UTC

Texen templatePath problem

Problem :
templatePath doesn't get correctly set when calling the same task twice with 
different arguments. Tthe first task sets the templatePath but the second 
task uses the templatePath from the first one instead of the specified one.

This results in the first task being successful, but the second fails ( it 
doesn't matter if I change the order of them).

I guess I could use the same templatePath and then use relative paths, but it 
is not a real solution.

This is a snip of the build.xml :

<target name="generate" depends="prepare">

    <!-- declare custom tasks -->
    <taskdef name="generator" classname="edu.ou.kmi.artemis.Generator">
      <classpath>
	<fileset dir="lib">
	  <include name="**/*.jar"/>
	</fileset>
      </classpath>
    </taskdef>

    <!-- run the generation of sql -->
    <generator ontologyName="${ontology.name}"
	       controlTemplate="control.vm"
	       templatePath="${template.path}/sql"
	       outputDirectory="${dist.config}"
	       outputFile="database.sql.in"/>

    <!-- run the generation of jsp -->
    <generator ontologyName="${ontology.name}"
	       controlTemplate="control.vm"
	       templatePath="${template.path}/jsp/layouts/${layout.name}"
	       outputDirectory="${dist.web}"
	       outputFile="report.generation"/>

</target>


Cheers

Matt

-- 
Matt Koss
Knowledge Media Institute
Open University
e-mail: m.koss@open.ac.uk

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Texen templatePath problem

Posted by Matt Koss <m....@open.ac.uk>.
> >
> > I am using ant 1.5 beta1
>
> That qualifies as 'later' :)

:-)

>
> > I have followed the torque source code and it doesn't seem to call
> > Velocity.init() at all.
> > Only thing it does is implement initControlContext() which I am doing as
> > well.
>
> It has to somewhere.

As I looked at the source code of TexenTask, the method execute calls 
Velocity.init().
I am just not doing it it explicitly anywhere in my class Generator that 
extends TexenTask.

>
> > template.path property is set in my build file at the beginning and I use
> > it as a value for the templatePath attribute.
> >
> > My Generator class only implements initControlContext() and few more
> > get/set methods for some attributes. I don't handle there standard
> > attributes like outputFile, outputDirectory, templatePath etc. I
> > understand that this is done by texen.
> >
> > When I run those two tasks, the initControlContext() method is called
> > once for each task, but the templatePath attribute seem to be passed from
> > the first task.
> > I have to specify it, because otherwise I get an error message, but the
> > value is completely ignored ( that is the value from the first task is
> > used ), no matter what I put there.
>
> I think it's getting passed into Generator
>
> Have you tried the switch I suggested?
>

I have tried it, but with a same result.
Bu I also get some message about reverseloader being deprecated, so I don't 
know if it is actually applied or not.


-- 
Matt Koss
Knowledge Media Institute
Open University
e-mail: m.koss@open.ac.uk

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Texen templatePath problem

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 5/27/02 8:39 AM, "Matt Koss" <m....@open.ac.uk> wrote:

> On Monday 27 May 2002 1:00 pm, Geir Magnusson Jr. wrote:
>> On 5/27/02 5:46 AM, "Matt Koss" <m....@open.ac.uk> wrote:
>>> Problem :
>>> templatePath doesn't get correctly set when calling the same task twice
>>> with different arguments. Tthe first task sets the templatePath but the
>>> second task uses the templatePath from the first one instead of the
>>> specified one.
>>> 
>>> This results in the first task being successful, but the second fails (
>>> it doesn't matter if I change the order of them).
>> 
>> This is in ant?  1.4 or later?  And does your generator task set the
>> template path before calling Velocity.init()?
> 
> I am using ant 1.5 beta1
> 

That qualifies as 'later' :)

> I have followed the torque source code and it doesn't seem to call
> Velocity.init() at all.
> Only thing it does is implement initControlContext() which I am doing as well.

It has to somewhere.
 
> template.path property is set in my build file at the beginning and I use it
> as a value for the templatePath attribute.
> 
> My Generator class only implements initControlContext() and few more get/set
> methods for some attributes. I don't handle there standard attributes like
> outputFile, outputDirectory, templatePath etc. I understand that this is done
> by texen.
> 
> When I run those two tasks, the initControlContext() method is called once for
> each task, but the templatePath attribute seem to be passed from the first
> task.
> I have to specify it, because otherwise I get an error message, but the value
> is completely ignored ( that is the value from the first task is used ), no
> matter what I put there.

I think it's getting passed into Generator

Have you tried the switch I suggested?

> 
> 
>> 
>> If the above is true, it may be due to how ant deals with classloaders now
>> in the 'new' ant.
>> 
>> To test the theory (not also this is 'pre morning coffee') try to add
>> 
>> 'reverseloader="true"'
>> 
>> In your taskdef, a la
>> 
>> <taskdef name="texen" classname="org.apache.velocity.texen.ant.TexenTask"
>>         reverseloader="true">
>> 
>> 
>> If this is what is going on, the reason is that ant in 1.4+ keeps the same
>> classsloader around for that task, so if you had set the path before
>> calling .init(), it remains set for the second usage....
>> 
>> Give it a try
>> 
>> Geir
>> 
>>> I guess I could use the same templatePath and then use relative paths,
>>> but it is not a real solution.
>>> 
>>> This is a snip of the build.xml :
>>> 
>>> <target name="generate" depends="prepare">
>>> 
>>>   <!-- declare custom tasks -->
>>>   <taskdef name="generator" classname="edu.ou.kmi.artemis.Generator">
>>> 
>>>     <classpath>
>>> <fileset dir="lib">
>>>  <include name="**/*.jar"/>
>>> </fileset>
>>>     </classpath>
>>>   </taskdef>
>>> 
>>>   <!-- run the generation of sql -->
>>>   <generator ontologyName="${ontology.name}"
>>>       controlTemplate="control.vm"
>>>       templatePath="${template.path}/sql"
>>>       outputDirectory="${dist.config}"
>>>       outputFile="database.sql.in"/>
>>> 
>>>   <!-- run the generation of jsp -->
>>>   <generator ontologyName="${ontology.name}"
>>>       controlTemplate="control.vm"
>>>       templatePath="${template.path}/jsp/layouts/${layout.name}"
>>>       outputDirectory="${dist.web}"
>>>       outputFile="report.generation"/>
>>> 
>>> </target>
>>> 
>>> 
>>> Cheers
>>> 
>>> Matt

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Texen templatePath problem

Posted by Matt Koss <m....@open.ac.uk>.
On Monday 27 May 2002 1:00 pm, Geir Magnusson Jr. wrote:
> On 5/27/02 5:46 AM, "Matt Koss" <m....@open.ac.uk> wrote:
> > Problem :
> > templatePath doesn't get correctly set when calling the same task twice
> > with different arguments. Tthe first task sets the templatePath but the
> > second task uses the templatePath from the first one instead of the
> > specified one.
> >
> > This results in the first task being successful, but the second fails (
> > it doesn't matter if I change the order of them).
>
> This is in ant?  1.4 or later?  And does your generator task set the
> template path before calling Velocity.init()?

I am using ant 1.5 beta1

I have followed the torque source code and it doesn't seem to call 
Velocity.init() at all.
Only thing it does is implement initControlContext() which I am doing as well.

template.path property is set in my build file at the beginning and I use it 
as a value for the templatePath attribute.

My Generator class only implements initControlContext() and few more get/set 
methods for some attributes. I don't handle there standard attributes like 
outputFile, outputDirectory, templatePath etc. I understand that this is done 
by texen.

When I run those two tasks, the initControlContext() method is called once for 
each task, but the templatePath attribute seem to be passed from the first 
task.
I have to specify it, because otherwise I get an error message, but the value 
is completely ignored ( that is the value from the first task is used ), no 
matter what I put there.

Regards

Matt


>
> If the above is true, it may be due to how ant deals with classloaders now
> in the 'new' ant.
>
> To test the theory (not also this is 'pre morning coffee') try to add
>
> 'reverseloader="true"'
>
> In your taskdef, a la
>
> <taskdef name="texen" classname="org.apache.velocity.texen.ant.TexenTask"
>         reverseloader="true">
>
>
> If this is what is going on, the reason is that ant in 1.4+ keeps the same
> classsloader around for that task, so if you had set the path before
> calling .init(), it remains set for the second usage....
>
> Give it a try
>
> Geir
>
> > I guess I could use the same templatePath and then use relative paths,
> > but it is not a real solution.
> >
> > This is a snip of the build.xml :
> >
> > <target name="generate" depends="prepare">
> >
> >   <!-- declare custom tasks -->
> >   <taskdef name="generator" classname="edu.ou.kmi.artemis.Generator">
> >
> >     <classpath>
> > <fileset dir="lib">
> >  <include name="**/*.jar"/>
> > </fileset>
> >     </classpath>
> >   </taskdef>
> >
> >   <!-- run the generation of sql -->
> >   <generator ontologyName="${ontology.name}"
> >       controlTemplate="control.vm"
> >       templatePath="${template.path}/sql"
> >       outputDirectory="${dist.config}"
> >       outputFile="database.sql.in"/>
> >
> >   <!-- run the generation of jsp -->
> >   <generator ontologyName="${ontology.name}"
> >       controlTemplate="control.vm"
> >       templatePath="${template.path}/jsp/layouts/${layout.name}"
> >       outputDirectory="${dist.web}"
> >       outputFile="report.generation"/>
> >
> > </target>
> >
> >
> > Cheers
> >
> > Matt

-- 
Matt Koss
Knowledge Media Institute
Open University
e-mail: m.koss@open.ac.uk

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Texen templatePath problem

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 5/27/02 5:46 AM, "Matt Koss" <m....@open.ac.uk> wrote:

> 
> Problem :
> templatePath doesn't get correctly set when calling the same task twice with
> different arguments. Tthe first task sets the templatePath but the second
> task uses the templatePath from the first one instead of the specified one.
> 
> This results in the first task being successful, but the second fails ( it
> doesn't matter if I change the order of them).

This is in ant?  1.4 or later?  And does your generator task set the
template path before calling Velocity.init()?

If the above is true, it may be due to how ant deals with classloaders now
in the 'new' ant.

To test the theory (not also this is 'pre morning coffee') try to add

'reverseloader="true"'

In your taskdef, a la

<taskdef name="texen" classname="org.apache.velocity.texen.ant.TexenTask"
        reverseloader="true">


If this is what is going on, the reason is that ant in 1.4+ keeps the same
classsloader around for that task, so if you had set the path before calling
.init(), it remains set for the second usage....

Give it a try

Geir

 
> I guess I could use the same templatePath and then use relative paths, but it
> is not a real solution.
> 
> This is a snip of the build.xml :
> 
> <target name="generate" depends="prepare">
> 
>   <!-- declare custom tasks -->
>   <taskdef name="generator" classname="edu.ou.kmi.artemis.Generator">

>     <classpath>
> <fileset dir="lib">
>  <include name="**/*.jar"/>
> </fileset>
>     </classpath>
>   </taskdef>
> 
>   <!-- run the generation of sql -->
>   <generator ontologyName="${ontology.name}"
>       controlTemplate="control.vm"
>       templatePath="${template.path}/sql"
>       outputDirectory="${dist.config}"
>       outputFile="database.sql.in"/>
> 
>   <!-- run the generation of jsp -->
>   <generator ontologyName="${ontology.name}"
>       controlTemplate="control.vm"
>       templatePath="${template.path}/jsp/layouts/${layout.name}"
>       outputDirectory="${dist.web}"
>       outputFile="report.generation"/>
> 
> </target>
> 
> 
> Cheers
> 
> Matt

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>