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/rmic DefaultRmicAdapter.java ForkingSunRmic.java WLRmic.java
Date Fri, 08 Oct 2004 11:09:46 GMT
stevel      2004/10/08 04:09:46

  Modified:    docs/manual/OptionalTasks depend.html
               src/main/org/apache/tools/ant/taskdefs/optional/depend
                        Depend.java
               src/main/org/apache/tools/ant/taskdefs/rmic
                        DefaultRmicAdapter.java ForkingSunRmic.java
                        WLRmic.java
  Log:
  Fed up with complaints about rmic generated code not having its source files found. Now
you can turn it off.
  
  Revision  Changes    Path
  1.11      +6 -0      ant/docs/manual/OptionalTasks/depend.html
  
  Index: depend.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/OptionalTasks/depend.html,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- depend.html	9 Feb 2004 21:50:08 -0000	1.10
  +++ depend.html	8 Oct 2004 11:09:45 -0000	1.11
  @@ -147,6 +147,12 @@
                        check dependencies</td>
       <td valign="top" align="center">No</td>
     </tr>
  +  <tr>
  +    <td valign="top">warnOnRmiStubs</td>
  +    <td valign="top">Flag to disable warnings about files that look like rmic generated
stub/skeleton
  +    classes, and which have no .java source. Useful when doing rmi development. </td>
  +    <td valign="top" align="center">No, default=true</td>
  +  </tr>
   </table>
   
   <h3>Parameters specified as nested elements</h3>
  
  
  
  1.44      +69 -13    ant/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
  
  Index: Depend.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- Depend.java	9 Mar 2004 16:48:16 -0000	1.43
  +++ Depend.java	8 Oct 2004 11:09:46 -0000	1.44
  @@ -31,6 +31,8 @@
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.taskdefs.MatchingTask;
  +import org.apache.tools.ant.taskdefs.rmic.DefaultRmicAdapter;
  +import org.apache.tools.ant.taskdefs.rmic.WLRmic;
   import org.apache.tools.ant.types.Path;
   import org.apache.tools.ant.types.Reference;
   import org.apache.tools.ant.util.depend.DependencyAnalyzer;
  @@ -96,6 +98,11 @@
       private boolean closure = false;
   
       /**
  +     * flag to enable warning if we encounter RMI stubs
  +     */
  +    private boolean warnOnRmiStubs=true;
  +
  +    /**
        * Flag which controls whether the reversed dependencies should be
        * dumped to the log
        */
  @@ -155,6 +162,16 @@
       }
   
       /**
  +     * flag to set to true if you want dependency issues with RMI
  +     * stubs to appear at warning level.
  +     * @param warnOnRmiStubs
  +     * @since Ant1.7
  +     */
  +    public void setWarnOnRmiStubs(boolean warnOnRmiStubs) {
  +        this.warnOnRmiStubs = warnOnRmiStubs;
  +    }
  +
  +    /**
        * Read the dependencies from cache file
        *
        * @return a collection of class dependencies
  @@ -326,10 +343,8 @@
                   while (depEnum.hasMoreElements()) {
                       dependencyList.addElement(depEnum.nextElement());
                   }
  -                if (dependencyList != null) {
  -                    cacheDirty = true;
  -                    dependencyMap.put(info.className, dependencyList);
  -                }
  +                cacheDirty = true;
  +                dependencyMap.put(info.className, dependencyList);
               }
   
               // This class depends on each class in the dependency list. For each
  @@ -454,14 +469,7 @@
               }
   
               if (affectedClassInfo.sourceFile == null) {
  -                if (!affectedClassInfo.isUserWarned) {
  -                    log("The class " + affectedClass + " in file "
  -                        + affectedClassInfo.absoluteFile.getPath()
  -                        + " is out of date due to " + className
  -                        + " but has not been deleted because its source file"
  -                        + " could not be determined", Project.MSG_WARN);
  -                    affectedClassInfo.isUserWarned = true;
  -                }
  +                warnOutOfDateButNotDeleted(affectedClassInfo, affectedClass, className);
                   continue;
               }
   
  @@ -504,6 +512,54 @@
       }
   
       /**
  +     * warn when a class is out of date, but not deleted as its source is unknown.
  +     * MSG_WARN is the normal level, but we downgrade to MSG_VERBOSE for RMI files
  +     * if {@link #warnOnRmiStubs is false}
  +     * @param affectedClassInfo info about the affectd class
  +     * @param affectedClass the name of the affected .class file
  +     * @param className the file that is triggering the out of dateness
  +     */
  +    private void warnOutOfDateButNotDeleted(
  +            ClassFileInfo affectedClassInfo, String affectedClass,
  +            String className) {
  +        if (affectedClassInfo.isUserWarned) {
  +            return;
  +        }
  +        int level = Project.MSG_WARN;
  +        if(!warnOnRmiStubs) {
  +            //downgrade warnings on RMI stublike classes, as they are generated
  +            //by rmic, so there is no need to tell the user that their source is
  +            //missing.
  +            if(isRmiStub(affectedClass, className)) {
  +                level=Project.MSG_VERBOSE;
  +            }
  +        }
  +        log("The class " + affectedClass + " in file "
  +            + affectedClassInfo.absoluteFile.getPath()
  +            + " is out of date due to " + className
  +            + " but has not been deleted because its source file"
  +            + " could not be determined", level);
  +        affectedClassInfo.isUserWarned = true;
  +    }
  +
  +    /**
  +     * test for being an RMI stub
  +     * @param affectedClass
  +     * @param className
  +     * @return
  +     */
  +    private boolean isRmiStub(String affectedClass, String className) {
  +        return isStub(affectedClass,className, DefaultRmicAdapter.RMI_STUB_SUFFIX)
  +                || isStub(affectedClass, className, DefaultRmicAdapter.RMI_SKEL_SUFFIX)
  +                || isStub(affectedClass, className, WLRmic.RMI_STUB_SUFFIX)
  +                || isStub(affectedClass, className, WLRmic.RMI_SKEL_SUFFIX);
  +    }
  +
  +    private boolean isStub(String affectedClass,String baseClass,String suffix) {
  +        return (baseClass+suffix).equals(affectedClass);
  +    }
  +
  +    /**
        * Dump the dependency information loaded from the classes to the Ant log
        */
       private void dumpDependencies() {
  @@ -548,7 +604,7 @@
       private void determineOutOfDateClasses() {
           outOfDateClasses = new Hashtable();
           for (int i = 0; i < srcPathList.length; i++) {
  -            File srcDir = (File) getProject().resolveFile(srcPathList[i]);
  +            File srcDir = getProject().resolveFile(srcPathList[i]);
               if (srcDir.exists()) {
                   DirectoryScanner ds = this.getDirectoryScanner(srcDir);
                   String[] files = ds.getIncludedFiles();
  
  
  
  1.34      +6 -4      ant/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
  
  Index: DefaultRmicAdapter.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- DefaultRmicAdapter.java	2 Aug 2004 22:45:44 -0000	1.33
  +++ DefaultRmicAdapter.java	8 Oct 2004 11:09:46 -0000	1.34
  @@ -25,7 +25,6 @@
   import org.apache.tools.ant.types.Commandline;
   import org.apache.tools.ant.types.Path;
   import org.apache.tools.ant.util.FileNameMapper;
  -import org.apache.tools.ant.util.JavaEnvUtils;
   
   /**
    * This is the default implementation for the RmicAdapter interface.
  @@ -39,6 +38,9 @@
       private Rmic attributes;
       private FileNameMapper mapper;
       private static final Random rand = new Random();
  +    public static final String RMI_STUB_SUFFIX = "_Stub";
  +    public static final String RMI_SKEL_SUFFIX = "_Skel";
  +    public static final String RMI_TIE_SUFFIX = "_Tie";
   
       public DefaultRmicAdapter() {
       }
  @@ -53,15 +55,15 @@
       }
   
       protected String getStubClassSuffix() {
  -        return "_Stub";
  +        return RMI_STUB_SUFFIX;
       }
   
       protected String getSkelClassSuffix() {
  -        return "_Skel";
  +        return RMI_SKEL_SUFFIX;
       }
   
       protected String getTieClassSuffix() {
  -        return "_Tie";
  +        return RMI_TIE_SUFFIX;
       }
   
       /**
  
  
  
  1.3       +2 -2      ant/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java
  
  Index: ForkingSunRmic.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ForkingSunRmic.java	5 Aug 2004 17:13:42 -0000	1.2
  +++ ForkingSunRmic.java	8 Oct 2004 11:09:46 -0000	1.3
  @@ -23,8 +23,8 @@
   
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
  +import org.apache.tools.ant.util.JavaEnvUtils;
   import org.apache.tools.ant.taskdefs.Rmic;
  -import org.apache.tools.ant.taskdefs.Java;
   import org.apache.tools.ant.taskdefs.Execute;
   import org.apache.tools.ant.taskdefs.LogStreamHandler;
   import org.apache.tools.ant.types.Commandline;
  @@ -56,7 +56,7 @@
           Commandline cmd = setupRmicCommand();
           Project project=owner.getProject();
           //rely on RMIC being on the path
  -        cmd.setExecutable(SunRmic.RMIC_EXECUTABLE);
  +        cmd.setExecutable(JavaEnvUtils.getJdkExecutable(SunRmic.RMIC_EXECUTABLE));
   
           //set up the args
           String[] args=cmd.getCommandline();
  
  
  
  1.25      +4 -2      ant/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java
  
  Index: WLRmic.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- WLRmic.java	24 Aug 2004 20:34:53 -0000	1.24
  +++ WLRmic.java	8 Oct 2004 11:09:46 -0000	1.25
  @@ -40,6 +40,8 @@
                                            + "set the environment variable "
                                            + "CLASSPATH.";
       public static final String ERROR_WLRMIC_FAILED = "Error starting WebLogic rmic: ";
  +    public static final String RMI_STUB_SUFFIX = "_WLStub";
  +    public static final String RMI_SKEL_SUFFIX = "_WLSkel";
   
       public boolean execute() throws BuildException {
           getRmic().log("Using WebLogic rmic", Project.MSG_VERBOSE);
  @@ -80,13 +82,13 @@
        * Get the suffix for the rmic stub classes
        */
       public String getStubClassSuffix() {
  -        return "_WLStub";
  +        return RMI_STUB_SUFFIX;
       }
   
       /**
        * Get the suffix for the rmic skeleton classes
        */
       public String getSkelClassSuffix() {
  -        return "_WLSkel";
  +        return RMI_SKEL_SUFFIX;
       }
   }
  
  
  

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


Mime
View raw message