Browse Source

<wsdltodotnet> should now work with Mono 1.0 as well

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276729 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
75e6369470
2 changed files with 42 additions and 12 deletions
  1. +4
    -4
      src/etc/testcases/taskdefs/optional/WsdlToDotnet.xml
  2. +38
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/dotnet/WsdlToDotnet.java

+ 4
- 4
src/etc/testcases/taskdefs/optional/WsdlToDotnet.xml View File

@@ -40,6 +40,7 @@
<echo> wsdl.found=${wsdl.found}</echo> <echo> wsdl.found=${wsdl.found}</echo>
<condition property="csc.found"> <condition property="csc.found">
<or> <or>
<available file="mcs" filepath="${env.PATH}" />
<available file="csc" filepath="${env.PATH}" /> <available file="csc" filepath="${env.PATH}" />
<available file="csc.exe" filepath="${env.PATH}" /> <available file="csc.exe" filepath="${env.PATH}" />
<available file="csc.exe" filepath="${env.Path}" /> <available file="csc.exe" filepath="${env.Path}" />
@@ -57,7 +58,6 @@
<condition property="dotnetapps.found"> <condition property="dotnetapps.found">
<and> <and>
<isset property="csc.found"/> <isset property="csc.found"/>
<isset property="vbc.found"/>
<isset property="wsdl.found"/> <isset property="wsdl.found"/>
</and> </and>
</condition> </condition>
@@ -142,7 +142,7 @@




<target name="testLocalWsdlVB" depends="init">
<target name="testLocalWsdlVB" depends="init" if="vbc.found">
<wsdltodotnet destFile="${out.vbc}" <wsdltodotnet destFile="${out.vbc}"
language="VB" language="VB"
srcFile="${local.wsdl}" srcFile="${local.wsdl}"
@@ -160,7 +160,7 @@
</target> </target>
<target name="testLocalWsdlServerVB" <target name="testLocalWsdlServerVB"
depends="init" >
depends="init" if="vbc.found">
<wsdltodotnet destFile="${out.vbc}" <wsdltodotnet destFile="${out.vbc}"
language="VB" language="VB"
srcFile="${local.wsdl}" srcFile="${local.wsdl}"
@@ -179,7 +179,7 @@
<fail unless="app.created">No app created</fail> <fail unless="app.created">No app created</fail>
</target> </target>
<target name="testInvalidExtraOpsVB" depends="init" if="vbc.found">
<target name="testInvalidExtraOpsVB" depends="init">
<wsdltodotnet destFile="${out.vbc}" <wsdltodotnet destFile="${out.vbc}"
language="VB" language="VB"
srcFile="${local.wsdl}" srcFile="${local.wsdl}"


+ 38
- 8
src/main/org/apache/tools/ant/taskdefs/optional/dotnet/WsdlToDotnet.java View File

@@ -19,6 +19,8 @@ package org.apache.tools.ant.taskdefs.optional.dotnet;
import java.io.File; import java.io.File;
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.taskdefs.condition.Os;
import org.apache.tools.ant.util.FileUtils;


/** /**
* Converts a WSDL file or URL resource into a .NET language. * Converts a WSDL file or URL resource into a .NET language.
@@ -57,7 +59,7 @@ public class WsdlToDotnet extends Task {
/** /**
* name of source file * name of source file
*/ */
private File srcFile = null;
private String srcFileName = null;


/** /**
* language; defaults to C# * language; defaults to C#
@@ -84,6 +86,11 @@ public class WsdlToDotnet extends Task {
*/ */
protected String extraOptions = null; protected String extraOptions = null;


/**
* @since Ant 1.7
*/
private boolean isMono = !Os.isFamily("windows");

/** /**
* Name of the file to generate. Required * Name of the file to generate. Required
* @param destFile filename * @param destFile filename
@@ -106,8 +113,13 @@ public class WsdlToDotnet extends Task {
* The local WSDL file to parse; either url or srcFile is required. * The local WSDL file to parse; either url or srcFile is required.
* @param srcFile name of WSDL file * @param srcFile name of WSDL file
*/ */
public void setSrcFile(File srcFile) {
this.srcFile = srcFile;
public void setSrcFile(String srcFileName) {
if (new File(srcFileName).isAbsolute()) {
srcFileName = FileUtils.newFileUtils()
.removeLeadingPath(getProject().getBaseDir(),
new File(srcFileName));;
}
this.srcFileName = srcFileName;
} }


/** /**
@@ -157,6 +169,17 @@ public class WsdlToDotnet extends Task {
this.extraOptions = extraOptions; this.extraOptions = extraOptions;
} }


/**
* Explicitly override the Mono auto-detection.
*
* <p>Defaults to false on Windows and true on any other platform.</p>
*
* @since Ant 1.7
*/
public void setMono(boolean b) {
isMono = b;
}

/** /**
* validation code * validation code
* @throws BuildException if validation failed * @throws BuildException if validation failed
@@ -170,15 +193,16 @@ public class WsdlToDotnet extends Task {
throw new BuildException( throw new BuildException(
"destination file is a directory"); "destination file is a directory");
} }
if (url != null && srcFile != null) {
if (url != null && srcFileName != null) {
throw new BuildException( throw new BuildException(
"you can not specify both a source file and a URL"); "you can not specify both a source file and a URL");
} }
if (url == null && srcFile == null) {
if (url == null && srcFileName == null) {
throw new BuildException( throw new BuildException(
"you must specify either a source file or a URL"); "you must specify either a source file or a URL");
} }
if (srcFile != null) {
if (srcFileName != null) {
File srcFile = getProject().resolveFile(srcFileName);
if (!srcFile.exists()) { if (!srcFile.exists()) {
throw new BuildException( throw new BuildException(
"source file does not exist"); "source file does not exist");
@@ -213,8 +237,14 @@ public class WsdlToDotnet extends Task {


//set source and rebuild options //set source and rebuild options
boolean rebuild = true; boolean rebuild = true;
if (srcFile != null) {
command.addArgument(srcFile.toString());
if (srcFileName != null) {
File srcFile = getProject().resolveFile(srcFileName);
if (isMono) {
// Mono 1.0's wsdl doesn't deal with absolute paths
command.addArgument(srcFileName);
} else {
command.addArgument(srcFile.toString());
}
//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() if (srcFile.exists() && destFile.exists()
&& srcFile.lastModified() <= destFile.lastModified()) { && srcFile.lastModified() <= destFile.lastModified()) {


Loading…
Cancel
Save