Fix BuckPrologCompiler to create Java 6 class files
Gerrit targets Java 6, not Java 7. If Buck is run under JDK 7 the javac compiler by default will assume -source 7 -target 7 and write incompatible class files. Ensure the compiler builds for Java 6 language features and Java 6 class format by passing the correct flags. Change-Id: Ib2c013a6d1955d94b75cfd5d967d2f45ef4d5486
This commit is contained in:
@@ -12,11 +12,15 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import com.googlecode.prolog_cafe.compiler.CompileException;
|
||||
import com.googlecode.prolog_cafe.compiler.Compiler;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.jar.JarEntry;
|
||||
@@ -29,9 +33,6 @@ import javax.tools.JavaFileObject;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
import com.googlecode.prolog_cafe.compiler.CompileException;
|
||||
import com.googlecode.prolog_cafe.compiler.Compiler;
|
||||
|
||||
public class BuckPrologCompiler {
|
||||
public static void main(String[] argv) throws IOException, CompileException {
|
||||
List<File> srcs = new ArrayList<File>();
|
||||
@@ -82,14 +83,16 @@ public class BuckPrologCompiler {
|
||||
classpath.append(jar.getPath());
|
||||
}
|
||||
ArrayList<String> args = new ArrayList<String>();
|
||||
args.add("-g:none");
|
||||
args.add("-nowarn");
|
||||
args.addAll(Arrays.asList(new String[]{
|
||||
"-source", "6",
|
||||
"-target", "6",
|
||||
"-g:none",
|
||||
"-nowarn",
|
||||
"-d", classes.getPath()}));
|
||||
if (classpath.length() > 0) {
|
||||
args.add("-classpath");
|
||||
args.add(classpath.toString());
|
||||
}
|
||||
args.add("-d");
|
||||
args.add(classes.getPath());
|
||||
if (!javac.getTask(null, fm, d, args, null,
|
||||
fm.getJavaFileObjectsFromFiles(find(java, ".java"))).call()) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
|
||||
Reference in New Issue
Block a user