author | jjg |
Fri, 17 Jun 2016 17:40:01 -0700 | |
changeset 39103 | 91a64ec5b970 |
parent 37758 | 3ecf9b414e05 |
child 40500 | f293dbb81a53 |
permissions | -rw-r--r-- |
37758 | 1 |
/* |
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
package toolbox; |
|
25 |
||
26 |
import java.io.File; |
|
27 |
import java.io.IOException; |
|
28 |
import java.nio.file.Files; |
|
29 |
import java.nio.file.Path; |
|
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
30 |
import java.nio.file.Paths; |
37758 | 31 |
import java.util.ArrayList; |
32 |
import java.util.Arrays; |
|
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
33 |
import java.util.LinkedHashSet; |
37758 | 34 |
import java.util.List; |
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
35 |
import java.util.Set; |
37758 | 36 |
import java.util.stream.Collectors; |
37 |
||
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
38 |
/** |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
39 |
* Builder for module declarations. |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
40 |
*/ |
37758 | 41 |
public class ModuleBuilder { |
42 |
||
43 |
private final ToolBox tb; |
|
44 |
private final String name; |
|
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
45 |
private String comment = ""; |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
46 |
private List<String> requires = new ArrayList<>(); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
47 |
private List<String> exports = new ArrayList<>(); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
48 |
private List<String> uses = new ArrayList<>(); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
49 |
private List<String> provides = new ArrayList<>(); |
37758 | 50 |
private List<String> content = new ArrayList<>(); |
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
51 |
private Set<Path> modulePath = new LinkedHashSet<>(); |
37758 | 52 |
|
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
53 |
/** |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
54 |
* Creates a builder for a module. |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
55 |
* @param tb a Toolbox that can be used to compile the module declaration. |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
56 |
* @param name the name of the module to be built |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
57 |
*/ |
37758 | 58 |
public ModuleBuilder(ToolBox tb, String name) { |
59 |
this.tb = tb; |
|
60 |
this.name = name; |
|
61 |
} |
|
62 |
||
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
63 |
/** |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
64 |
* Sets the doc comment for the declaration. |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
65 |
* @param comment the content of the comment, excluding the initial |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
66 |
* '/**', leading whitespace and asterisks, and the final trailing 'a;/'. |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
67 |
* @return this builder |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
68 |
*/ |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
69 |
public ModuleBuilder comment(String comment) { |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
70 |
this.comment = comment; |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
71 |
return this; |
37758 | 72 |
} |
73 |
||
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
74 |
/** |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
75 |
* Adds a "requires public" directive to the declaration. |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
76 |
* @param requires the name of the module that is required |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
77 |
* @param modulePath a path in which to locate the modules |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
78 |
* if the declaration is compiled |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
79 |
* @return this builder |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
80 |
*/ |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
81 |
public ModuleBuilder requiresPublic(String requires, Path... modulePath) { |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
82 |
this.requires.add("requires public " + requires + ";"); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
83 |
this.modulePath.addAll(Arrays.asList(modulePath)); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
84 |
return this; |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
85 |
} |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
86 |
|
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
87 |
/** |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
88 |
* Adds a "requires" directive to the declaration. |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
89 |
* @param requires the name of the module that is required |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
90 |
* @param modulePath a path in while to locate the modules |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
91 |
* if the declaration is compiled |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
92 |
* @return this builder |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
93 |
*/ |
37758 | 94 |
public ModuleBuilder requires(String requires, Path... modulePath) { |
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
95 |
this.requires.add("requires " + requires + ";"); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
96 |
this.modulePath.addAll(Arrays.asList(modulePath)); |
37758 | 97 |
return this; |
98 |
} |
|
99 |
||
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
100 |
/** |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
101 |
* Adds a qualified "exports" directive to the declaration. |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
102 |
* @param pkg the name of the package to be exported |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
103 |
* @param module the name of the module to which it is to be exported |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
104 |
* @return this builder |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
105 |
*/ |
37758 | 106 |
public ModuleBuilder exportsTo(String pkg, String module) { |
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
107 |
this.exports.add("exports " + pkg + " to " + module + ";"); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
108 |
return this; |
37758 | 109 |
} |
110 |
||
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
111 |
/** |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
112 |
* Adds an unqualified "exports" directive to the declaration. |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
113 |
* @param pkg the name of the package to be exported |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
114 |
* @param module the name of the module to which it is to be exported |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
115 |
* @return this builder |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
116 |
*/ |
37758 | 117 |
public ModuleBuilder exports(String pkg) { |
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
118 |
this.exports.add("exports " + pkg + ";"); |
37758 | 119 |
return this; |
120 |
} |
|
121 |
||
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
122 |
/** |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
123 |
* Adds a "uses" directive to the declaration. |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
124 |
* @param service the name of the service type |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
125 |
* @return this builder |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
126 |
*/ |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
127 |
public ModuleBuilder uses(String service) { |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
128 |
this.uses.add("uses " + service + ";"); |
37758 | 129 |
return this; |
130 |
} |
|
131 |
||
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
132 |
/** |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
133 |
* Adds a "provides" directive to the declaration. |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
134 |
* @param service the name of the service type |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
135 |
* @param implementation the name of the implementation type |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
136 |
* @return this builder |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
137 |
*/ |
37758 | 138 |
public ModuleBuilder provides(String service, String implementation) { |
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
139 |
this.provides.add("provides " + service + " with " + implementation + ";"); |
37758 | 140 |
return this; |
141 |
} |
|
142 |
||
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
143 |
/** |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
144 |
* Adds type definitions to the module. |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
145 |
* @param content a series of strings, each representing the content of |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
146 |
* a compilation unit to be included with the module |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
147 |
* @return this builder |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
148 |
*/ |
37758 | 149 |
public ModuleBuilder classes(String... content) { |
150 |
this.content.addAll(Arrays.asList(content)); |
|
151 |
return this; |
|
152 |
} |
|
153 |
||
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
154 |
/** |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
155 |
* Writes the module declaration and associated additional compilation |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
156 |
* units to a module directory within a given directory. |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
157 |
* @param srcDir the directory in which a directory will be created |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
158 |
* to contain the source files for the module |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
159 |
* @return the directory containing the source files for the module |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
160 |
*/ |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
161 |
public Path write(Path srcDir) throws IOException { |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
162 |
Files.createDirectories(srcDir); |
37758 | 163 |
List<String> sources = new ArrayList<>(); |
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
164 |
StringBuilder sb = new StringBuilder(); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
165 |
if (!comment.isEmpty()) { |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
166 |
sb.append("/**\n").append(comment.replace("\n", " *")).append(" */\n"); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
167 |
} |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
168 |
sb.append("module ").append(name).append(" {"); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
169 |
requires.forEach(r -> sb.append(" " + r + "\n")); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
170 |
exports.forEach(e -> sb.append(" " + e + "\n")); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
171 |
uses.forEach(u -> sb.append(" " + u + "\n")); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
172 |
provides.forEach(p -> sb.append(" " + p + "\n")); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
173 |
sb.append("}"); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
174 |
sources.add(sb.toString()); |
37758 | 175 |
sources.addAll(content); |
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
176 |
Path moduleSrc = srcDir.resolve(name); |
37758 | 177 |
tb.writeJavaFiles(moduleSrc, sources.toArray(new String[]{})); |
178 |
return moduleSrc; |
|
179 |
} |
|
180 |
||
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
181 |
/** |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
182 |
* Writes the source files for the module to an interim directory, |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
183 |
* and then compiles them to a given directory. |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
184 |
* @param modules the directory in which a directory will be created |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
185 |
* to contain the compiled class files for the module |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
186 |
* @throws IOException if an error occurs while compiling the files |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
187 |
*/ |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
188 |
public void build(Path modules) throws IOException { |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
189 |
build(Paths.get(modules + "Src"), modules); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
190 |
} |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
191 |
|
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
192 |
/** |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
193 |
* Writes the source files for the module to a specified directory, |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
194 |
* and then compiles them to a given directory. |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
195 |
* @param srcDir the directory in which a directory will be created |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
196 |
* to contain the source files for the module |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
197 |
* @param modules the directory in which a directory will be created |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
198 |
* to contain the compiled class files for the module |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
199 |
* @throws IOException if an error occurs while compiling the files |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
200 |
*/ |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
201 |
public void build(Path src, Path modules) throws IOException { |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
202 |
Path moduleSrc = write(src); |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
203 |
String mp = modulePath.stream() |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
204 |
.map(Path::toString) |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
205 |
.collect(Collectors.joining(File.pathSeparator)); |
37758 | 206 |
new JavacTask(tb) |
39103
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
207 |
.outdir(Files.createDirectories(modules.resolve(name))) |
91a64ec5b970
8159749: Update toolbox ModuleBuilder for doc comments
jjg
parents:
37758
diff
changeset
|
208 |
.options("-mp", mp) |
37758 | 209 |
.files(tb.findJavaFiles(moduleSrc)) |
210 |
.run() |
|
211 |
.writeAll(); |
|
212 |
} |
|
213 |
} |