FileDocCategorySizeDatePackage
VisualBasicCompile.javaAPI DocApache Ant 1.7010393Wed Dec 13 06:16:24 GMT 2006org.apache.tools.ant.taskdefs.optional.dotnet

VisualBasicCompile

public class VisualBasicCompile extends DotnetCompile
This task compiles Visual Basic.NET source into executables or modules. The task requires vbc.exe on the execute path, unless it or an equivalent program is specified in the executable parameter

All parameters are optional: <vbc/> should suffice to produce a debug build of all *.vb files.

The task is a directory based task, so attributes like includes="**\/*.vb" and excludes="broken.vb" 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 destfile is prudent.

Also, dependency checking only works if destfile is set.

For historical reasons the pattern **/*.vb is preset as includes list and you can not override it with an explicit includes attribute. Use nested <src> elements instead of the basedir attribute if you need more control.

As with <csc> nested src filesets of source, reference filesets, definitions and resources can be provided.

Example

<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>
ant.task
name="vbc" category="dotnet"

Fields Summary
private boolean
removeIntChecks
Compiler option to remove integer checks. Default: false.
private boolean
optionExplicit
Require explicit declaration of variables? Default: false.
private boolean
optionStrict
Enforce strict language semantics? Default: false.
private String
optionCompare
Whether to compare strings as "text" or "binary". Default: "binary".
private String
rootNamespace
Root namespace for all type declarations.
private String
imports
Declare global imports fornamespaces in referenced metadata files.
Constructors Summary
public VisualBasicCompile()
Constructor for VisualBasicCompile.


            
      
        clear();
    
Methods Summary
protected voidaddCompilerSpecificOptions(NetCommand command)
implement VBC commands

param
command the command to set arguements on.

        command.addArgument(getRemoveIntChecksParameter());
        command.addArgument(getImportsParameter());
        command.addArgument(getOptionExplicitParameter());
        command.addArgument(getOptionStrictParameter());
        command.addArgument(getRootNamespaceParameter());
        command.addArgument(getOptionCompareParameter());
    
public voidclear()
reset all contents.

        super.clear();
        imports = null;
        rootNamespace = null;
        optionCompare = null;
        optionExplicit = false;
        optionStrict = false;
        removeIntChecks = false;
        setExecutable("vbc");
    
protected voidcreateResourceParameter(NetCommand command, DotnetResource resource)
{@inheritDoc}

        resource.getParameters(getProject(), command, false);
    
public java.lang.StringgetFileExtension()
Get the extension of filenames to compile.

return
The string extension of files to compile.

        return "vb";
    
public java.lang.StringgetImports()
Get global imports for namespaces in referenced metadata files.

return
the imports string.

        return this.imports;
    
protected java.lang.StringgetImportsParameter()
Format the option for imports.

return
the formatted import option.

        if (imports != null && imports.length() != 0) {
            return "/imports:" + imports;
        } else {
            return null;
        }
    
public java.lang.StringgetOptionCompare()
"binary" or "text" for the string-comparison style.

return
the option compare style.

        return this.optionCompare;
    
protected java.lang.StringgetOptionCompareParameter()
Format the option for string comparison style.

return
The formatted option.

        if (optionCompare != null && "text".equalsIgnoreCase(optionCompare)) {
            return "/optioncompare:text";
        } else {
            return "/optioncompare:binary";
        }
    
public booleangetOptionExplicit()
Get the flag for whether to require explicit declaration of variables.

return
true if flag is turned on

        return optionExplicit;
    
public java.lang.StringgetOptionExplicitParameter()
Form the option string for optionExplicit..

return
The parameter string.

        return "/optionexplicit" + (optionExplicit ? "+" : "-");
    
public booleangetOptionStrict()
Get the flag for whether to enforce strict language semantics.

return
true if flag is turned on

        return optionStrict;
    
public java.lang.StringgetOptionStrictParameter()
For the option string for optionStrict.

return
The parameter string.

        return "/optionstrict" + (optionStrict ? "+" : "-");
    
public java.lang.StringgetReferenceDelimiter()
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.

        return ",";
    
public booleangetRemoveIntChecks()
Get the flag for removing integer checks.

return
true if flag is turned on

        return removeIntChecks;
    
public java.lang.StringgetRemoveIntChecksParameter()
Form the option string for removeIntChecks.

return
The parameter string.

        return "/removeintchecks" + (removeIntChecks ? "+" : "-");
    
public java.lang.StringgetRootNamespace()
Get the root namespace.

return
the root namespace.

        return this.rootNamespace;
    
protected java.lang.StringgetRootNamespaceParameter()
Form the option string for rootNamespace.

return
the root namespace option string.

        if (rootNamespace != null && rootNamespace.length() != 0) {
            return "/rootnamespace:" + rootNamespace;
        } else {
            return null;
        }
    
protected java.lang.StringgetWin32ResParameter()
get the argument or null for no argument needed This is overridden from DotnetCompile.java because VBC uses "/win32resource:" rather than "/win32res:"

return
The Win32Res Parameter to CSC

        if (getWin32Res() != null) {
            return "/win32resource:" + getWin32Res().toString();
        } else {
            return null;
        }
    
public voidsetImports(java.lang.String imports)
Declare global imports for namespaces in referenced metadata files.

param
imports the imports string

        this.imports = imports;
    
public voidsetOptionCompare(java.lang.String optionCompare)
Specify binary- or text-style string comparisons. Defaults to "binary"

param
optionCompare the option compare style. "text" | "binary".

        if ("text".equalsIgnoreCase(optionCompare)) {
            this.optionCompare = "text";
        } else {
            this.optionCompare = "binary";
        }
    
public voidsetOptionExplicit(boolean flag)
Whether to require explicit declaration of variables.

param
flag on/off flag

        optionExplicit = flag;
    
public voidsetOptionStrict(boolean flag)
Enforce strict language semantics.

param
flag on/off flag

        optionStrict = flag;
    
public voidsetRemoveIntChecks(boolean flag)
Whether to remove integer checks. Default false.

param
flag on/off flag

        removeIntChecks = flag;
    
public voidsetRootNamespace(java.lang.String rootNamespace)
Specifies the root namespace for all type declarations.

param
rootNamespace a root namespace.

        this.rootNamespace = rootNamespace;
    
protected voidvalidate()
validation code

throws
BuildException if validation failed

        super.validate();
        if (getDestFile() == null) {
            throw new BuildException("DestFile was not specified");
        }