Then I add <reference> fileset support into vbc, jsharp and csc, including inside the dependency checking. resources still need dependency checking, and testing. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274222 13f79535-47bb-0310-9956-ffa450edef68master
@@ -449,5 +449,15 @@ public class CSharp extends DotnetCompile { | |||
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(); | |||
} | |||
} | |||
@@ -76,9 +76,10 @@ public class DotnetBaseMatchingTask extends MatchingTask { | |||
*/ | |||
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 @@ public class DotnetBaseMatchingTask extends MatchingTask { | |||
* 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 @@ public class DotnetBaseMatchingTask extends MatchingTask { | |||
//add the files to the command | |||
addFilesToCommand(filesToBuild, command); | |||
//now run the command of exe + settings + files | |||
if (filesOutOfDate > 0) { | |||
command.runCommand(); | |||
@@ -210,4 +212,5 @@ public class DotnetBaseMatchingTask extends MatchingTask { | |||
} | |||
} |
@@ -152,6 +152,10 @@ public abstract class DotnetCompile | |||
*/ | |||
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 @@ public abstract class DotnetCompile | |||
* 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 @@ public abstract class DotnetCompile | |||
"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 @@ public abstract class DotnetCompile | |||
* list of extra modules to refer to | |||
*/ | |||
protected String additionalModules; | |||
/** | |||
* filesets of references | |||
*/ | |||
protected Vector referenceFilesets =new Vector(); | |||
/** | |||
@@ -278,7 +288,7 @@ public abstract class DotnetCompile | |||
protected String getReferencesParameter() { | |||
//bail on no references | |||
if (notEmpty(references)) { | |||
return "/reference:" + references; | |||
return REFERENCE_OPTION + references; | |||
} else { | |||
return null; | |||
} | |||
@@ -298,6 +308,15 @@ public abstract class DotnetCompile | |||
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 @@ public abstract class DotnetCompile | |||
return null; | |||
} | |||
StringBuffer s = new StringBuffer("/reference:"); | |||
StringBuffer s = new StringBuffer(REFERENCE_OPTION); | |||
s.append(refpath); | |||
return new String(s); | |||
} | |||
@@ -681,7 +700,7 @@ public abstract class DotnetCompile | |||
* 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 @@ public abstract class DotnetCompile | |||
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)); | |||
@@ -767,6 +786,14 @@ public abstract class DotnetCompile | |||
return failOnError; | |||
} | |||
/** | |||
* link or embed a resource | |||
* @param resource | |||
*/ | |||
public void addResource(DotnetResource resource) { | |||
resources.add(resource); | |||
} | |||
/** | |||
* test for a string containing something useful | |||
* | |||
@@ -810,6 +837,7 @@ public abstract class DotnetCompile | |||
return "**/*." + getFileExtension(); | |||
} | |||
/** | |||
* do the work by building the command line and then calling it | |||
* | |||
@@ -821,8 +849,13 @@ public abstract class DotnetCompile | |||
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); | |||
} | |||
@@ -869,6 +902,66 @@ public abstract class DotnetCompile | |||
command.addArgument(getWin32ResParameter()); | |||
} | |||
/** | |||
* 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 @@ public abstract class DotnetCompile | |||
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 | |||
@@ -907,69 +1013,6 @@ public abstract class DotnetCompile | |||
} | |||
} | |||
/** | |||
* 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; | |||
} | |||
} | |||
} | |||
@@ -0,0 +1,135 @@ | |||
/* | |||
* 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; | |||
} | |||
} |
@@ -0,0 +1,181 @@ | |||
/* | |||
* 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(); | |||
} | |||
} |
@@ -61,10 +61,13 @@ package org.apache.tools.ant.taskdefs.optional.dotnet; | |||
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 @@ import org.apache.tools.ant.taskdefs.MatchingTask; | |||
* </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. | |||
* | |||
*@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 @@ public class Ilasm | |||
* any extra command options? | |||
*/ | |||
protected String extraOptions; | |||
/** | |||
* filesets of references | |||
*/ | |||
protected Vector referenceFilesets =new Vector(); | |||
/** | |||
@@ -471,7 +479,7 @@ public class Ilasm | |||
NetCommand command = buildIlasmCommand(); | |||
addFilesAndExecute(command); | |||
addFilesAndExecute(command, false); | |||
} | |||
// end execute | |||
@@ -502,6 +510,25 @@ public class Ilasm | |||
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"); | |||
} | |||
/** | |||
@@ -0,0 +1,171 @@ | |||
/* | |||
* 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"); | |||
} | |||
} | |||
} |
@@ -281,14 +281,13 @@ public class NetCommand { | |||
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); | |||
} | |||
} | |||
@@ -68,6 +68,7 @@ import org.apache.tools.ant.BuildException; | |||
* | |||
* @author Brian Felder bfelder@providence.org | |||
* @author Steve Loughran | |||
* @ant.task name="vbc" category="dotnet" | |||
*/ | |||
public class VisualBasicCompile extends DotnetCompile { | |||
@@ -338,6 +339,16 @@ public class VisualBasicCompile extends DotnetCompile { | |||
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(); | |||
} | |||
/** | |||
* Get the name of the compiler executable. | |||
* @return The name of the compiler executable. | |||