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/optional/dotnet DotnetDefine.java DotnetResource.java JSharp.java CSharp.java DotnetBaseMatchingTask.java DotnetCompile.java Ilasm.java NetCommand.java VisualBasicCompile.java
Date Tue, 11 Mar 2003 06:07:38 GMT
stevel      2003/03/10 22:07:38

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/dotnet
                        CSharp.java DotnetBaseMatchingTask.java
                        DotnetCompile.java Ilasm.java NetCommand.java
                        VisualBasicCompile.java
  Added:       src/main/org/apache/tools/ant/taskdefs/optional/dotnet
                        DotnetDefine.java DotnetResource.java JSharp.java
  Log:
  Rounding off the toolchain with <defines> that has the same syntax as that of <cc>,
a resource type for resource inclusion, and , uh, a J# compiler. Notice how I reverse the
pureJava setting from that of vjc, so you need to explicitly ask for impure java. I havent
enabled this in the types yet, in case anyone wants to veto the concept altogether.
  
  Then I add <reference> fileset support into vbc, jsharp and csc, including inside
the dependency checking.
  
  resources still need dependency checking, and testing.
  
  Revision  Changes    Path
  1.30      +10 -0     ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java
  
  Index: CSharp.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- CSharp.java	10 Feb 2003 14:13:48 -0000	1.29
  +++ CSharp.java	11 Mar 2003 06:07:37 -0000	1.30
  @@ -449,5 +449,15 @@
           return "cs";
       }
   
  +    /**
  +     * from a resource, get the resource param string
  +     * @param resource
  +     * @return a string containing the resource param, or a null string
  +     * to conditionally exclude a resource.
  +     */
  +    protected String createResourceParameter(DotnetResource resource) {
  +        return resource.getCSharpStyleParameter();
  +    }
  +
   }
   
  
  
  
  1.2       +5 -2      ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetBaseMatchingTask.java
  
  Index: DotnetBaseMatchingTask.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetBaseMatchingTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DotnetBaseMatchingTask.java	10 Mar 2003 08:02:24 -0000	1.1
  +++ DotnetBaseMatchingTask.java	11 Mar 2003 06:07:37 -0000	1.2
  @@ -76,9 +76,10 @@
        */
       protected File outputFile;
       /**
  -     * sets of file to compile
  +     * filesets of file to compile
        */
       protected Vector filesets = new Vector();
  +
       /**
        *  source directory upon which the search pattern is applied
        */
  @@ -193,7 +194,7 @@
        * finish off the command by adding all dependent files, execute
        * @param command
        */
  -    protected void addFilesAndExecute(NetCommand command) {
  +    protected void addFilesAndExecute(NetCommand command, boolean ignoreTimestamps) {
           long outputTimestamp = getOutputFileTimestamp();
           Hashtable filesToBuild =new Hashtable();
           int filesOutOfDate = buildFileList(command,filesToBuild, outputTimestamp);
  @@ -201,6 +202,7 @@
           //add the files to the command
           addFilesToCommand(filesToBuild, command);
   
  +
           //now run the command of exe + settings + files
           if (filesOutOfDate > 0) {
               command.runCommand();
  @@ -208,6 +210,7 @@
               log("output file is up to date",Project.MSG_VERBOSE);
           }
       }
  +
   
   
   }
  
  
  
  1.7       +112 -69   ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java
  
  Index: DotnetCompile.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DotnetCompile.java	10 Mar 2003 08:02:24 -0000	1.6
  +++ DotnetCompile.java	11 Mar 2003 06:07:37 -0000	1.7
  @@ -152,6 +152,10 @@
        */
       protected Vector definitionList = new Vector();
   
  +    /**
  +     * our resources
  +     */
  +    protected Vector resources = new Vector();
   
       /**
        *  Fix .NET reference inclusion. .NET is really dumb in how it handles
  @@ -167,7 +171,7 @@
        *  need to reference mscorlib.dll, cos it is always there
        */
   
  -    protected static final String [] DEFAULT_REFERENCE_LIST_DOTNET_10 =
  +    protected static final String[] DEFAULT_REFERENCE_LIST_DOTNET_10 =
              {"Accessibility.dll",
               "cscompmgd.dll",
               "CustomMarshalers.dll",
  @@ -192,6 +196,8 @@
               "System.Windows.Forms.dll",
               "System.XML.dll"};
   
  +    protected static final String REFERENCE_OPTION= "/reference:";
  +
       /**
        *  debug flag. Controls generation of debug information.
        */
  @@ -230,6 +236,10 @@
        *  list of extra modules to refer to
        */
       protected String additionalModules;
  +    /**
  +     * filesets of references
  +     */
  +    protected Vector referenceFilesets =new Vector();
   
   
       /**
  @@ -278,7 +288,7 @@
       protected String getReferencesParameter() {
           //bail on no references
           if (notEmpty(references)) {
  -            return "/reference:" + references;
  +            return REFERENCE_OPTION + references;
           } else {
               return null;
           }
  @@ -298,6 +308,15 @@
           referenceFiles.append(path);
       }
   
  +    /**
  +     * add a new reference fileset to the compilation
  +     * @param reference
  +     */
  +    public void addReference(FileSet reference) {
  +        referenceFilesets.add(reference);
  +    }
  +
  +
   
       /**
        *  turn the path list into a list of files and a /references argument
  @@ -319,7 +338,7 @@
               return null;
           }
   
  -        StringBuffer s = new StringBuffer("/reference:");
  +        StringBuffer s = new StringBuffer(REFERENCE_OPTION);
           s.append(refpath);
           return new String(s);
       }
  @@ -681,7 +700,7 @@
        * add a define to the list of definitions
        * @param define
        */
  -    public void addDefine(Define define) {
  +    public void addDefine(DotnetDefine define) {
           definitionList.addElement(define);
       }
   
  @@ -695,7 +714,7 @@
           Enumeration defEnum=definitionList.elements();
           while (defEnum.hasMoreElements()) {
               //loop through all definitions
  -            Define define = (Define) defEnum.nextElement();
  +            DotnetDefine define = (DotnetDefine) defEnum.nextElement();
               if(define.isSet(this)) {
                   //add those that are set, and a delimiter
                   defines.append(define.getValue(this));
  @@ -768,6 +787,14 @@
       }
   
       /**
  +     * link or embed a resource
  +     * @param resource
  +     */
  +    public void addResource(DotnetResource resource) {
  +        resources.add(resource);
  +    }
  +
  +    /**
        *  test for a string containing something useful
        *
        *@param  s  string in
  @@ -810,6 +837,7 @@
           return "**/*." + getFileExtension();
       }
   
  +
       /**
        *  do the work by building the command line and then calling it
        *
  @@ -821,8 +849,13 @@
           NetCommand command = createNetCommand();
           //fill in args
           fillInSharedParameters(command);
  +        addResources(command);
           addCompilerSpecificOptions(command);
  -        addFilesAndExecute(command);
  +        int referencesOutOfDate=addReferenceFilesets(command,
  +                getOutputFileTimestamp());
  +        //if the refs are out of date, force a build.
  +        boolean forceBuild= referencesOutOfDate > 0;
  +        addFilesAndExecute(command, forceBuild);
   
       }
   
  @@ -870,6 +903,66 @@
       }
   
       /**
  +     * for every resource declared, we get the (language specific)
  +     * resource setting
  +     */
  +    protected void addResources(NetCommand command) {
  +        Enumeration e=resources.elements();
  +        while (e.hasMoreElements()) {
  +            DotnetResource resource = (DotnetResource) e.nextElement();
  +            command.addArgument(createResourceParameter(resource));
  +        }
  +    }
  +
  +    /**
  +     * from a resource, get the
  +     * @param resource
  +     * @return a string containing the resource param, or a null string
  +     * to conditionally exclude a resource.
  +     */
  +    protected abstract String createResourceParameter(DotnetResource resource);
  +
  +
  +    /**
  +     * run through the list of reference files and add them to the command
  +     * @param outputTimestamp timestamp to compare against
  +     * @return number of files out of date
  +     */
  +
  +    protected int addReferenceFilesets(NetCommand command, long outputTimestamp) {
  +        int filesOutOfDate = 0;
  +        Hashtable filesToBuild=new Hashtable();
  +        for (int i = 0; i < referenceFilesets.size(); i++) {
  +            FileSet fs = (FileSet) referenceFilesets.elementAt(i);
  +            filesOutOfDate += command.scanOneFileset(
  +                    fs.getDirectoryScanner(getProject()),
  +                    filesToBuild,
  +                    outputTimestamp);
  +        }
  +        //bail out early if there were no files
  +        if(filesToBuild.size()==0) {
  +            return 0;
  +        }
  +        StringBuffer referenceList= new StringBuffer(REFERENCE_OPTION);
  +        //now scan the hashtable and add the files
  +        Enumeration files = filesToBuild.elements();
  +        while (files.hasMoreElements()) {
  +            File file = (File) files.nextElement();
  +            if(isFileManagedBinary(file)) {
  +                referenceList.append(file.toString());
  +                referenceList.append(getReferenceDelimiter());
  +            } else {
  +                log("ignoring "+file+" as it is not a managed executable",
  +                        Project.MSG_VERBOSE);
  +            }
  +
  +        }
  +        //add it all to an argument
  +        command.addArgument(referenceList.toString());
  +        return filesOutOfDate;
  +    }
  +
  +    /**
        * create our helper command
        * @return a command prefilled with the exe name and task name
        */
  @@ -892,6 +985,19 @@
           return ";";
       }
   
  +
  +    /**
  +     * test for a file being managed or not
  +     * @return true if we think this is a managed executable, and thus OK
  +     * for linking
  +     * @todo look at the PE header of the exe and see if it is managed or not.
  +     */
  +    protected static boolean isFileManagedBinary(File file) {
  +        String filename= file.toString().toLowerCase();
  +        return filename.endsWith(".exe") || filename.endsWith(".dll")
  +                || filename.endsWith(".netmodule");
  +    }
  +
       /**
        * Target types to build.
        * valid build types are exe|library|module|winexe
  @@ -904,69 +1010,6 @@
                   "module",
                   "winexe"
               };
  -        }
  -    }
  -
  -    /**
  -     * definitions can be conditional. What .NET conditions can not be
  -     * is in any state other than defined and undefined; you cannot give
  -     * a definition a value.
  -     */
  -    public static class Define {
  -        private String name;
  -        private String condition;
  -
  -        public String getCondition() {
  -            return condition;
  -        }
  -
  -        /**
  -         * the name of a property which must be defined for
  -         * the definition to be set. Optional.
  -         * @param condition
  -         */
  -        public void setCondition(String condition) {
  -            this.condition = condition;
  -        }
  -
  -        public String getName() {
  -            return name;
  -        }
  -
  -        /**
  -         * the name of the definition. Required.
  -         * @param name
  -         */
  -        public void setName(String name) {
  -            this.name = name;
  -        }
  -
  -        /**
  -         * get the value of this definition. Will be null if a condition
  -         * was declared and not met
  -         * @param owner owning task
  -         * @return
  -         * @throws BuildException
  -         */
  -        public String getValue(Task owner) throws BuildException {
  -            if(name==null) {
  -                throw new BuildException("No name provided for the define element",
  -                    owner.getLocation());
  -            }
  -            if(!isSet(owner)) {
  -                return null;
  -            }
  -            return name;
  -        }
  -
  -        /**
  -         * test for a define being set
  -         * @param owner
  -         * @return true if there was no condition, or it is met
  -         */
  -        public boolean isSet(Task owner) {
  -            return condition==null
  -            || owner.getProject().getProperty(condition) != null;
           }
       }
   
  
  
  
  1.27      +30 -3     ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java
  
  Index: Ilasm.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- Ilasm.java	10 Mar 2003 08:02:24 -0000	1.26
  +++ Ilasm.java	11 Mar 2003 06:07:37 -0000	1.27
  @@ -61,10 +61,13 @@
   
   
   import java.io.File;
  +import java.util.Vector;
  +
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.types.EnumeratedAttribute;
  +import org.apache.tools.ant.types.FileSet;
   import org.apache.tools.ant.taskdefs.MatchingTask;
   
   /**
  @@ -86,8 +89,9 @@
    *  </b> and <b>excludes="broken.il"</b> can be used to control the files
pulled
    *  in. You can also use nested &lt;src&gt filesets to refer to source.
    *
  - *@author     Steve Loughran steve_l@iseran.com
  - *@version    0.6
  + * @author     Steve Loughran steve_l@iseran.com
  + * @version    0.6
  + * @ant.task    name="ilasm" category="dotnet"
    */
   
   public class Ilasm
  @@ -158,6 +162,10 @@
        *  any extra command options?
        */
       protected String extraOptions;
  +    /**
  +     * filesets of references
  +     */
  +    protected Vector referenceFilesets =new Vector();
   
   
       /**
  @@ -471,7 +479,7 @@
   
           NetCommand command = buildIlasmCommand();
   
  -        addFilesAndExecute(command);
  +        addFilesAndExecute(command, false);
   
       }
       // end execute
  @@ -502,6 +510,25 @@
           return command;
       }
   
  +    /**
  +     * add a new reference fileset to the compilation
  +     * @param reference
  +     */
  +    public void addReference(FileSet reference) {
  +        referenceFilesets.add(reference);
  +    }
  +
  +    /**
  +     * test for a file being managed or not
  +     * @return true if we think this is a managed executable, and thus OK
  +     * for linking
  +     * @todo look at the PE header of the exe and see if it is managed or not.
  +     */
  +    protected static boolean isFileManagedBinary(File file) {
  +        String filename= file.toString().toLowerCase();
  +        return filename.endsWith(".exe") || filename.endsWith(".dll")
  +                || filename.endsWith(".netmodule");
  +    }
   
   
       /**
  
  
  
  1.20      +2 -3      ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java
  
  Index: NetCommand.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- NetCommand.java	10 Mar 2003 10:11:19 -0000	1.19
  +++ NetCommand.java	11 Mar 2003 06:07:37 -0000	1.20
  @@ -281,14 +281,13 @@
           for (int i = 0; i < dependencies.length; i++) {
               File targetFile = new File(base, dependencies[i]);
               if (filesToBuild.get(targetFile) == null) {
  -                owner.log(targetFile.toString(), Project.MSG_VERBOSE);
                   filesToBuild.put(targetFile, targetFile);
                   if (targetFile.lastModified() > outputTimestamp) {
                       filesOutOfDate++;
  -                    owner.log("Source file " + targetFile.toString() + " is out of date",
  +                    owner.log(targetFile.toString() + " is out of date",
                               Project.MSG_VERBOSE);
                   } else {
  -                    owner.log("Source file " + targetFile.toString() + " is up to date",
  +                    owner.log(targetFile.toString(),
                               Project.MSG_VERBOSE);
                   }
               }
  
  
  
  1.3       +11 -0     ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/VisualBasicCompile.java
  
  Index: VisualBasicCompile.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/VisualBasicCompile.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- VisualBasicCompile.java	10 Feb 2003 14:13:48 -0000	1.2
  +++ VisualBasicCompile.java	11 Mar 2003 06:07:37 -0000	1.3
  @@ -68,6 +68,7 @@
    *
    * @author Brian Felder bfelder@providence.org
    * @author Steve Loughran
  + * @ant.task    name="vbc" category="dotnet"
    */
   
   public class VisualBasicCompile extends DotnetCompile {
  @@ -336,6 +337,16 @@
        */
       public String getFileExtension() {
           return "vb";
  +    }
  +
  +    /**
  +     * from a resource, get the resource param
  +     * @param resource
  +     * @return a string containing the resource param, or a null string
  +     * to conditionally exclude a resource.
  +     */
  +    protected String createResourceParameter(DotnetResource resource) {
  +        return resource.getVbStyleParameter();
       }
   
       /**
  
  
  
  1.1                  ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetDefine.java
  
  Index: DotnetDefine.java
  ===================================================================
  /*
   *  The Apache Software License, Version 1.1
   *
   *  Copyright (c) 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", "Ant", 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.tools.ant.taskdefs.optional.dotnet;
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Task;
  import org.apache.tools.ant.Project;
  
  /**
   * definitions can be conditional. What .NET conditions can not be
   * is in any state other than defined and undefined; you cannot give
   * a definition a value.
   */
  public class DotnetDefine {
      private String name;
      private String ifCond;
      private String unlessCond;
  
  
      /**
       * the name of a property which must be defined for
       * the definition to be set. Optional.
       * @param condition
       */
      public void setIf(String condition) {
          this.ifCond = condition;
      }
  
      /**
       * the name of a property which must be undefined for
       * the definition to be set. Optional.
       * @param condition
       */
      public void setUnless(String condition) {
          this.unlessCond = condition;
      }
  
      public String getName() {
          return name;
      }
  
      /**
       * the name of the definition. Required.
       * @param name
       */
      public void setName(String name) {
          this.name = name;
      }
  
      /**
       * get the value of this definition. Will be null if a condition
       * was declared and not met
       * @param owner owning task
       * @return
       * @throws BuildException
       */
      public String getValue(Task owner) throws BuildException {
          if(name==null) {
              throw new BuildException("No name provided for the define element",
                  owner.getLocation());
          }
          if(!isSet(owner)) {
              return null;
          }
          return name;
      }
  
  
      /**
       * logic taken from patternset
       * @param owner
       * @return true if the condition is valid
       */
      public boolean isSet(Task owner) {
          Project p=owner.getProject();
          if (ifCond != null && p.getProperty(ifCond) == null) {
              return false;
          } else if (unlessCond != null && p.getProperty(unlessCond) != null) {
              return false;
          }
          return true;
      }
  }
  
  
  
  1.1                  ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetResource.java
  
  Index: DotnetResource.java
  ===================================================================
  /*
  *  The Apache Software License, Version 1.1
  *
  *  Copyright (c) 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", "Ant", 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.tools.ant.taskdefs.optional.dotnet;
  
  import org.apache.tools.ant.BuildException;
  
  import java.io.File;
  
  /**
   * class used by DotnetCompile to name resources, could be upgraded to a datatype
   * in the distant future.
   * a resource maps to /res:file,name
   */
  public class DotnetResource {
  
  
      /**
       * name of resource
       */
      private File file;
  
      /**
       * embed (default) or link the resource
       */
      private boolean embed = true;
  
      /**
       * this is used in VBC and JSC
       */
      private Boolean isPublic = null;
  
      /**
       * name of the object
       */
      private String name = null;
  
      public boolean isEmbed() {
          return embed;
      }
  
      /**
       * embed the resource in the assembly (default, true) or just link to it.
       * @param embed
       */
      public void setEmbed(boolean embed) {
          this.embed = embed;
      }
  
      public File getFile() {
          return file;
      }
  
      /**
       * name the resource
       * @param file
       */
      public void setFile(File file) {
          this.file = file;
      }
  
      public Boolean getPublic() {
          return isPublic;
      }
  
      /**
       * VB and J# only: is a resource public or not?
       * @param aPublic
       */
      public void setPublic(Boolean aPublic) {
          isPublic = aPublic;
      }
  
      public String getName() {
          return name;
      }
  
      /**
       * should the resource have a name?
       * @param name
       */
      public void setName(String name) {
          this.name = name;
      }
  
      /**
       * build the C# style parameter (which has no public/private option)
       * @return
       */
      public String getCSharpStyleParameter() {
          StringBuffer buffer = new StringBuffer();
          buffer.append(isEmbed() ? "/resource" : "/linkresource");
          buffer.append(':');
          buffer.append(getFile().toString());
          if (getName() != null) {
              buffer.append(',');
              buffer.append(getName());
          }
          if (getPublic() != null) {
              throw new BuildException("This compiler does not support the "
                      + "public/private option.");
          }
          return buffer.toString();
      }
  
      /**
       * get the style of param used by VB and javascript
       * @return
       */
      public String getVbStyleParameter() {
          StringBuffer buffer = new StringBuffer();
          buffer.append(isEmbed() ? "/resource" : "/linkresource");
          buffer.append(':');
          buffer.append(getFile().toString());
          if (getName() != null) {
              buffer.append(',');
              buffer.append(getName());
              if (getPublic() != null) {
                  buffer.append(',');
                  buffer.append(getPublic().booleanValue()
                          ? "public" : "private");
  
              }
          } else if (getPublic() != null) {
              throw new BuildException("You cannot have a public or private "
                      + "option without naming the resource");
          }
          return buffer.toString();
      }
  }
  
  
  
  1.1                  ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/JSharp.java
  
  Index: JSharp.java
  ===================================================================
  /*
   *  The Apache Software License, Version 1.1
   *
   *  Copyright (c) 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", "Ant", 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.tools.ant.taskdefs.optional.dotnet;
  
  import org.apache.tools.ant.BuildException;
  
  
  /**
   * Compile J# source down to a managed .NET application.
   * J# is not Java. But it is the language closest to Java in the .NET framework.
   * This task compiles jsharp source (assumes a .jsl extension, incidentally), and
   * generates a .NET managed exe or dll.
   * See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vjsharp/html/vjoriMicrosoftVisualJ.asp
   * for vjc command options in glory detail.
   * @author Steve Loughran
   * @since ant1.6
   * @ant.task    name="jsharp" category="dotnet"
   */
  public class JSharp extends DotnetCompile {
  
      /**
       * hex base address
       */
      String baseAddress;
  
      /** /x option to disable J++ and J# lang extensions
       *
       */
      boolean pureJava = true;
  
      /**
       * whether to make package scoped stuff public or assembly scoped
       */
      boolean secureScoping = false;
  
  
      public void setBaseAddress(String baseAddress) {
          this.baseAddress = baseAddress;
      }
  
      /**
       * do we want pure java (default, true) or corrupted J#?
       * @param pureJava
       */
      public void setPureJava(boolean pureJava) {
          this.pureJava = pureJava;
      }
  
      /**
       * Make package scoped code visible to the current assembly only (default: false)
       * .NET does not have package scoping. Instead it has assembly, private and public.
       * By default, package content is public to all.
       * @param secureScoping
       */
      public void setSecureScoping(boolean secureScoping) {
          this.secureScoping = secureScoping;
      }
  
      /**
       * Get the delimiter that the compiler uses between references.
       * For example, c# will return ";"; VB.NET will return ","
       * @return The string delimiter for the reference string.
       */
      public String getReferenceDelimiter() {
          return ";";
      }
  
      /**
       * Get the name of the compiler executable.
       * @return The name of the compiler executable.
       */
      public String getCompilerExeName() {
          return "vjc";
      }
  
      /**
       * Get the extension of filenames to compile.
       * @return The string extension of files to compile.
       */
      public String getFileExtension() {
          return ".jsl";
      }
  
      /**
       * add jvc specific commands
       * @param command
       */
      protected void addCompilerSpecificOptions(NetCommand command) {
          if (pureJava) {
              command.addArgument("/x");
          }
          if (secureScoping) {
              command.addArgument("/securescoping");
          }
      }
  
      /**
       * from a resource, get the resource param
       * @param resource
       * @return a string containing the resource param, or a null string
       * to conditionally exclude a resource.
       */
      protected String createResourceParameter(DotnetResource resource) {
          return resource.getCSharpStyleParameter();
      }
  
      /**
       * validation code
       * @throws  org.apache.tools.ant.BuildException  if validation failed
       */
      protected void validate()
              throws BuildException {
          super.validate();
          if (getDestFile() == null) {
              throw new BuildException("DestFile was not specified");
          }
      }
  }
  
  
  

Mime
View raw message