buildframework/helium/sf/java/antdata/src/com/nokia/helium/ant/data/taskdefs/DatabaseTask.java
changeset 628 7c4a911dc066
parent 587 85df38eb4012
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
    27 import org.apache.tools.ant.DirectoryScanner;
    27 import org.apache.tools.ant.DirectoryScanner;
    28 import org.apache.tools.ant.Project;
    28 import org.apache.tools.ant.Project;
    29 import org.apache.tools.ant.Task;
    29 import org.apache.tools.ant.Task;
    30 import org.apache.tools.ant.types.FileSet;
    30 import org.apache.tools.ant.types.FileSet;
    31 import org.apache.tools.ant.types.ResourceCollection;
    31 import org.apache.tools.ant.types.ResourceCollection;
       
    32 
    32 import com.nokia.helium.ant.data.Database;
    33 import com.nokia.helium.ant.data.Database;
    33 
    34 
    34 /**
    35 /**
    35  * Reads the current Ant project and any additional filesets and generates a xml
    36  * Reads the current Ant project and/or Ant files and generates a XML file with a summary
    36  * file with a summary of targets, macros and properties.
    37  * of targets, macros and properties.
    37  * 
    38  * 
    38  * @ant.task name="database"
    39  * @ant.task name="database" category="Database"
    39  */
    40  */
    40 public class DatabaseTask extends Task {
    41 public class DatabaseTask extends Task {
       
    42     private static final String DEFAULT_SCOPE = "public";
       
    43 
    41     private File outputFile;
    44     private File outputFile;
    42     // private boolean excludeParsedFiles
    45     private String scope = DEFAULT_SCOPE;
    43     private String scope = "public";
       
    44     private boolean filesetonly;
    46     private boolean filesetonly;
    45     private List<ResourceCollection> rcs = new ArrayList<ResourceCollection>();
    47     private List<ResourceCollection> rcs = new ArrayList<ResourceCollection>();
    46 
    48 
    47     public DatabaseTask() {
    49     public DatabaseTask() {
    48         setTaskName("database");
    50         setTaskName("database");
    68     }
    70     }
    69 
    71 
    70     public void setOutput(File outputFile) {
    72     public void setOutput(File outputFile) {
    71         this.outputFile = outputFile;
    73         this.outputFile = outputFile;
    72     }
    74     }
    73     
    75 
    74     public void setFilesetOnly(boolean f)
    76     public void setFilesetOnly(boolean filesetonly) {
    75     {
    77         this.filesetonly = filesetonly;
    76         filesetonly = f; 
       
    77     }
    78     }
    78 
    79 
    79     /**
    80     /**
    80      * Defines what level of visibility to display Ant objects at.
    81      * Defines what level of visibility to display Ant objects at. Default value is "public".
    81      * 
    82      * 
    82      * @param scope The visibility level, either public, protected or private.
    83      * @param scope The visibility level, either public, protected or private.
    83      */
    84      */
    84     public void setScope(String scope) {
    85     public void setScope(String scope) {
    85         this.scope = scope;
    86         this.scope = scope;
   108                 }
   109                 }
   109             }
   110             }
   110 
   111 
   111             // Output the database file
   112             // Output the database file
   112             Database db;
   113             Database db;
   113             if (filesetonly)
   114             if (filesetonly) {
   114                 db = new Database(null);
   115                 db = new Database(null);
   115             else
   116             }
       
   117             else {
   116                 db = new Database(getProject());
   118                 db = new Database(getProject());
       
   119             }
   117             db.setScopeFilter(scope);
   120             db.setScopeFilter(scope);
   118             db.addAntFilePaths(antFilePaths);
   121             db.addAntFilePaths(antFilePaths);
   119             FileWriter out = new FileWriter(outputFile);
   122             FileWriter out = new FileWriter(outputFile);
   120             db.toXML(out);
   123             db.toXML(out);
   121             out.close();
   124             out.close();