26 * @summary Verify that plugins inside modules works |
26 * @summary Verify that plugins inside modules works |
27 * @library /tools/lib |
27 * @library /tools/lib |
28 * @modules |
28 * @modules |
29 * jdk.compiler/com.sun.tools.javac.api |
29 * jdk.compiler/com.sun.tools.javac.api |
30 * jdk.compiler/com.sun.tools.javac.main |
30 * jdk.compiler/com.sun.tools.javac.main |
31 * jdk.jdeps/com.sun.tools.javap |
31 * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase |
32 * @build ToolBox ModuleTestBase |
|
33 * @run main PluginsInModulesTest |
32 * @run main PluginsInModulesTest |
34 */ |
33 */ |
35 |
34 |
36 import java.nio.file.Files; |
35 import java.nio.file.Files; |
37 import java.nio.file.Path; |
36 import java.nio.file.Path; |
38 import java.util.Arrays; |
37 import java.util.Arrays; |
39 import java.util.List; |
38 import java.util.List; |
|
39 |
|
40 import toolbox.JavacTask; |
|
41 import toolbox.Task; |
|
42 import toolbox.ToolBox; |
40 |
43 |
41 public class PluginsInModulesTest extends ModuleTestBase { |
44 public class PluginsInModulesTest extends ModuleTestBase { |
42 |
45 |
43 public static void main(String... args) throws Exception { |
46 public static void main(String... args) throws Exception { |
44 new PluginsInModulesTest().runTests(); |
47 new PluginsInModulesTest().runTests(); |
101 tb.writeJavaFiles( |
104 tb.writeJavaFiles( |
102 pluginMod1, |
105 pluginMod1, |
103 pluginModule1, |
106 pluginModule1, |
104 plugin1); |
107 plugin1); |
105 |
108 |
106 String log = tb.new JavacTask() |
109 String log = new JavacTask(tb) |
107 .options("-modulesourcepath", moduleSrc.toString()) |
110 .options("-modulesourcepath", moduleSrc.toString()) |
108 .outdir(processorCompiledModules) |
111 .outdir(processorCompiledModules) |
109 .files(findJavaFiles(moduleSrc)) |
112 .files(findJavaFiles(moduleSrc)) |
110 .run() |
113 .run() |
111 .writeAll() |
114 .writeAll() |
112 .getOutput(ToolBox.OutputKind.DIRECT); |
115 .getOutput(Task.OutputKind.DIRECT); |
113 |
116 |
114 if (!log.isEmpty()) { |
117 if (!log.isEmpty()) { |
115 throw new AssertionError("Unexpected output: " + log); |
118 throw new AssertionError("Unexpected output: " + log); |
116 } |
119 } |
117 |
120 |
124 Path classes; |
127 Path classes; |
125 |
128 |
126 @Test |
129 @Test |
127 void testUseOnlyOneProcessor(Path base) throws Exception { |
130 void testUseOnlyOneProcessor(Path base) throws Exception { |
128 initialization(base); |
131 initialization(base); |
129 List<String> log = tb.new JavacTask() |
132 List<String> log = new JavacTask(tb) |
130 .options("-processormodulepath", processorCompiledModules.toString(), |
133 .options("-processormodulepath", processorCompiledModules.toString(), |
131 "-Xplugin:simpleplugin1") |
134 "-Xplugin:simpleplugin1") |
132 .outdir(classes) |
135 .outdir(classes) |
133 .sources(testClass) |
136 .sources(testClass) |
134 .run() |
137 .run() |
135 .writeAll() |
138 .writeAll() |
136 .getOutputLines(ToolBox.OutputKind.STDOUT); |
139 .getOutputLines(Task.OutputKind.STDOUT); |
137 if (!log.equals(Arrays.asList("simpleplugin1 started for event COMPILATION", |
140 if (!log.equals(Arrays.asList("simpleplugin1 started for event COMPILATION", |
138 "simpleplugin1 finished for event COMPILATION"))) { |
141 "simpleplugin1 finished for event COMPILATION"))) { |
139 throw new AssertionError("Unexpected output: " + log); |
142 throw new AssertionError("Unexpected output: " + log); |
140 } |
143 } |
141 } |
144 } |