diff --git a/src/etc/testcases/taskdefs/optional/dotnet.xml b/src/etc/testcases/taskdefs/optional/dotnet.xml
index f888003a0..f494cfba1 100644
--- a/src/etc/testcases/taskdefs/optional/dotnet.xml
+++ b/src/etc/testcases/taskdefs/optional/dotnet.xml
@@ -97,15 +97,15 @@
-
+
-
+
-
-
+
+
@@ -164,6 +164,56 @@
+
+
+
+
+
+
+
+
+ No app ${testCSC.exe} created
+
+
+
+
+
+
+
+
+ No app ${testCSC.exe} created
+
+
+
+
+
+
+
+
+
+
+ No app ${testCSC.exe} created
+
+
+
+
+
+
@@ -216,6 +266,18 @@
No file ${testCSC.dll} created
+
+
+
+
+
+
+ No file ${testCSC2.dll} created
@@ -245,12 +307,14 @@
>
+
No app ${testCscReferences.exe} created
+
@@ -280,7 +344,7 @@
depends="testILASM-Mono,testILASM-MS"
if="ilasm.found"/>
-
@@ -294,13 +358,13 @@
No app ${testILASM.exe} created
-
-
@@ -371,7 +435,7 @@
No app ${testCSCresponseFile.exe} created
-
+
diff --git a/src/etc/testcases/taskdefs/optional/dotnet/example.cs b/src/etc/testcases/taskdefs/optional/dotnet/example.cs
index d02343728..59323da69 100644
--- a/src/etc/testcases/taskdefs/optional/dotnet/example.cs
+++ b/src/etc/testcases/taskdefs/optional/dotnet/example.cs
@@ -14,12 +14,13 @@
* limitations under the License.
*
*/
-
+
using System;
public class Example {
public static void Main(String[] args) {
Example2.echo();
+ Example3.echo();
}
}
diff --git a/src/etc/testcases/taskdefs/optional/dotnet/example3.cs b/src/etc/testcases/taskdefs/optional/dotnet/example3.cs
new file mode 100644
index 000000000..a826f7587
--- /dev/null
+++ b/src/etc/testcases/taskdefs/optional/dotnet/example3.cs
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+
+/**
+ * this is just here to create confusion
+ */
+public class Example3 {
+
+ public static void echo() {
+ Console.WriteLine("hello, I look like Java, but I'm really .NET");
+ }
+
+}
diff --git a/src/etc/testcases/taskdefs/optional/dotnet/res.resources b/src/etc/testcases/taskdefs/optional/dotnet/res.resources
new file mode 100644
index 000000000..20e265d8a
Binary files /dev/null and b/src/etc/testcases/taskdefs/optional/dotnet/res.resources differ
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java
index 5d6f4a30e..7280a7cae 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java
@@ -386,8 +386,8 @@ public class CSharp extends DotnetCompile {
* @return a string containing the resource param, or a null string
* to conditionally exclude a resource.
*/
- protected String createResourceParameter(DotnetResource resource) {
- return resource.getCSharpStyleParameter();
+ protected void createResourceParameter(NetCommand command, DotnetResource resource) {
+ resource.getParameters(getProject(), command, true);
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java
index 3362a54f3..c63520326 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java
@@ -220,7 +220,7 @@ public abstract class DotnetCompile
//bail on no references
if (notEmpty(references)) {
if (isWindows) {
- return REFERENCE_OPTION + '\"' + references + '\"';
+ return '\"' + REFERENCE_OPTION + references + '\"';
} else {
return REFERENCE_OPTION + references;
}
@@ -871,7 +871,7 @@ public abstract class DotnetCompile
Enumeration e = resources.elements();
while (e.hasMoreElements()) {
DotnetResource resource = (DotnetResource) e.nextElement();
- command.addArgument(createResourceParameter(resource));
+ createResourceParameter(command, resource);
}
}
@@ -881,7 +881,7 @@ public abstract class DotnetCompile
* @return a string containing the resource param, or a null string
* to conditionally exclude a resource.
*/
- protected abstract String createResourceParameter(DotnetResource resource);
+ protected abstract void createResourceParameter(NetCommand command, DotnetResource resource);
/**
@@ -904,37 +904,20 @@ public abstract class DotnetCompile
if (filesToBuild.size() == 0) {
return 0;
}
- StringBuffer referenceList = new StringBuffer(REFERENCE_OPTION);
//now scan the hashtable and add the files
Enumeration files = filesToBuild.elements();
- boolean firstEntry = true;
while (files.hasMoreElements()) {
File file = (File) files.nextElement();
if (isFileManagedBinary(file)) {
- if (!firstEntry) {
- referenceList.append(getReferenceDelimiter());
- } else if (isWindows) {
- referenceList.append('\"');
- }
- referenceList.append(file.toString());
- firstEntry = false;
+ if (isWindows) command.addArgument('"'+REFERENCE_OPTION+file.toString()+'"');
+ else command.addArgument(REFERENCE_OPTION+file.toString());
} else {
log("ignoring " + file + " as it is not a managed executable",
Project.MSG_VERBOSE);
}
}
- // hack: This means we've added at least one reference that's
- // a managed binary
- if (!firstEntry) {
- //add it all to an argument
- if (isWindows) {
- command.addArgument(referenceList.toString() + '\"');
- } else {
- command.addArgument(referenceList.toString());
- }
- }
-
+
return filesOutOfDate;
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetResource.java b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetResource.java
index d8f6ac412..e103beb4b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetResource.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetResource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2004 The Apache Software Foundation
+ * Copyright 2000-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,10 @@ package org.apache.tools.ant.taskdefs.optional.dotnet;
import org.apache.tools.ant.BuildException;
import java.io.File;
+import java.util.ArrayList;
+import org.apache.tools.ant.types.FileSet;
+import java.util.Iterator;
+import org.apache.tools.ant.*;
/**
* class used by DotnetCompile to name resources, could be upgraded to a datatype
@@ -48,6 +52,16 @@ public class DotnetResource {
*/
private String name = null;
+ /**
+ * A list of filesets with resources.
+ */
+ private ArrayList fileSets=new ArrayList();
+
+ /**
+ * a namespace to be used with
+ */
+ private String namespace = null;
+
public boolean isEmbed() {
return embed;
}
@@ -96,48 +110,104 @@ public class DotnetResource {
this.name = name;
}
+ /**
+ * Filesets root namespace. The value always ends with '.' .
+ * @return String namespace name
+ */
+ public String getNamespace() {
+ return namespace;
+ }
+
+ /**
+ * Sets filesets root namespace.
+ * @param namespace String root namespace
+ */
+ public void setNamespace(String namespace) {
+ if (namespace==null) this.namespace=null;
+ else this.namespace=(namespace.length()==0 || namespace.endsWith(".") ? namespace : namespace+'.');
+ }
+
+ private void checkParameters() {
+ if (hasFilesets()) {
+ if (getName()!=null) throw new BuildException(
+ "Cannot use attribute with filesets");
+ if (getFile()!=null) throw new BuildException(
+ "Cannot use attribute with filesets");
+ }
+ else {
+ if (getNamespace()!=null) throw new BuildException(
+ "Cannot use attribute without filesets");
+ }
+ }
/**
* build the C# style parameter (which has no public/private option)
* @return the built C# style parameter
*/
- 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());
+ public void getParameters(Project p, NetCommand command, boolean csharpStyle) {
+ checkParameters();
+ if (hasFilesets()) {
+ for (Iterator listIter=fileSets.iterator(); listIter.hasNext();) {
+ FileSet fs=(FileSet)listIter.next();;
+ String baseDirectory=fs.getDir(p).toString();
+ String namespace=getNamespace(); // ends with '.' or null
+ DirectoryScanner ds = fs.getDirectoryScanner(p);
+ String[] files = ds.getIncludedFiles();
+ for (int i=0; i node has embedded
+ * @return boolean
+ */
+ public boolean hasFilesets() {
+ return fileSets.size()>0;
+ }
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/JSharp.java b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/JSharp.java
index c8153292d..5da6f2eeb 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/JSharp.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/JSharp.java
@@ -119,8 +119,8 @@ public class JSharp extends DotnetCompile {
* @return a string containing the resource param, or a null string
* to conditionally exclude a resource.
*/
- protected String createResourceParameter(DotnetResource resource) {
- return resource.getCSharpStyleParameter();
+ protected void createResourceParameter(NetCommand command, DotnetResource resource) {
+ resource.getParameters(getProject(), command, true);
}
/**
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/VisualBasicCompile.java b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/VisualBasicCompile.java
index ff2230629..e9704a2eb 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/VisualBasicCompile.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/VisualBasicCompile.java
@@ -352,8 +352,8 @@ public class VisualBasicCompile extends DotnetCompile {
* @return a string containing the resource param, or a null string
* to conditionally exclude a resource.
*/
- protected String createResourceParameter(DotnetResource resource) {
- return resource.getVbStyleParameter();
+ protected void createResourceParameter(NetCommand command, DotnetResource resource) {
+ resource.getParameters(getProject(), command, false);
}
/**
diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/DotnetTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/DotnetTest.java
index 32739be43..b881bf43d 100644
--- a/src/testcases/org/apache/tools/ant/taskdefs/optional/DotnetTest.java
+++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/DotnetTest.java
@@ -90,6 +90,13 @@ public class DotnetTest extends BuildFileTest {
executeTarget("testCscReferences");
}
+ /**
+ * A unit test for JUnit
+ */
+ public void testCscResources() throws Exception {
+ executeTarget("testCSCResources");
+ }
+
/**
* test we can assemble
*/