1 | /*
|
---|
2 | * Copyright 2000-2005 The Apache Software Foundation
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | *
|
---|
16 | */
|
---|
17 | package org.apache.tools.ant.taskdefs.optional.dotnet;
|
---|
18 |
|
---|
19 | import org.apache.tools.ant.BuildException;
|
---|
20 |
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Compile J# source down to a managed .NET application.
|
---|
24 | * <p>
|
---|
25 | * J# is not Java. But it is the language closest to Java in the .NET framework.
|
---|
26 | * This task compiles jsharp source (.java files), and
|
---|
27 | * generates a .NET managed exe or dll.
|
---|
28 | * <p>
|
---|
29 | *
|
---|
30 | * <p>For historical reasons the pattern
|
---|
31 | * <code>**</code><code>/*.java</code> is preset as includes list and
|
---|
32 | * you can not override it with an explicit includes attribute. Use
|
---|
33 | * nested <code><src></code> elements instead of the basedir
|
---|
34 | * attribute if you need more control.</p>
|
---|
35 | *
|
---|
36 | * @see <A=ref="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vjsharp/html/vjoriMicrosoftVisualJ.asp">
|
---|
37 | * Visual J++ online documentation</a>
|
---|
38 | *
|
---|
39 | * @since ant1.6
|
---|
40 | * @ant.task category="dotnet" name="jsharpc"
|
---|
41 | */
|
---|
42 | public class JSharp extends DotnetCompile {
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * hex base address
|
---|
46 | */
|
---|
47 | String baseAddress;
|
---|
48 |
|
---|
49 | /** /x option to disable J++ and J# lang extensions
|
---|
50 | *
|
---|
51 | */
|
---|
52 | boolean pureJava = true;
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * whether to make package scoped stuff public or assembly scoped
|
---|
56 | */
|
---|
57 | boolean secureScoping = false;
|
---|
58 |
|
---|
59 | public JSharp() {
|
---|
60 | setExecutable("vjc");
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 | public void setBaseAddress(String baseAddress) {
|
---|
65 | this.baseAddress = baseAddress;
|
---|
66 | }
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * do we want pure java (default, true) or corrupted J#?
|
---|
70 | * @param pureJava
|
---|
71 | */
|
---|
72 | public void setPureJava(boolean pureJava) {
|
---|
73 | this.pureJava = pureJava;
|
---|
74 | }
|
---|
75 |
|
---|
76 | /**
|
---|
77 | * Make package scoped code visible to the current assembly only (default: false)
|
---|
78 | * .NET does not have package scoping. Instead it has assembly, private and public.
|
---|
79 | * By default, package content is public to all.
|
---|
80 | * @param secureScoping
|
---|
81 | */
|
---|
82 | public void setSecureScoping(boolean secureScoping) {
|
---|
83 | this.secureScoping = secureScoping;
|
---|
84 | }
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * Get the delimiter that the compiler uses between references.
|
---|
88 | * For example, c# will return ";"; VB.NET will return ","
|
---|
89 | * @return The string delimiter for the reference string.
|
---|
90 | */
|
---|
91 | public String getReferenceDelimiter() {
|
---|
92 | return ";";
|
---|
93 | }
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * Get the extension of filenames to compile.
|
---|
97 | * @return The string extension of files to compile.
|
---|
98 | */
|
---|
99 | public String getFileExtension() {
|
---|
100 | return ".java";
|
---|
101 | }
|
---|
102 |
|
---|
103 | /**
|
---|
104 | * add jvc specific commands
|
---|
105 | * @param command
|
---|
106 | */
|
---|
107 | protected void addCompilerSpecificOptions(NetCommand command) {
|
---|
108 | if (pureJava) {
|
---|
109 | command.addArgument("/x:all");
|
---|
110 | }
|
---|
111 | if (secureScoping) {
|
---|
112 | command.addArgument("/securescoping");
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 | /**
|
---|
117 | * from a resource, get the resource param
|
---|
118 | * @param resource
|
---|
119 | * @return a string containing the resource param, or a null string
|
---|
120 | * to conditionally exclude a resource.
|
---|
121 | */
|
---|
122 | protected String createResourceParameter(DotnetResource resource) {
|
---|
123 | return resource.getCSharpStyleParameter();
|
---|
124 | }
|
---|
125 |
|
---|
126 | /**
|
---|
127 | * validation code
|
---|
128 | * @throws org.apache.tools.ant.BuildException if validation failed
|
---|
129 | */
|
---|
130 | protected void validate()
|
---|
131 | throws BuildException {
|
---|
132 | super.validate();
|
---|
133 | if (getDestFile() == null) {
|
---|
134 | throw new BuildException("DestFile was not specified");
|
---|
135 | }
|
---|
136 | }
|
---|
137 | }
|
---|