git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275328 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -75,81 +75,57 @@ import java.io.File; | |||||
| /** | /** | ||||
| * Compiles C# source into executables or modules. | * Compiles C# source into executables or modules. | ||||
| * | * | ||||
| * The task will only work on win2K until other platforms support | |||||
| * csc.exe or an equivalent. CSC.exe must be on the execute path too. <p> | |||||
| * | |||||
| * All parameters are optional: <csc/> should suffice to produce a debug | |||||
| * build of all *.cs files. References to external files do require explicit | |||||
| * enumeration, so are one of the first attributes to consider adding. <p> | |||||
| * | |||||
| * csc.exe must be on the execute path, unless another executable | |||||
| * or the full path to that executable is specified in the <tt>executable</tt> | |||||
| * parameter | |||||
| * <p> | |||||
| * All parameters are optional: <csc/> should suffice to produce a debug | |||||
| * build of all *.cs files. However, naming an <tt>destFile</tt>stops the | |||||
| * csc compiler from choosing an output name from random, and | |||||
| * allows the dependency checker to determine if the file is out of date. | |||||
| * <p> | |||||
| * The task is a directory based task, so attributes like <b>includes="*.cs" | * The task is a directory based task, so attributes like <b>includes="*.cs" | ||||
| * </b> and <b>excludes="broken.cs"</b> can be used to control the files pulled | * </b> and <b>excludes="broken.cs"</b> can be used to control the files pulled | ||||
| * in. By default, all *.cs files from the project folder down are included in | * in. By default, all *.cs files from the project folder down are included in | ||||
| * the command. When this happens the output file -if not specified- is taken | * the command. When this happens the output file -if not specified- is taken | ||||
| * as the first file in the list, which may be somewhat hard to control. | * as the first file in the list, which may be somewhat hard to control. | ||||
| * Specifying the output file with <b>'outfile'</b> seems prudent. <p> | |||||
| * | |||||
| * <p> | |||||
| * | |||||
| * TODO | |||||
| * <ol> | |||||
| * <li> is incremental build still broken in beta-1? | |||||
| * <li> is Win32Icon broken? | |||||
| * <li> all the missing options | |||||
| * </ol> | |||||
| * <p> | |||||
| * | |||||
| * History | |||||
| * <Table> | |||||
| * | |||||
| * <tr> | |||||
| * | |||||
| * <td> | |||||
| * 0.3 | |||||
| * </td> | |||||
| * | |||||
| * <td> | |||||
| * Beta 1 edition | |||||
| * </td> | |||||
| * | |||||
| * <td> | |||||
| * To avoid having to remember which assemblies to include, the task | |||||
| * automatically refers to the main dotnet libraries in Beta1. | |||||
| * </tr> | |||||
| * | |||||
| * <tr> | |||||
| * | |||||
| * <td> | |||||
| * 0.2 | |||||
| * </td> | |||||
| * | |||||
| * <td> | |||||
| * Slightly different | |||||
| * </td> | |||||
| * | |||||
| * <td> | |||||
| * Split command execution to a separate class; | |||||
| * </tr> | |||||
| * | |||||
| * <tr> | |||||
| * Specifying the output file with <tt>destFile</tt> seems prudent. <p> | |||||
| * | * | ||||
| * <td> | |||||
| * 0.1 | |||||
| * </td> | |||||
| * <p> | |||||
| * For more complex source trees, nested <tt>src</tt> elemements can be | |||||
| * supplied. When such an element is present, the implicit fileset is ignored. | |||||
| * This makes sense, when you think about it :) | |||||
| * <p> | |||||
| * | * | ||||
| * <td> | |||||
| * "I can't believe it's so rudimentary" | |||||
| * </td> | |||||
| * References to external files can be made through the references attribute, | |||||
| * or (since Ant1.6), via nested <reference> filesets. With the latter, | |||||
| * the timestamps of the references are also used in the dependency | |||||
| * checking algorithm. | |||||
| * <p> | |||||
| * | * | ||||
| * <td> | |||||
| * First pass; minimal builds only support; | |||||
| * </tr> | |||||
| * Example | |||||
| * | * | ||||
| * </table> | |||||
| * <pre><csc | |||||
| * optimize="true" | |||||
| * debug="false" | |||||
| * docFile="documentation.xml" | |||||
| * warnLevel="4" | |||||
| * unsafe="false" | |||||
| * targetType="exe" | |||||
| * incremental="false" | |||||
| * mainClass = "MainApp" | |||||
| * destFile="NetApp.exe" | |||||
| * > | |||||
| * <src dir="src" includes="*.cs" /> | |||||
| * <reference file="${testCSC.dll}" /> | |||||
| * <define name="RELEASE" /> | |||||
| * <define name="DEBUG" if="debug.property"/> | |||||
| * <define name="def3" unless="def3.property"/> | |||||
| * </csc> | |||||
| * </pre> | |||||
| * | * | ||||
| * | * | ||||
| * @author Steve Loughran steve_l@iseran.com | |||||
| * @version 0.5 | |||||
| * @author Steve Loughran | |||||
| * @ant.task name="csc" category="dotnet" | * @ant.task name="csc" category="dotnet" | ||||
| * @since Ant 1.3 | * @since Ant 1.3 | ||||
| */ | */ | ||||
| @@ -69,9 +69,11 @@ import org.apache.tools.ant.types.EnumeratedAttribute; | |||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| /** | /** | ||||
| * Assembles .NET Intermediate Language files. The task will only work | |||||
| * on win2K until other platforms support csc.exe or an equivalent. ilasm.exe | |||||
| * must be on the execute path too. <p> | |||||
| * Assembles .NET Intermediate Language files. | |||||
| * ilasm.exe must be on the execute path, unless another executable | |||||
| * or the full path to that executable is specified in the <tt>executable</tt> | |||||
| * parameter | |||||
| * <p> | |||||
| * | * | ||||
| * <p> | * <p> | ||||
| * | * | ||||
| @@ -86,9 +88,9 @@ import org.apache.tools.ant.types.FileSet; | |||||
| * The task is a directory based task, so attributes like <b>includes="*.il" | * The task is a directory based task, so attributes like <b>includes="*.il" | ||||
| * </b> and <b>excludes="broken.il"</b> can be used to control the files pulled | * </b> and <b>excludes="broken.il"</b> can be used to control the files pulled | ||||
| * in. You can also use nested <src> filesets to refer to source. | * in. You can also use nested <src> filesets to refer to source. | ||||
| * | |||||
| * @author Steve Loughran steve_l@iseran.com | |||||
| * @version 0.6 | |||||
| * <p> | |||||
| * | |||||
| * @author Steve Loughran | |||||
| * @ant.task name="ilasm" category="dotnet" | * @ant.task name="ilasm" category="dotnet" | ||||
| */ | */ | ||||
| @@ -56,6 +56,7 @@ package org.apache.tools.ant.taskdefs.optional.dotnet; | |||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.Project; | |||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import java.io.File; | import java.io.File; | ||||
| @@ -352,16 +353,26 @@ public class Ildasm extends Task { | |||||
| } | } | ||||
| /** | /** | ||||
| * | |||||
| * @return | |||||
| * Test for disassembly being needed; use existence and granularity | |||||
| * correct date stamps | |||||
| * @return true iff a rebuild is required. | |||||
| */ | */ | ||||
| private boolean isDisassemblyNeeded() { | private boolean isDisassemblyNeeded() { | ||||
| if (!destFile.exists()) { | if (!destFile.exists()) { | ||||
| log("Destination file does not exist: a build is required", | |||||
| Project.MSG_VERBOSE); | |||||
| return true; | return true; | ||||
| } | } | ||||
| long sourceTime = sourceFile.lastModified(); | long sourceTime = sourceFile.lastModified(); | ||||
| long destTime = destFile.lastModified(); | long destTime = destFile.lastModified(); | ||||
| return sourceTime > (destTime + FileUtils.newFileUtils().getFileTimestampGranularity()); | |||||
| if(sourceTime > (destTime + FileUtils.newFileUtils().getFileTimestampGranularity())) { | |||||
| log("Source file is newer than the dest file: a rebuild is required", | |||||
| Project.MSG_VERBOSE); | |||||
| return true; | |||||
| } else { | |||||
| log("The .il file is up to date", Project.MSG_VERBOSE); | |||||
| return false; | |||||
| } | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -370,6 +381,9 @@ public class Ildasm extends Task { | |||||
| */ | */ | ||||
| public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
| validate(); | validate(); | ||||
| if(!isDisassemblyNeeded()) { | |||||
| return; | |||||
| } | |||||
| NetCommand command = new NetCommand(this, "ildasm", executable); | NetCommand command = new NetCommand(this, "ildasm", executable); | ||||
| command.setFailOnError(true); | command.setFailOnError(true); | ||||
| //fill in args | //fill in args | ||||
| @@ -423,6 +437,7 @@ public class Ildasm extends Task { | |||||
| } catch (BuildException e) { | } catch (BuildException e) { | ||||
| //forcibly delete the output file in case of trouble | //forcibly delete the output file in case of trouble | ||||
| if (destFile.exists()) { | if (destFile.exists()) { | ||||
| log("Deleting destination file as it may be corrupt"); | |||||
| destFile.delete(); | destFile.delete(); | ||||
| } | } | ||||
| //then rethrow the exception | //then rethrow the exception | ||||
| @@ -57,16 +57,28 @@ package org.apache.tools.ant.taskdefs.optional.dotnet; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| import java.io.File; | import java.io.File; | ||||
| /** | /** | ||||
| * Wrapper to .NET's tlbimport; imports a tlb file to a NET assembly | |||||
| * Import a COM type library into the .NET framework. | |||||
| * <p> | |||||
| * | |||||
| * This task is a wrapper to .NET's tlbimport; it imports a tlb file to a NET assembly | |||||
| * by generating a binary assembly (.dll) that contains all the binding | * by generating a binary assembly (.dll) that contains all the binding | ||||
| * metadata. Uses date timestamps to minimise rebuilds. | |||||
| * metadata. It uses date timestamps to minimise rebuilds. | |||||
| * <p> | |||||
| * Example | |||||
| * <pre> | |||||
| * <importtypelib | |||||
| * srcfile="xerces.tlb" | |||||
| * destfile="xerces.dll" | |||||
| * namespace="Apache.Xerces"/> | |||||
| * </pre> | |||||
| * @since Ant 1.6 | * @since Ant 1.6 | ||||
| * @author steve loughran | * @author steve loughran | ||||
| * @ant.task name="ImportTypelib" category="dotnet" | |||||
| * @ant.task category="dotnet" | |||||
| */ | */ | ||||
| public class ImportTypelib extends Task { | public class ImportTypelib extends Task { | ||||
| @@ -162,7 +174,7 @@ public class ImportTypelib extends Task { | |||||
| throw new BuildException( | throw new BuildException( | ||||
| "destination file is a directory"); | "destination file is a directory"); | ||||
| } | } | ||||
| if (srcFile != null || !srcFile.exists()) { | |||||
| if (srcFile == null || !srcFile.exists()) { | |||||
| throw new BuildException( | throw new BuildException( | ||||
| "source file does not exist"); | "source file does not exist"); | ||||
| } | } | ||||
| @@ -175,6 +187,31 @@ public class ImportTypelib extends Task { | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Test for disassembly being needed; use existence and granularity | |||||
| * correct date stamps | |||||
| * @return true iff a rebuild is required. | |||||
| */ | |||||
| private boolean isExecuteNeeded() { | |||||
| if (!destFile.exists()) { | |||||
| log("Destination file does not exist: a build is required", | |||||
| Project.MSG_VERBOSE); | |||||
| return true; | |||||
| } | |||||
| long sourceTime = srcFile.lastModified(); | |||||
| long destTime = destFile.lastModified(); | |||||
| if (sourceTime > (destTime + FileUtils.newFileUtils().getFileTimestampGranularity())) { | |||||
| log("Source file is newer than the dest file: a rebuild is required", | |||||
| Project.MSG_VERBOSE); | |||||
| return true; | |||||
| } else { | |||||
| log("The output file is up to date", Project.MSG_VERBOSE); | |||||
| return false; | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * Create a typelib command | * Create a typelib command | ||||
| * @exception BuildException if something goes wrong with the build | * @exception BuildException if something goes wrong with the build | ||||
| @@ -185,9 +222,7 @@ public class ImportTypelib extends Task { | |||||
| + " to assembly " + destFile | + " to assembly " + destFile | ||||
| + " in namespace " + namespace, Project.MSG_VERBOSE); | + " in namespace " + namespace, Project.MSG_VERBOSE); | ||||
| //rebuild unless the dest file is newer than the source file | //rebuild unless the dest file is newer than the source file | ||||
| if (srcFile.exists() && destFile.exists() | |||||
| && srcFile.lastModified() <= destFile.lastModified()) { | |||||
| log("The typelib is up to date", Project.MSG_VERBOSE); | |||||
| if(!isExecuteNeeded()) { | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -205,5 +240,6 @@ public class ImportTypelib extends Task { | |||||
| command.addArgument("/unsafe"); | command.addArgument("/unsafe"); | ||||
| } | } | ||||
| command.addArgument(extraOptions); | command.addArgument(extraOptions); | ||||
| command.runCommand(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -60,14 +60,16 @@ import org.apache.tools.ant.BuildException; | |||||
| * Compile J# source down to a managed .NET application. | * Compile J# source down to a managed .NET application. | ||||
| * <p> | * <p> | ||||
| * J# is not Java. But it is the language closest to Java in the .NET framework. | * 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 | |||||
| * This task compiles jsharp source (.java files), and | |||||
| * generates a .NET managed exe or dll. | * generates a .NET managed exe or dll. | ||||
| * <p> | * <p> | ||||
| * See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vjsharp/html/vjoriMicrosoftVisualJ.asp | |||||
| * for vjc command options in glory detail. | |||||
| * | |||||
| * @see <A=ref="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vjsharp/html/vjoriMicrosoftVisualJ.asp"> | |||||
| * Visual J++ online documentation</a> | |||||
| * | |||||
| * @author Steve Loughran | * @author Steve Loughran | ||||
| * @since ant1.6 | * @since ant1.6 | ||||
| * @ant.task name="jsharpc" category="dotnet" | |||||
| * @ant.task category="dotnet" | |||||
| */ | */ | ||||
| public class JSharp extends DotnetCompile { | public class JSharp extends DotnetCompile { | ||||
| @@ -122,14 +124,12 @@ public class JSharp extends DotnetCompile { | |||||
| return ";"; | return ";"; | ||||
| } | } | ||||
| /** | /** | ||||
| * Get the extension of filenames to compile. | * Get the extension of filenames to compile. | ||||
| * @return The string extension of files to compile. | * @return The string extension of files to compile. | ||||
| */ | */ | ||||
| public String getFileExtension() { | public String getFileExtension() { | ||||
| return ".jsl"; | |||||
| return ".java"; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -59,13 +59,52 @@ import org.apache.tools.ant.BuildException; | |||||
| /** | /** | ||||
| * This task compiles Visual Basic.NET source into executables or modules. | * This task compiles Visual Basic.NET source into executables or modules. | ||||
| * The task will only work on win2K until other platforms support vbc.exe or | |||||
| * an equivalent. VBC.exe must be on the execute path, too. | |||||
| * The task requires vbc.exe on the execute path, unless it or an equivalent | |||||
| * program is specified in the <tt>executable</tt> parameter | |||||
| * | * | ||||
| * <p> | * <p> | ||||
| * All parameters are optional: <vbc/> should suffice to produce a debug | * All parameters are optional: <vbc/> should suffice to produce a debug | ||||
| * build of all *.vb files. | * build of all *.vb files. | ||||
| * | * | ||||
| * <p> | |||||
| * The task is a directory based task, so attributes like | |||||
| * <tt>includes="**\/*.vb"</tt> and | |||||
| * <tt>excludes="broken.vb"</tt> can be used to control | |||||
| * the files pulled in. By default, | |||||
| * all *.vb files from the project folder down are included in the command. | |||||
| * When this happens the destFile -if not specified- | |||||
| * is taken as the first file in the list, which may be somewhat hard to control. | |||||
| Specifying the output file with <tt>destfile</tt> is prudent. | |||||
| </p> | |||||
| <p> | |||||
| * Also, dependency checking only works if destfile is set. | |||||
| * | |||||
| * As with <csc> nested <tt>src</tt> filesets of source, | |||||
| * reference filesets, definitions and resources can be provided. | |||||
| * | |||||
| * <p> | |||||
| * Example | |||||
| * </p> | |||||
| * <pre><vbc | |||||
| * optimize="true" | |||||
| * debug="false" | |||||
| * warnLevel="4" | |||||
| * targetType="exe" | |||||
| * definitions="RELEASE" | |||||
| * excludes="src/unicode_class.vb" | |||||
| * mainClass = "MainApp" | |||||
| * destFile="NetApp.exe" | |||||
| * optionExplicit="true" | |||||
| * optionCompare="text" | |||||
| * references="System.Xml,System.Web.Xml" | |||||
| * > | |||||
| * <reference file="${testCSC.dll}" /> | |||||
| * <define name="RELEASE" /> | |||||
| * <define name="DEBUG" if="debug.property"/> | |||||
| * <define name="def3" unless="def2.property"/> | |||||
| * </vbc> | |||||
| </pre> | |||||
| * @author Brian Felder bfelder@providence.org | * @author Brian Felder bfelder@providence.org | ||||
| * @author Steve Loughran | * @author Steve Loughran | ||||
| * @ant.task name="vbc" category="dotnet" | * @ant.task name="vbc" category="dotnet" | ||||
| @@ -60,11 +60,23 @@ import org.apache.tools.ant.Task; | |||||
| /** | /** | ||||
| * Converts a WSDL file or URL resource into a .NET language. | * Converts a WSDL file or URL resource into a .NET language. | ||||
| * | * | ||||
| * Why add a wrapper to the MS WSDL tool? | |||||
| * So that you can verify that your web services, be they written with Axis or | |||||
| *anyone else's SOAP toolkit, work with .NET clients. | |||||
| * | |||||
| *This task is dependency aware when using a file as a source and destination; | |||||
| *so if you <get> the file (with <code>usetimestamp="true"</code>) then | |||||
| *you only rebuild stuff when the WSDL file is changed. Of course, | |||||
| *if the server generates a new timestamp every time you ask for the WSDL, | |||||
| *this is not enough...use the <filesmatch> <condition> to | |||||
| *to byte for byte comparison against a cached WSDL file then make | |||||
| *the target conditional on that test failing. | |||||
| * See "Creating an XML Web Service Proxy", "wsdl.exe" docs in | * See "Creating an XML Web Service Proxy", "wsdl.exe" docs in | ||||
| * the framework SDK documentation | * the framework SDK documentation | ||||
| * @author Steve Loughran | * @author Steve Loughran | ||||
| * @version 0.5 | * @version 0.5 | ||||
| * @ant.task name="wsdltodotnet" category="dotnet" | |||||
| * @ant.task category="dotnet" | |||||
| * @since Ant 1.5 | * @since Ant 1.5 | ||||
| */ | */ | ||||