ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/compilers AptExternalCompilerAdapter.java AptCompilerAdapter.java
Date Mon, 07 Mar 2005 12:22:52 GMT
stevel      2005/03/07 04:22:52

  Modified:    src/main/org/apache/tools/ant/taskdefs/compilers
                        AptExternalCompilerAdapter.java
                        AptCompilerAdapter.java
  Log:
  Fixing apt with correct method name, some more javadocs.
  http://issues.apache.org/bugzilla/show_bug.cgi?id=33853
  
  Revision  Changes    Path
  1.3       +6 -0      ant/src/main/org/apache/tools/ant/taskdefs/compilers/AptExternalCompilerAdapter.java
  
  Index: AptExternalCompilerAdapter.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/compilers/AptExternalCompilerAdapter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AptExternalCompilerAdapter.java	22 Nov 2004 09:23:30 -0000	1.2
  +++ AptExternalCompilerAdapter.java	7 Mar 2005 12:22:52 -0000	1.3
  @@ -30,6 +30,12 @@
   public class AptExternalCompilerAdapter extends DefaultCompilerAdapter {
   
   
  +    /**
  +     * Get the facade task that fronts this adapter
  +     *
  +     * @return task instance
  +     * @see DefaultCompilerAdapter#getJavac()
  +     */
       protected Apt getApt() {
           return (Apt) getJavac();
       }
  
  
  
  1.3       +60 -3     ant/src/main/org/apache/tools/ant/taskdefs/compilers/AptCompilerAdapter.java
  
  Index: AptCompilerAdapter.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/compilers/AptCompilerAdapter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AptCompilerAdapter.java	12 Oct 2004 20:51:29 -0000	1.2
  +++ AptCompilerAdapter.java	7 Mar 2005 12:22:52 -0000	1.3
  @@ -31,22 +31,70 @@
   
   /**
    * The implementation of the apt compiler for JDK 1.5
  + * <p/>
  + * As usual, the low level entry points for Java tools are neither documented or
  + * stable; this entry point may change from that of 1.5.0_01-b08 without any
  + * warning at all. The IDE decompile of the tool entry points is as follows:
  + * <pre>
  + * public class Main {
  + * public Main() ;
  + * <p/>
  + * public static transient void main(String... strings) ;
  + * <p/>
  + * public static transient int process(String... strings);
  + * <p/>
  + * public static transient int process(PrintWriter printWriter,
  + *      String... strings) ;
  + * public static transient int process(
  + *      AnnotationProcessorFactory annotationProcessorFactory,
  + *      String... strings) ;
  + * <p/>
  + * public static transient int process(
  + *      AnnotationProcessorFactory annotationProcessorFactory,
  + *      PrintWriter printWriter,
  + *      String... strings);
  + * private static transient int processing(
  + *      AnnotationProcessorFactory annotationProcessorFactory,
  + *      PrintWriter printWriter,
  + *      String... strings) ;
  + * }
  + * </pre>
    *
    * @since Ant 1.7
    */
   public class AptCompilerAdapter extends DefaultCompilerAdapter {
   
       /**
  -     * Integer returned by the "Modern" jdk1.3 compiler to indicate success.
  +     * Integer returned by the Apt compiler to indicate success.
        */
       private static final int APT_COMPILER_SUCCESS = 0;
  +    /**
  +     * class in tools.jar that implements APT
  +     */
       public static final String APT_ENTRY_POINT = "com.sun.tools.apt.Main";
  -    public static final String APT_METHOD_NAME = "compile";
   
  +    /**
  +     * method used to compile.
  +     */
  +    public static final String APT_METHOD_NAME = "process";
  +
  +    /**
  +     * Get the facade task that fronts this adapter
  +     *
  +     * @return task instance
  +     * @see DefaultCompilerAdapter#getJavac()
  +     */
       protected Apt getApt() {
           return (Apt) getJavac();
       }
   
  +    /**
  +     * Using the front end arguments, set up the command line to run Apt
  +     *
  +     * @param apt task
  +     * @param cmd command that is set up with the various switches from the task
  +     *            options
  +     */
       static void setAptCommandlineSwitches(Apt apt, Commandline cmd) {
   
           if (!apt.isCompile()) {
  @@ -89,8 +137,12 @@
           }
       }
   
  +    /**
  +     * using our front end task, set up the command line switches
  +     *
  +     * @param cmd command line to set up
  +     */
       protected void setAptCommandlineSwitches(Commandline cmd) {
  -        // Process the nocompile flag
           Apt apt = getApt();
           setAptCommandlineSwitches(apt, cmd);
       }
  @@ -102,9 +154,12 @@
        */
       public boolean execute() throws BuildException {
           attributes.log("Using apt compiler", Project.MSG_VERBOSE);
  +        //set up the javac options
           Commandline cmd = setupModernJavacCommand();
  +        //then add the Apt options
           setAptCommandlineSwitches(cmd);
   
  +        //finally invoke APT
           // Use reflection to be able to build on all JDKs:
           try {
               Class c = Class.forName(APT_ENTRY_POINT);
  @@ -116,8 +171,10 @@
                       .intValue();
               return (result == APT_COMPILER_SUCCESS);
           } catch (BuildException be) {
  +            //rethrow build exceptions
               throw be;
           } catch (Exception ex) {
  +            //cast everything else to a build exception
               throw new BuildException("Error starting apt compiler",
                       ex, location);
           }
  
  
  

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


Mime
View raw message