Mariano Benitez wrote:

another thing, I did the <typedef> thing because I cannot add classpath to an antlib definition, so the problems are chained....

I hope to get this in for ant 1.6.2.


If I would define antlibs with classpath references directly it would be better....

You would still face the problem.
The antlib: namespace automatic loading of tasks/types is only triggered if a task or type from
the namespace is used.


for example if you have a master.xml file:

<project name="master" default="dosubprojects">
  <target name="dosubprojects">
     <subant target="">
        <fileset dir="." includes="**/build.xml"/>
     </subant>
  </target>
</project>

and each of the projects had:
<project xmlns:cpp="antlib:net.sf.antcontrib.cpptasks" default="compile">
 <cpp:compiler id="compiler.flags">
  ...
</project>

Each of the subprojects would trigger the task defs for the cpptasks namespace.

The way to work around this would be to do:
<project name="master" default="dosubprojects" 
xmlns:cpp="antlib:net.sf.antcontrib.cpptasks">
  <cpp:compiler id="dummy.flags"/>
  <target name="dosubprojects">
     <subant target="">
        <fileset dir="." includes="**/build.xml"/>
     </subant>
  </target>
</project>

Peter




MAriano

Mariano Benitez wrote:

but ... If I call "typedef" for the same file, with the same task, same uri, etc, why it redefine the tasks if they are already defined?

BTW, it could help an "unless" attribute for typedef, not to do it again :)
<typedef resource="fuego/internal/test/ant/antlib.xml" uri="antlib:fuego.internal.test.ant" loaderRef="fuego.internal.test" classpathref="fuego.internal.test.antlibs.path" unless="defined"/>
<property name="defined" value="true"/>


MAriano

Peter Reilly wrote:

Hi Mariano,
I assume you are calling the "typedef" commands multiple times.
- hence the different antloaders. But you only need to typedef
the types/tasks once.

You should wrap the taskdefs in a macrodef or a target,
and call them once in the master build file before doing
any subant, or ant calls.

Peter

Mariano Benitez wrote:

I am at the edge of a mental crisis, I need help....


Can someone explain how antlib paths and tasks works, I have this situation that I cannot understand.



I defined this:

<project name="fuego.internal.test.include" basedir=".">

<property name="xml.encoding" value="ISO-8859-1"/>
<path id="fuego.internal.test.antlibs.path">
<fileset dir="${fuego.basedir}/lib">
<include name="fuegoexpress-antlib.jar"/>
<include name="fuegoenterprise-antlib.jar"/>
<include name="fuegoj2ee-antlib.jar"/>
<include name="fuego-test-antlib.jar"/>
</fileset>
</path>
<typedef resource="fuego/internal/test/ant/antlib.xml" uri="antlib:fuego.internal.test.ant" loaderRef="fuego.internal.test" classpathref="fuego.internal.test.antlibs.path"/>
<typedef resource="fuego/tools/ant/enterprise/antlib.xml" uri="antlib:fuego.tools.ant.enterprise" loaderRef="fuego.internal.test" classpathref="fuego.internal.test.antlibs.path"/>
<typedef resource="fuego/tools/ant/express/antlib.xml" uri="antlib:fuego.tools.ant.express" loaderRef="fuego.internal.test" classpathref="fuego.internal.test.antlibs.path"/>
<typedef resource="fuego/tools/ant/j2ee/antlib.xml" uri="antlib:fuego.tools.ant.j2ee" loaderRef="fuego.internal.test" classpathref="fuego.internal.test.antlibs.path"/>
</project>


another Jar "fuegocore.jar" is in the classpath manifest of those jars, inside the fuegocore jar there is a clas "Loader".

When I am executing one of the tasks in the antlib I do this.

Inside an Utils.class static method:
task.log("[LOADERS] Loader Class [" + Loader.class.hashCode() + "/" + Loader.class.getClassLoader() + "]");
task.log("[LOADERS] Utils Class [" + Utils.class.hashCode() + "/" + Utils.class.getClassLoader() + "]");


and this is the result I get when I run this multiple times in the same ant run.

[t:testsetup] [LOADERS] Loader Class [6597453/[EMAIL PROTECTED]
[t:testsetup] [LOADERS] Utils Class [19551658/[EMAIL PROTECTED]


[t:testsetup] [LOADERS] Loader Class [6597453/[EMAIL PROTECTED]
[t:testsetup] [LOADERS] Utils Class [10520143/[EMAIL PROTECTED]


[t:testsetup] [LOADERS] Loader Class [6597453/[EMAIL PROTECTED]
[t:testsetup] [LOADERS] Utils Class [28623319/[EMAIL PROTECTED]




the thing is: WHY THE LOADER CLASS IS ALWAYS THE SAME WHILE THE UTILS CLASS IS ALWAYS IN DIFFERENT ANT CLASSLOADERS!!!

Also, If I put a static {} block in the Loader class it is invoked many times, not only one as it should, being the same class the one being returned.

Please help, I cannot understand what is causing this and the side-effect is that I get OutOfMemory errors when I run nightly batch tests.


Everything is appreciated.

MAriano

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to