ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/proposal/mutant/src/java/start/org/apache/ant/start Main.java
Date Wed, 03 Apr 2002 15:02:48 GMT
conor       02/04/03 07:02:48

  Modified:    proposal/mutant build.xml
               proposal/mutant/src/java/bootstrap/org/apache/ant/builder
                        MutantBuilder.java
               proposal/mutant/src/java/init/org/apache/ant/init
                        InitConfig.java
               proposal/mutant/src/java/start/org/apache/ant/start
                        Main.java
  Log:
  reorg of mutant's frontend
  
  Revision  Changes    Path
  1.17      +3 -3      jakarta-ant/proposal/mutant/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/build.xml,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -w -u -r1.16 -r1.17
  --- build.xml	25 Mar 2002 05:40:33 -0000	1.16
  +++ build.xml	3 Apr 2002 15:02:47 -0000	1.17
  @@ -77,14 +77,14 @@
   
     <target name="cli" depends="antcore, start">
       <mkdir dir="${bin.dir}/cli"/>
  -    <mkdir dir="${distlib.dir}/cli"/>
  +    <mkdir dir="${distlib.dir}/frontend"/>
       <depend destdir="${bin.dir}/cli" srcdir="${java.dir}/cli">
         <classpath refid="classpath.cli"/>
       </depend>
       <javac destdir="${bin.dir}/cli" srcdir="${java.dir}/cli" debug="${debug}">
         <classpath refid="classpath.cli"/>
       </javac>
  -    <jar basedir="${bin.dir}/cli" jarfile="${distlib.dir}/cli/cli.jar"/>
  +    <jar basedir="${bin.dir}/cli" jarfile="${distlib.dir}/frontend/cli.jar"/>
     </target>
   
     <target name="start" depends="init">
  @@ -199,7 +199,7 @@
       <mkdir dir="${javadocs.dir}"/>
       <javadoc packagenames="org.apache.*"
                useexternalfile="yes"
  -             sourcepath="${java.dir}/antcore:${java.dir}/init:${java.dir}/common:${java.dir}/cli:${java.dir}/start"
  +             sourcepath="${java.dir}/antcore:${java.dir}/init:${java.dir}/common:${java.dir}/frontend:${java.dir}/start"
                destdir="${javadocs.dir}"
                author="true" 
                private ="true"
  
  
  
  1.4       +2 -2      jakarta-ant/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/MutantBuilder.java
  
  Index: MutantBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/MutantBuilder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -u -r1.3 -r1.4
  --- MutantBuilder.java	6 Mar 2002 08:17:07 -0000	1.3
  +++ MutantBuilder.java	3 Apr 2002 15:02:47 -0000	1.4
  @@ -51,9 +51,9 @@
       }
       protected void cli(BuildHelper helper) {
           helper.mkdir("${bin.dir}/cli");
  -        helper.mkdir("${distlib.dir}/cli");
  +        helper.mkdir("${distlib.dir}/frontend");
           helper.javac("${java.dir}/cli", "${bin.dir}/cli", "classpath.cli");
  -        helper.jar("${bin.dir}/cli", "${distlib.dir}/cli/cli.jar",
  +        helper.jar("${bin.dir}/cli", "${distlib.dir}/frontend/cli.jar",
                      null, null);
       }
       protected void start(BuildHelper helper) {
  
  
  
  1.5       +79 -1     jakarta-ant/proposal/mutant/src/java/init/org/apache/ant/init/InitConfig.java
  
  Index: InitConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/init/org/apache/ant/init/InitConfig.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -u -r1.4 -r1.5
  --- InitConfig.java	18 Mar 2002 02:44:28 -0000	1.4
  +++ InitConfig.java	3 Apr 2002 15:02:47 -0000	1.5
  @@ -52,9 +52,11 @@
    * <http://www.apache.org/>.
    */
   package org.apache.ant.init;
  +import java.io.File;
   
  +import java.net.MalformedURLException;
   import java.net.URL;
  -import java.io.File;
  +import java.net.URLClassLoader;
   
   /**
    * InitConfig is the initialization configuration created to start Ant. This
  @@ -64,6 +66,10 @@
    * @created 9 January 2002
    */
   public class InitConfig {
  +
  +    /** The default name of the jar containing the XML parser */
  +    public static final String DEFAULT_PARSER_JAR = "crimson.jar";
  +
       /** The system classloader */
       private ClassLoader systemLoader;
   
  @@ -108,6 +114,59 @@
       private File userConfigArea;
   
       /**
  +     * XXX Constructor for the InitConfig object
  +     *
  +     * @exception InitException XXX Description of Exception
  +     */
  +    public InitConfig() throws InitException {
  +        try {
  +            URL antLibURL = getAntLibURL();
  +            setLibraryURL(antLibURL);
  +
  +            URL antHome = new URL(antLibURL, "..");
  +            setAntHome(antHome);
  +            if (antHome.getProtocol().equals("file")) {
  +                File systemConfigArea = new File(antHome.getFile(), "conf");
  +                setSystemConfigArea(systemConfigArea);
  +            }
  +            File userConfigArea
  +                 = new File(System.getProperty("user.home"), ".ant/conf");
  +            setUserConfigArea(userConfigArea);
  +
  +            // set up the class loaders that will be used when running Ant
  +            ClassLoader systemLoader = getClass().getClassLoader();
  +            setSystemLoader(systemLoader);
  +            URL toolsJarURL = ClassLocator.getToolsJarURL();
  +            setToolsJarURL(toolsJarURL);
  +
  +            URL commonJarLib = new URL(libraryURL, "common/");
  +            ClassLoader commonLoader
  +                 = new URLClassLoader(LoaderUtils.getLocationURLs(commonJarLib,
  +                "common.jar"), systemLoader);
  +            setCommonLoader(commonLoader);
  +
  +            // core needs XML parser for parsing various XML components.
  +            URL parserBase = new URL(libraryURL, "parser/");
  +            URL[] parserURLs
  +                 = LoaderUtils.getLocationURLs(parserBase, DEFAULT_PARSER_JAR);
  +            setParserURLs(parserURLs);
  +
  +            URL[] coreURLs
  +                 = LoaderUtils.getLocationURLs(new URL(libraryURL, "antcore/"),
  +                "antcore.jar");
  +            URL[] combinedURLs = new URL[parserURLs.length + coreURLs.length];
  +            System.arraycopy(coreURLs, 0, combinedURLs, 0, coreURLs.length);
  +            System.arraycopy(parserURLs, 0, combinedURLs, coreURLs.length,
  +                parserURLs.length);
  +            ClassLoader coreLoader = new URLClassLoader(combinedURLs,
  +                commonLoader);
  +            setCoreLoader(coreLoader);
  +        } catch (MalformedURLException e) {
  +            throw new InitException(e);
  +        }
  +    }
  +
  +    /**
        * Sets the location of the user configuration files
        *
        * @param userConfigArea the new user config area
  @@ -267,6 +326,25 @@
        */
       public URL getLibraryURL() {
           return libraryURL;
  +    }
  +
  +    /**
  +     * Get a URL to the Ant Library directory.
  +     *
  +     * @return the URL for the Ant library directory
  +     * @throws MalformedURLException if there is a problem constructing the 
  +     *      library URL
  +     */
  +    private URL getAntLibURL() throws MalformedURLException {
  +        URL initClassURL = ClassLocator.getClassLocationURL(getClass());
  +
  +        String initURLString = initClassURL.toString();
  +        int index = initURLString.lastIndexOf("/");
  +        if (index != -1) {
  +            initURLString = initURLString.substring(0, index + 1);
  +        }
  +
  +        return  new URL(initURLString);
       }
   }
   
  
  
  
  1.8       +14 -122   jakarta-ant/proposal/mutant/src/java/start/org/apache/ant/start/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/start/org/apache/ant/start/Main.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -w -u -r1.7 -r1.8
  --- Main.java	18 Mar 2002 02:44:28 -0000	1.7
  +++ Main.java	3 Apr 2002 15:02:48 -0000	1.8
  @@ -53,16 +53,10 @@
    */
   package org.apache.ant.start;
   
  -import java.io.File;
   import java.lang.reflect.Method;
  -import java.net.MalformedURLException;
   import java.net.URL;
   import java.net.URLClassLoader;
  -import org.apache.ant.init.ClassLocator;
  -import org.apache.ant.init.InitUtils;
   import org.apache.ant.init.InitConfig;
  -import org.apache.ant.init.InitException;
  -import org.apache.ant.init.LoaderUtils;
   
   /**
    * This is the main startup class for the command line interface of Ant. It
  @@ -77,44 +71,8 @@
            = "org.apache.ant.cli.Commandline";
   
   
  -    /**
  -     * Get a URL to the Ant Library directory.
  -     *
  -     * @return the URL for the Ant library directory
  -     * @throws InitException if there is a problem constructing the library
  -     *      URL
  -     */
  -    public static URL getLibraryURL()
  -         throws InitException {
  -        try {
  -            URL cliURL = ClassLocator.getClassLocationURL(Main.class);
  -
  -            if (cliURL.getProtocol().equals("file")
  -                 && cliURL.getFile().endsWith("/")) {
  -                // we are running from a set of classes. This should only
  -                // happen in an Ant build situation. We use some embedded
  -                // knowledge to locate the lib directory
  -                File classesDirectory = new File(cliURL.getFile());
  -                File libDirectory = new File(classesDirectory.getParent(),
  -                    "lib");
  -                if (!libDirectory.exists()) {
  -                    throw new RuntimeException("Ant library directory "
  -                         + libDirectory + " does not exist");
  -                }
  -                return InitUtils.getFileURL(libDirectory);
  -            } else {
  -                String cliURLString = cliURL.toString();
  -                int index = cliURLString.lastIndexOf("/");
  -                if (index != -1) {
  -                    cliURLString = cliURLString.substring(0, index + 1);
  -                }
  -                return new URL(cliURLString);
  -            }
  -        } catch (MalformedURLException e) {
  -            throw new InitException(e);
  -        }
  -    }
  -
  +    /** The default front end name */
  +    public static final String DEFAULT_FRONTEND = "cli";
   
       /**
        * Entry point for starting command line Ant
  @@ -123,90 +81,25 @@
        */
       public static void main(String[] args) {
           Main main = new Main();
  -        main.start(args);
  -    }
  -
  -
  -
  -    /**
  -     * Get the location of AntHome
  -     *
  -     * @return the URL containing AntHome.
  -     * @throws InitException if Ant's home cannot be determined or properly
  -     *      contructed.
  -     */
  -    private URL getAntHome()
  -         throws InitException {
  -        try {
  -            URL libraryURL = getLibraryURL();
  -            if (libraryURL != null) {
  -                return new URL(libraryURL, "..");
  -            }
  -        } catch (MalformedURLException e) {
  -            throw new InitException(e);
  +        main.start(DEFAULT_FRONTEND, args);
           }
  -        throw new InitException("Unable to determine Ant Home");
  -    }
  -
   
       /**
        * Internal start method used to initialise front end
        *
  +     * @param frontend the frontend jar to launch
        * @param args commandline arguments
        */
  -    private void start(String[] args) {
  +    public void start(String frontend, String[] args) {
           try {
               InitConfig config = new InitConfig();
   
  -            URL libraryURL = getLibraryURL();
  -            config.setLibraryURL(libraryURL);
  -
  -            URL antHome = getAntHome();
  -            config.setAntHome(antHome);
  -            if (antHome.getProtocol().equals("file")) {
  -                File systemConfigArea = new File(antHome.getFile(), "conf");
  -                config.setSystemConfigArea(systemConfigArea);
  -            }
  -            File userConfigArea
  -                 = new File(System.getProperty("user.home"), ".ant/conf");
  -            config.setUserConfigArea(userConfigArea);
  -
  -            // set up the class loaders that will be used when running Ant
  -            ClassLoader systemLoader = getClass().getClassLoader();
  -            config.setSystemLoader(systemLoader);
  -            URL toolsJarURL = ClassLocator.getToolsJarURL();
  -            config.setToolsJarURL(toolsJarURL);
  -
  -            URL commonJarLib = new URL(libraryURL, "common/");
  -            ClassLoader commonLoader
  -                 = new URLClassLoader(LoaderUtils.getLocationURLs(commonJarLib,
  -                "common.jar"), systemLoader);
  -            config.setCommonLoader(commonLoader);
  -
  -            // core needs XML parser for parsing various XML components.
  -            URL[] parserURLs
  -                 = LoaderUtils.getLocationURLs(new URL(libraryURL, "parser/"),
  -                "crimson.jar");
  -            config.setParserURLs(parserURLs);
  -
  -            URL[] coreURLs
  -                 = LoaderUtils.getLocationURLs(new URL(libraryURL, "antcore/"),
  -                "antcore.jar");
  -            URL[] combinedURLs = new URL[parserURLs.length + coreURLs.length];
  -            System.arraycopy(coreURLs, 0, combinedURLs, 0, coreURLs.length);
  -            System.arraycopy(parserURLs, 0, combinedURLs, coreURLs.length,
  -                parserURLs.length);
  -            ClassLoader coreLoader = new URLClassLoader(combinedURLs,
  -                commonLoader);
  -            config.setCoreLoader(coreLoader);
  -
  -            URL cliJarLib = new URL(libraryURL, "cli/");
  +            URL frontendJar = new URL(config.getLibraryURL(), 
  +                "frontend/" + frontend + ".jar");
  +            URL[] frontendJars = new URL[]{frontendJar};
               ClassLoader frontEndLoader
  -                 = new URLClassLoader(LoaderUtils.getLocationURLs(cliJarLib,
  -                "cli.jar"), coreLoader);
  +                = new URLClassLoader(frontendJars, config.getCoreLoader());
   
  -            //System.out.println("System Loader config");                
  -            //LoaderUtils.dumpLoader(System.out, systemLoader);
               // System.out.println("Front End Loader config");
               // LoaderUtils.dumpLoader(System.out, frontEndLoader);
   
  @@ -220,7 +113,6 @@
                    = commandLineClass.getMethod("start", param);
               final Object[] argument = {args, config};
               startMethod.invoke(null, argument);
  -
           } catch (Exception e) {
               e.printStackTrace();
           }
  
  
  

--
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