001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018: package org.apache.tools.ant.taskdefs.optional.dotnet;
019:
020: import org.apache.tools.ant.BuildException;
021:
022: /**
023: * Compile J# source down to a managed .NET application.
024: * <p>
025: * J# is not Java. But it is the language closest to Java in the .NET framework.
026: * This task compiles jsharp source (.java files), and
027: * generates a .NET managed exe or dll.
028: * <p>
029: *
030: * <p>For historical reasons the pattern
031: * <code>**</code><code>/*.java</code> is preset as includes list and
032: * you can not override it with an explicit includes attribute. Use
033: * nested <code><src></code> elements instead of the basedir
034: * attribute if you need more control.</p>
035: *
036: * @see <a ref=
037: * "http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vjsharp/html/vjoriMicrosoftVisualJ.asp"
038: * >Visual J++ online documentation</a>
039: *
040: * @since ant1.6
041: * @ant.task category="dotnet" name="jsharpc"
042: */
043: public class JSharp extends DotnetCompile {
044: // CheckStyle:VisibilityModifier OFF - bc
045: /**
046: * hex base address
047: */
048: String baseAddress;
049:
050: /** /x option to disable J++ and J# lang extensions
051: *
052: */
053: boolean pureJava = true;
054:
055: /**
056: * whether to make package scoped stuff public or assembly scoped
057: */
058: boolean secureScoping = false;
059:
060: // CheckStyle:VisibilityModifier ON
061:
062: /** No arg constructor. */
063: public JSharp() {
064: setExecutable("vjc");
065: }
066:
067: /**
068: * Set the base address attribute.
069: * @param baseAddress the value to use.
070: */
071: public void setBaseAddress(String baseAddress) {
072: this .baseAddress = baseAddress;
073: }
074:
075: /**
076: * do we want pure java (default, true) or corrupted J#?
077: * @param pureJava a <code>boolean</code> value.
078: */
079: public void setPureJava(boolean pureJava) {
080: this .pureJava = pureJava;
081: }
082:
083: /**
084: * Make package scoped code visible to the current assembly only (default: false)
085: * .NET does not have package scoping. Instead it has assembly, private and public.
086: * By default, package content is public to all.
087: * @param secureScoping a <code>boolean</code> value.
088: */
089: public void setSecureScoping(boolean secureScoping) {
090: this .secureScoping = secureScoping;
091: }
092:
093: /**
094: * Get the delimiter that the compiler uses between references.
095: * For example, c# will return ";"; VB.NET will return ","
096: * @return The string delimiter for the reference string.
097: */
098: public String getReferenceDelimiter() {
099: return ";";
100: }
101:
102: /**
103: * Get the extension of filenames to compile.
104: * @return The string extension of files to compile.
105: */
106: public String getFileExtension() {
107: return ".java";
108: }
109:
110: /**
111: * add jvc specific commands
112: * @param command the command to add to.
113: */
114: protected void addCompilerSpecificOptions(NetCommand command) {
115: if (pureJava) {
116: command.addArgument("/x:all");
117: }
118: if (secureScoping) {
119: command.addArgument("/securescoping");
120: }
121: }
122:
123: /** {@inheritDoc} */
124: protected void createResourceParameter(NetCommand command,
125: DotnetResource resource) {
126: resource.getParameters(getProject(), command, true);
127: }
128:
129: /**
130: * validation code
131: * @throws org.apache.tools.ant.BuildException if validation failed
132: */
133: protected void validate() throws BuildException {
134: super .validate();
135: if (getDestFile() == null) {
136: throw new BuildException("DestFile was not specified");
137: }
138: }
139: }
|