stevel 2003/07/31 22:55:17
Modified: src/etc/testcases/taskdefs/optional dotnet.xml
src/main/org/apache/tools/ant/taskdefs/optional/dotnet
CSharp.java DotnetBaseMatchingTask.java
DotnetCompile.java JSharp.java
VisualBasicCompile.java
src/testcases/org/apache/tools/ant/taskdefs/optional
DotnetTest.java
Log:
add the ability to set the executable used in .net tasks. Why do this
(a) so you can refer to versions off the path (useful for multiple versions)
(b) so you can use other implementations than the windows one.
Specifically, Mono Csharp compiler, msc, apparently uses the same syntax as
csc if desired. We will have to test this... I suppose we could test Rotor too,
but I cant be bothered
Revision Changes Path
1.3 +20 -5 ant/src/etc/testcases/taskdefs/optional/dotnet.xml
Index: dotnet.xml
===================================================================
RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/optional/dotnet.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- dotnet.xml 11 Mar 2003 06:10:46 -0000 1.2
+++ dotnet.xml 1 Aug 2003 05:55:16 -0000 1.3
@@ -67,20 +67,35 @@
destFile="${testCSC.exe}"
targetType="exe"
>
- <src dir="${src.dir}" includes="**/*.cs"/>
</csc>
<available property="app.created" file="${testCSC.exe}"/>
<fail unless="app.created">No app ${testCSC.exe} created</fail>
<exec executable="${testCSC.exe}" failonerror="true" />
+ <delete file="${testCSC.exe}"/>
</target>
-
-
+
+ <target name="testCSCintrinsicFileset" depends="init">
+ <property name="testCSC.exe"
+ location="${build.dir}/ExampleCsc.exe"/>
+ <csc
+ destFile="${testCSC.exe}"
+ targetType="exe"
+ srcDir="."
+ >
+ </csc>
+ <available property="app.created" file="${testCSC.exe}"/>
+ <fail unless="app.created">No app ${testCSC.exe} created</fail>
+ <exec executable="${testCSC.exe}" failonerror="true"/>
+ <delete file="${testCSC.exe}"/>
+ </target>
+
<target name="testCSCdll" depends="init">
- <property name="testCSC.dll"
+ <property name="testCSC.dll"
location="${build.dir}/Example2.dll" />
<csc
destFile="${testCSC.dll}"
- targetType="library"
+ targetType="library"
+ executable="csc"
>
<src dir="${src.dir}" includes="example2.cs"/>
</csc>
1.35 +2 -8
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.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- CSharp.java 18 Jul 2003 14:21:22 -0000 1.34
+++ CSharp.java 1 Aug 2003 05:55:16 -0000 1.35
@@ -199,6 +199,7 @@
*/
public CSharp() {
+ clear();
}
/**
@@ -213,7 +214,7 @@
unsafe = false;
noconfig = false;
definitions = null;
-
+ setExecutable("csc");
}
@@ -426,13 +427,6 @@
return ";";
}
- /**
- * compiler is 'csc'
- * @return
- */
- public String getCompilerExeName() {
- return "csc";
- }
/**
* extension is '.cs'
1.6 +1 -1
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DotnetBaseMatchingTask.java 18 Jul 2003 14:21:22 -0000 1.5
+++ DotnetBaseMatchingTask.java 1 Aug 2003 05:55:16 -0000 1.6
@@ -137,7 +137,7 @@
= getSrcDir() != null || filesets.size() == 0;
if (scanImplicitFileset) {
//scan for an implicit fileset if there was a srcdir set
- //or there was no srcDir set but the @
+ //or there was no srcDir set but there was no contained classes
if (getSrcDir() == null) {
//if there is no src dir here, set it
setSrcDir(getProject().resolveFile("."));
1.11 +30 -7
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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DotnetCompile.java 18 Jul 2003 14:21:22 -0000 1.10
+++ DotnetCompile.java 1 Aug 2003 05:55:16 -0000 1.11
@@ -155,6 +155,12 @@
protected Vector resources = new Vector();
/**
+ * executable
+ */
+
+ protected String executable;
+
+ /**
* Fix .NET reference inclusion. .NET is really dumb in how it handles
* inclusion. You have to list every 'assembly' -read DLL that is
imported.
* So already you are making a platform assumption -shared libraries
have a
@@ -791,6 +797,26 @@
}
/**
+ * what is the executable?
+ * @return
+ */
+ protected String getExecutable() {
+ return executable;
+ }
+
+ /**
+ * set the name of the program, overriding the defaults.
+ * Can be used to set the full path to a program, or to switch
+ * to an alternate implementation of the command, such as the Mono or
Rotor
+ * versions -provided they use the same command line arguments as the
+ * .NET framework edition
+ * @param executable
+ */
+ public void setExecutable(String executable) {
+ this.executable = executable;
+ }
+
+ /**
* test for a string containing something useful
*
[EMAIL PROTECTED] s string in
@@ -809,6 +835,9 @@
if (outputFile != null && outputFile.isDirectory()) {
throw new BuildException("destFile cannot be a directory");
}
+ if(getExecutable()==null) {
+ throw new BuildException("There is no executable defined for
this task");
+ }
}
/**
@@ -863,12 +892,6 @@
public abstract String getReferenceDelimiter();
/**
- * Get the name of the compiler executable.
- * @return The name of the compiler executable.
- */
- public abstract String getCompilerExeName() ;
-
- /**
* Get the extension of filenames to compile.
* @return The string extension of files to compile.
*/
@@ -963,7 +986,7 @@
* @return a command prefilled with the exe name and task name
*/
protected NetCommand createNetCommand() {
- NetCommand command = new NetCommand(this, getTaskName(),
getCompilerExeName());
+ NetCommand command = new NetCommand(this, getTaskName(),
getExecutable());
return command;
}
1.4 +5 -7
ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/JSharp.java
Index: JSharp.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/JSharp.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JSharp.java 4 Jul 2003 14:04:55 -0000 1.3
+++ JSharp.java 1 Aug 2003 05:55:16 -0000 1.4
@@ -84,7 +84,11 @@
*/
boolean secureScoping = false;
+ public JSharp() {
+ setExecutable("vjc");
+ }
+
public void setBaseAddress(String baseAddress) {
this.baseAddress = baseAddress;
}
@@ -116,13 +120,7 @@
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.
1.7 +2 -9
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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- VisualBasicCompile.java 18 Jul 2003 14:21:23 -0000 1.6
+++ VisualBasicCompile.java 1 Aug 2003 05:55:16 -0000 1.7
@@ -107,7 +107,7 @@
* Constructor for VisualBasicCompile.
*/
public VisualBasicCompile() {
- super();
+ clear();
}
/**
@@ -121,6 +121,7 @@
optionExplicit = false;
optionStrict = false;
removeIntChecks = false;
+ setExecutable("vbc");
}
/**
@@ -347,14 +348,6 @@
*/
protected String createResourceParameter(DotnetResource resource) {
return resource.getVbStyleParameter();
- }
-
- /**
- * Get the name of the compiler executable.
- * @return The name of the compiler executable.
- */
- public String getCompilerExeName() {
- return "vbc";
}
/**
1.3 +8 -0
ant/src/testcases/org/apache/tools/ant/taskdefs/optional/DotnetTest.java
Index: DotnetTest.java
===================================================================
RCS file:
/home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/optional/DotnetTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DotnetTest.java 11 Mar 2003 06:08:11 -0000 1.2
+++ DotnetTest.java 1 Aug 2003 05:55:16 -0000 1.3
@@ -109,6 +109,14 @@
/**
* A unit test for JUnit
*/
+ public void testCSCintrinsicFileset() throws Exception {
+ executeTarget("testCSCintrinsicFileset");
+ }
+
+
+ /**
+ * A unit test for JUnit
+ */
public void testCSCdll() throws Exception {
executeTarget("testCSCdll");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]