KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > dotnet > JSharp


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18 package org.apache.tools.ant.taskdefs.optional.dotnet;
19
20 import org.apache.tools.ant.BuildException;
21
22
23 /**
24  * Compile J# source down to a managed .NET application.
25  * <p>
26  * J# is not Java. But it is the language closest to Java in the .NET framework.
27  * This task compiles jsharp source (.java files), and
28  * generates a .NET managed exe or dll.
29  * <p>
30  *
31  * <p>For historical reasons the pattern
32  * <code>**</code><code>/*.java</code> is preset as includes list and
33  * you can not override it with an explicit includes attribute. Use
34  * nested <code>&lt;src&gt;</code> elements instead of the basedir
35  * attribute if you need more control.</p>
36  *
37  * @see <a ref=
38  * "http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vjsharp/html/vjoriMicrosoftVisualJ.asp"
39  * >Visual J++ online documentation</a>
40  *
41  * @since ant1.6
42  * @ant.task category="dotnet" name="jsharpc"
43  */

44 public class JSharp extends DotnetCompile {
45     // CheckStyle:VisibilityModifier OFF - bc
46
/**
47      * hex base address
48      */

49     String JavaDoc baseAddress;
50
51     /** /x option to disable J++ and J# lang extensions
52      *
53      */

54     boolean pureJava = true;
55
56     /**
57      * whether to make package scoped stuff public or assembly scoped
58      */

59     boolean secureScoping = false;
60
61     // CheckStyle:VisibilityModifier ON
62

63     /** No arg constructor. */
64     public JSharp() {
65         setExecutable("vjc");
66     }
67
68
69     /**
70      * Set the base address attribute.
71      * @param baseAddress the value to use.
72      */

73     public void setBaseAddress(String JavaDoc baseAddress) {
74         this.baseAddress = baseAddress;
75     }
76
77     /**
78      * do we want pure java (default, true) or corrupted J#?
79      * @param pureJava a <code>boolean</code> value.
80      */

81     public void setPureJava(boolean pureJava) {
82         this.pureJava = pureJava;
83     }
84
85     /**
86      * Make package scoped code visible to the current assembly only (default: false)
87      * .NET does not have package scoping. Instead it has assembly, private and public.
88      * By default, package content is public to all.
89      * @param secureScoping a <code>boolean</code> value.
90      */

91     public void setSecureScoping(boolean secureScoping) {
92         this.secureScoping = secureScoping;
93     }
94
95     /**
96      * Get the delimiter that the compiler uses between references.
97      * For example, c# will return ";"; VB.NET will return ","
98      * @return The string delimiter for the reference string.
99      */

100     public String JavaDoc getReferenceDelimiter() {
101         return ";";
102     }
103
104     /**
105      * Get the extension of filenames to compile.
106      * @return The string extension of files to compile.
107      */

108     public String JavaDoc getFileExtension() {
109         return ".java";
110     }
111
112     /**
113      * add jvc specific commands
114      * @param command the command to add to.
115      */

116     protected void addCompilerSpecificOptions(NetCommand command) {
117         if (pureJava) {
118             command.addArgument("/x:all");
119         }
120         if (secureScoping) {
121             command.addArgument("/securescoping");
122         }
123     }
124
125     /** {@inheritDoc} */
126     protected void createResourceParameter(NetCommand command, DotnetResource resource) {
127         resource.getParameters(getProject(), command, true);
128     }
129
130     /**
131      * validation code
132      * @throws org.apache.tools.ant.BuildException if validation failed
133      */

134     protected void validate()
135             throws BuildException {
136         super.validate();
137         if (getDestFile() == null) {
138             throw new BuildException("DestFile was not specified");
139         }
140     }
141 }
142
Popular Tags