ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-ant/proposal/sandbox/embed ProjectHelperImpl2.java ant-sax2.jar build.xml
Date Sat, 13 Jul 2002 16:46:10 GMT
costin      2002/07/13 09:46:10

  Modified:    proposal/sandbox/embed ProjectHelperImpl2.java ant-sax2.jar
                        build.xml
  Log:
  Initial attempt to fix the optional.jar ( for 1.5+ ). The ProjectHelper
  will replace all optional tasks, using an AntClassLoader to load
  ( delegation disabled for the optional package ).
  
  Next step is to add a task that adds jars to the loader for optional.
  ( like junit.jar, etc ).
  
  Revision  Changes    Path
  1.4       +36 -0     jakarta-ant/proposal/sandbox/embed/ProjectHelperImpl2.java
  
  Index: ProjectHelperImpl2.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/embed/ProjectHelperImpl2.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ProjectHelperImpl2.java	17 May 2002 21:26:41 -0000	1.3
  +++ ProjectHelperImpl2.java	13 Jul 2002 16:46:10 -0000	1.4
  @@ -97,6 +97,39 @@
        */
       private static SAXParserFactory parserFactory = null;
   
  +    /** Will prepare the class loader to allow dynamic modifications
  +        of the classpath. Optional tasks are loaded in a different loader.
  +    */
  +    public void initClassLoader(Project project) {
  +        try {
  +            // reverse loader
  +            AntClassLoader acl=new AntClassLoader( this.getClass().getClassLoader(), true
);
  +            acl.addLoaderPackageRoot( "org.apache.tools.ant.taskdefs.optional");
  +
  +            // XXX find the classpath
  +            String antHome=project.getProperty( "ant.home" );
  +            File optionalJar=new File( antHome + "/lib/optional.jar" );
  +            System.out.println("Optional.jar = " +optionalJar.getAbsolutePath());
  +            acl.addPathElement(optionalJar.getAbsolutePath() );
  +            
  +            // reload all optional tasks in this loader.
  +            Hashtable tasks=project.getTaskDefinitions();
  +            Enumeration keys=tasks.keys();
  +            while( keys.hasMoreElements() ) {
  +                String n=(String)keys.nextElement();
  +                Class c=(Class)tasks.get(n);
  +                if( ! c.getName().startsWith( "org.apache.tools.ant.taskdefs.optional"
))
  +                    continue;
  +                // System.out.println("Reloading " + n + " " + c + " " + c.getClassLoader()
);
  +                c=acl.loadClass( c.getName() );
  +                tasks.put( n, c );
  +                // System.out.println("Loaded " + n + " " + c.getClassLoader() );
  +            }
  +        } catch( Exception ex ) {
  +            ex.printStackTrace();
  +        }
  +    }
  +    
       /**
        * Parses the project file, configuring the project as it goes.
        * 
  @@ -104,6 +137,9 @@
        *                           be read
        */
       public void parse(Project project, Object source) throws BuildException {
  +        // re-init class loader for optional.jar
  +        initClassLoader( project );
  +
           AntXmlContext context=new AntXmlContext();
           if(source instanceof File) {
               context.buildFile=(File)source;
  
  
  
  1.2       +150 -98   jakarta-ant/proposal/sandbox/embed/ant-sax2.jar
  
  	<<Binary file>>
  
  
  1.2       +6 -2      jakarta-ant/proposal/sandbox/embed/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/embed/build.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.xml	17 May 2002 23:12:51 -0000	1.1
  +++ build.xml	13 Jul 2002 16:46:10 -0000	1.2
  @@ -2,13 +2,15 @@
     <property name="ant.src" location="../../.." />
     <property name="ant.build" location="${ant.src}/build" />
     <property name="debug" value="true"/>
  -
  +    
     <target name="main">
  -    <copy file="ProjectHelperImpl2.java"  
  +    <copy id="test" file="ProjectHelperImpl2.java"  
             todir="${ant.src}/src/main/org/apache/tools/ant/helper" />
       <copy file="RuntimeConfigurable2.java"  
             todir="${ant.src}/src/main/org/apache/tools/ant" />
   
  +    <echo message="${toString:test}" />
  +
       <javac srcdir="${ant.src}/src"  
              debug="${debug}"
              destdir="${ant.build}/classes" >
  @@ -27,6 +29,8 @@
         <include name="org/apache/tools/ant/helper/ProjectHelperImpl2*" />
         <include name="org/apache/tools/ant/RuntimeConfigurable2*" />
       </jar>
  +
  +    <copy file="ant-sax2.jar" todir="${ant.home}/lib" />
     </target>
   
     <target name="clean">
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message