You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by le...@apache.org on 2003/08/23 01:48:03 UTC

cvs commit: jakarta-commons-sandbox/attributes/compiler/src/java/org/apache/commons/attributes/compiler AttributeCompiler.java AttributeIndexer.java

leosutic    2003/08/22 16:48:03

  Modified:    attributes/compiler project.xml
               attributes/compiler/src/java/org/apache/commons/attributes/compiler
                        AttributeCompiler.java AttributeIndexer.java
  Log:
  Renamed all maven id's from "jakarta-commons-attributes" to
  "commons-attributes", and added Apache license.
  
  Revision  Changes    Path
  1.2       +4 -6      jakarta-commons-sandbox/attributes/compiler/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/attributes/compiler/project.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- project.xml	20 Aug 2003 23:16:15 -0000	1.1
  +++ project.xml	22 Aug 2003 23:48:03 -0000	1.2
  @@ -2,12 +2,10 @@
   
   <project>
       <extend>${basedir}/../project.xml</extend>
  -    <id>jakarta-commons-attributes-compiler</id>
  +    <id>commons-attributes-compiler</id>
       <name>Jakarta Commons Attribute Compiler Ant Task</name>
       <package>org.apache.commons.attributes.compiler</package>
  -    
  -    <currentVersion>0.1</currentVersion>
  -    <inceptionYear>2003</inceptionYear>
  +
       <shortDescription>Attribute Compiler</shortDescription>
       
       <description>
  @@ -27,8 +25,8 @@
           </dependency>
           
           <dependency>
  -            <groupId>jakarta-commons-attributes</groupId>
  -            <artifactId>jakarta-commons-attributes-api</artifactId>
  +            <groupId>commons-attributes</groupId>
  +            <artifactId>commons-attributes-api</artifactId>
               <version>SNAPSHOT</version>
           </dependency>
       </dependencies>
  
  
  
  1.2       +91 -9     jakarta-commons-sandbox/attributes/compiler/src/java/org/apache/commons/attributes/compiler/AttributeCompiler.java
  
  Index: AttributeCompiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/attributes/compiler/src/java/org/apache/commons/attributes/compiler/AttributeCompiler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AttributeCompiler.java	20 Aug 2003 23:13:29 -0000	1.1
  +++ AttributeCompiler.java	22 Aug 2003 23:48:03 -0000	1.2
  @@ -1,3 +1,59 @@
  +/*
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
   package org.apache.commons.attributes.compiler;
   
   import java.io.BufferedReader;
  @@ -13,6 +69,7 @@
   
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.types.FileSet;
  +import org.apache.tools.ant.types.Path;
   
   import xjavadoc.XClass;
   import xjavadoc.XConstructor;
  @@ -42,6 +99,7 @@
   public class AttributeCompiler extends XJavadocTask {
       
       private final ArrayList fileSets = new ArrayList ();
  +    private Path src;
       private File destDir;
       private int numGenerated;
       
  @@ -53,11 +111,29 @@
           fileSets.add (set);
       }
       
  -    
       public void setDestdir (File destDir) {
           this.destDir = destDir;
       }
       
  +    public void setSourcepathref (String pathref) {
  +        String sourcePaths = project.getReference (pathref).toString ();
  +        StringTokenizer tok = new StringTokenizer (sourcePaths, File.pathSeparator);
  +        while (tok.hasMoreTokens ()) {
  +            FileSet fs = new FileSet ();
  +            fs.setDir (new File (tok.nextToken ()));
  +            fs.setIncludes ("**/*.java");
  +            fs.setProject (project);
  +            addFileset (fs);
  +        }
  +    }
  +    
  +    /**
  +     * This attribute is only set when the compiler is running in Maven.
  +     * Grab all POM-related parameters here.
  +     */
  +    public void setInmaven (boolean inMaven) {
  +    }
  +    
       protected void copyImports (File source, PrintWriter dest) throws Exception {
           BufferedReader br = new BufferedReader (new FileReader (source));
           try {
  @@ -80,6 +156,8 @@
               
               if (isAttribute (tag)) {
                   String expression = tag.getName () + " " + tag.getValue ();
  +                expression = expression.trim ();
  +                
                   if (expression.startsWith ("@")) {
                       expression = expression.substring (1);
                   }
  @@ -121,14 +199,6 @@
       }
           
       protected void generateClass (XClass xClass) throws Exception {
  -        if (xClass.isAnonymous ()) {
  -            log (xClass.getName () + " is anonymous - ignoring.");
  -        }
  -        
  -        if (!hasAttributes (xClass)) {
  -            return;
  -        }
  -        
           String name = null;
           File sourceFile = null;
           File destFile = null;
  @@ -152,6 +222,18 @@
           }
           
           destFile = new File (destDir, name.replace ('.', '/') + "$__attributeRepository.java");
  +        
  +        if (xClass.isAnonymous ()) {
  +            log (xClass.getName () + " is anonymous - ignoring.");
  +            return;
  +        }
  +        
  +        if (!hasAttributes (xClass)) {
  +            if (destFile.exists ()) {
  +                destFile.delete ();
  +            }
  +            return;
  +        }
           
           if (destFile.exists () && destFile.lastModified () >= sourceFile.lastModified ()) {
               return;
  
  
  
  1.2       +60 -0     jakarta-commons-sandbox/attributes/compiler/src/java/org/apache/commons/attributes/compiler/AttributeIndexer.java
  
  Index: AttributeIndexer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/attributes/compiler/src/java/org/apache/commons/attributes/compiler/AttributeIndexer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AttributeIndexer.java	20 Aug 2003 23:13:29 -0000	1.1
  +++ AttributeIndexer.java	22 Aug 2003 23:48:03 -0000	1.2
  @@ -1,3 +1,59 @@
  +/*
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
   package org.apache.commons.attributes.compiler;
   
   import java.io.BufferedInputStream;
  @@ -99,6 +155,10 @@
       }
       
       public void execute () throws BuildException {
  +        if (!jarFile.exists ()) {
  +            log ("Can't find " + jarFile.getPath ());
  +            return;
  +        }
           try {
               log ("Building attribute index for " + jarFile.getPath ());