equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
56 |
56 |
57 static void compile(File classOutDir, Iterable<File> classPath, File... files) |
57 static void compile(File classOutDir, Iterable<File> classPath, File... files) |
58 throws IOException { |
58 throws IOException { |
59 System.err.println("compile..."); |
59 System.err.println("compile..."); |
60 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); |
60 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); |
61 StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null); |
61 try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) { |
62 try { |
|
63 Iterable<? extends JavaFileObject> fileObjects = |
62 Iterable<? extends JavaFileObject> fileObjects = |
64 fm.getJavaFileObjectsFromFiles(Arrays.asList(files)); |
63 fm.getJavaFileObjectsFromFiles(Arrays.asList(files)); |
65 |
64 |
66 List<String> options = new ArrayList<String>(); |
65 List<String> options = new ArrayList<String>(); |
67 if (classOutDir != null) { |
66 if (classOutDir != null) { |
76 |
75 |
77 JavaCompiler.CompilationTask task = |
76 JavaCompiler.CompilationTask task = |
78 compiler.getTask(null, fm, null, options, null, fileObjects); |
77 compiler.getTask(null, fm, null, options, null, fileObjects); |
79 if (!task.call()) |
78 if (!task.call()) |
80 throw new AssertionError("compilation failed"); |
79 throw new AssertionError("compilation failed"); |
81 } finally { |
|
82 fm.close(); |
|
83 } |
80 } |
84 } |
81 } |
85 |
82 |
86 static void jar(File jar, Iterable<File> classPath, File base, File... files) |
83 static void jar(File jar, Iterable<File> classPath, File base, File... files) |
87 throws IOException { |
84 throws IOException { |