Home » apache-ant-1.7.1-src » org.apache.tools » ant » taskdefs » optional » ide » [javadoc | source]
    1   /*
    2    * Copyright  2001-2004 The Apache Software Foundation
    3    *
    4    *  Licensed under the Apache License, Version 2.0 (the "License");
    5    *  you may not use this file except in compliance with the License.
    6    *  You may obtain a copy of the License at
    7    *
    8    *      http://www.apache.org/licenses/LICENSE-2.0
    9    *
   10    *  Unless required by applicable law or agreed to in writing, software
   11    *  distributed under the License is distributed on an "AS IS" BASIS,
   12    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   13    *  See the License for the specific language governing permissions and
   14    *  limitations under the License.
   15    *
   16    */
   17   
   18   package org.apache.tools.ant.taskdefs.optional.ide;
   19   
   20   
   21   import java.io.File;
   22   import org.apache.tools.ant.BuildException;
   23   import org.apache.tools.ant.types.PatternSet;
   24   
   25   /**
   26    * Export packages from the Visual Age for Java workspace.
   27    * The packages are specified similar to all other MatchingTasks.
   28    * Since the VA Workspace is not file based, this task is simulating
   29    * a directory hierarchy for the workspace:
   30    * The 'root' contains all project 'dir's, and the projects contain
   31    * their respective package 'dir's.
   32    * Example:
   33    * <blockquote>
   34    * &lt;vajexport destdir=&quot;C:/builddir/source&quot;&gt;
   35    * &nbsp;&lt;include name=&quot;/MyVAProject/org/foo/subsystem1/**&quot; /&gt;
   36    * &nbsp;&lt;exclude name=&quot;/MyVAProject/org/foo/subsystem1/test/**&quot;/&gt;
   37    * &lt;/vajexport&gt;
   38    * </blockquote>
   39    * exports all packages in the project MyVAProject which start with
   40    * 'org.foo.subsystem1' except of these starting with
   41    * 'org.foo.subsystem1.test'.
   42    *
   43    * <p>Parameters:
   44    * <table border="1" cellpadding="2" cellspacing="0">
   45    * <tr>
   46    *   <td valign="top"><b>Attribute</b></td>
   47    *   <td valign="top"><b>Description</b></td>
   48    *   <td align="center" valign="top"><b>Required</b></td>
   49    * </tr>
   50    * <tr>
   51    *   <td valign="top">destdir</td>
   52    *   <td valign="top">location to store the exported files</td>
   53    *   <td align="center" valign="top">Yes</td>
   54    * <tr>
   55    *   <td valign="top">exportSources</td>
   56    *   <td valign="top">export Java sources, defaults to "yes"</td>
   57    *   <td align="center" valign="top">No</td>
   58    * </tr>
   59    * <tr>
   60    *   <td valign="top">exportResources</td>
   61    *   <td valign="top">export resource files, defaults to "yes"</td>
   62    *   <td align="center" valign="top">No</td>
   63    * </tr>
   64    * <tr>
   65    *   <td valign="top">exportClasses</td>
   66    *   <td valign="top">export class files, defaults to "no"</td>
   67    *   <td align="center" valign="top">No</td>
   68    * </tr>
   69    * <tr>
   70    *   <td valign="top">exportDebugInfo</td>
   71    *   <td valign="top">include debug info in exported class files,
   72    *                    defaults to "no"</td>
   73    *   <td align="center" valign="top">No</td>
   74    * </tr>
   75    * <tr>
   76    *   <td valign="top">defaultexcludes</td>
   77    *   <td valign="top">use default excludes when exporting,
   78    *                    defaults to "yes".
   79    *                    Default excludes are: IBM&#x2f;**,
   80    *                    Java class libraries&#x2f;**, Sun class libraries&#x2f;**,
   81    *                    JSP Page Compile Generated Code&#x2f;**, Visual Age*&#x2f;**</td>
   82    *   <td align="center" valign="top">No</td>
   83    * </tr>
   84    * <tr>
   85    *   <td valign="top">overwrite</td>
   86    *   <td valign="top">overwrite existing files, defaults to "yes"</td>
   87    *   <td align="center" valign="top">No</td>
   88    * </tr>
   89    * <tr>
   90    *   <td valign="top">remote</td>
   91    *   <td valign="top">remote tool server to run this command against
   92    *                    (format: &lt;servername&gt; : &lt;port no&gt;)</td>
   93    *   <td align="center" valign="top">No</td>
   94    * </tr>
   95    * <tr>
   96    *   <td valign="top">haltonerror</td>
   97    *   <td valign="top">stop the build process if an error occurs,
   98    *                    defaults to "yes"</td>
   99    *   <td align="center" valign="top">No</td>
  100    * </tr>
  101    * </table>
  102    *
  103    */
  104   
  105   public class VAJExport extends VAJTask {
  106       //set set... method comments for description
  107       protected File destDir;
  108       protected boolean exportSources = true;
  109       protected boolean exportResources = true;
  110       protected boolean exportClasses = false;
  111       protected boolean exportDebugInfo = false;
  112       protected boolean useDefaultExcludes = true;
  113       protected boolean overwrite = true;
  114   
  115       protected PatternSet patternSet = new PatternSet();
  116   
  117       /**
  118        * add a name entry on the exclude list
  119        */
  120       public PatternSet.NameEntry createExclude() {
  121           return patternSet.createExclude();
  122       }
  123   
  124       /**
  125        * add a name entry on the include list
  126        */
  127       public PatternSet.NameEntry createInclude() {
  128           return patternSet.createInclude();
  129       }
  130   
  131       /**
  132        * do the export
  133        */
  134       public void execute() throws BuildException {
  135           // first off, make sure that we've got a destdir
  136           if (destDir == null) {
  137               throw new BuildException("destdir attribute must be set!");
  138           }
  139   
  140           // delegate the export to the VAJUtil object.
  141           try {
  142               getUtil().exportPackages(destDir,
  143                   patternSet.getIncludePatterns(getProject()),
  144                   patternSet.getExcludePatterns(getProject()),
  145                   exportClasses, exportDebugInfo,
  146                   exportResources, exportSources,
  147                   useDefaultExcludes, overwrite);
  148           } catch (BuildException ex) {
  149               if (haltOnError) {
  150                   throw ex;
  151               } else {
  152                   log(ex.toString());
  153               }
  154           }
  155       }
  156   
  157       /**
  158        * Sets whether default exclusions should be used or not; default true.
  159        *
  160        * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions
  161        *                           should be used, "false"|"off"|"no" when they
  162        *                           shouldn't be used.
  163        */
  164       public void setDefaultexcludes(boolean useDefaultExcludes) {
  165           this.useDefaultExcludes = useDefaultExcludes;
  166       }
  167   
  168       /**
  169        * Set the destination directory into which the selected
  170        * items should be exported; required.
  171        */
  172       public void setDestdir(File destDir) {
  173           this.destDir = destDir;
  174       }
  175   
  176       /**
  177        * Sets the set of exclude patterns. Patterns may be separated by a comma
  178        * or a space. Currently only patterns denoting packages are
  179        * supported
  180        *
  181        * @param excludes the string containing the exclude patterns
  182        */
  183       public void setExcludes(String excludes) {
  184           patternSet.setExcludes(excludes);
  185       }
  186   
  187       /**
  188        * optional flag to export the class files; default false.
  189        */
  190       public void setExportClasses(boolean doExport) {
  191           exportClasses = doExport;
  192       }
  193   
  194       /**
  195        * optional flag to export the debug info; default false.
  196        * debug info
  197        */
  198       public void setExportDebugInfo(boolean doExport) {
  199           exportDebugInfo = doExport;
  200       }
  201   
  202       /**
  203        * optional flag to export the resource file; default true.
  204        */
  205       public void setExportResources(boolean doExport) {
  206           exportResources = doExport;
  207       }
  208   
  209       /**
  210        * optional flag to export the Java files; default true.
  211        */
  212       public void setExportSources(boolean doExport) {
  213           exportSources = doExport;
  214       }
  215   
  216       /**
  217        * Sets the set of include patterns. Patterns may be separated by a comma
  218        * or a space. Currently only patterns denoting packages are
  219        * supported
  220        *
  221        * @param includes the string containing the include patterns
  222        */
  223       public void setIncludes(String includes) {
  224           patternSet.setIncludes(includes);
  225       }
  226   
  227       /**
  228        * if Overwrite is set, files will be overwritten during export
  229        */
  230       public void setOverwrite(boolean doOverwrite) {
  231           overwrite = doOverwrite;
  232       }
  233   
  234   }

Save This Page
Home » apache-ant-1.7.1-src » org.apache.tools » ant » taskdefs » optional » ide » [javadoc | source]