mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8035063: Option handling in sjavac needs to be rewritten
Option handling code rewritten. Exclusion / inclusion patterns changed from package to directories. Reviewed-by: jjg, jfranck
This commit is contained in:
parent
a50db59b59
commit
06f651942c
28 changed files with 2427 additions and 907 deletions
85
langtools/test/tools/sjavac/ExclPattern.java
Normal file
85
langtools/test/tools/sjavac/ExclPattern.java
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class ExclPattern {
|
||||
|
||||
public static void main(String[] ignore) throws IOException {
|
||||
|
||||
String toBeExcluded = "pkg/excl-dir/excluded.txt";
|
||||
String toBeIncluded = "pkg/incl-dir/included.txt";
|
||||
|
||||
// Set up source directory with directory to be excluded
|
||||
populate(Paths.get("srcdir"),
|
||||
"pkg/SomeClass.java",
|
||||
"package pkg; public class SomeClass { }",
|
||||
|
||||
toBeExcluded,
|
||||
"This file should not end up in the dest directory.",
|
||||
|
||||
toBeIncluded,
|
||||
"This file should end up in the dest directory.");
|
||||
|
||||
String[] args = {
|
||||
"-x", "pkg/excl-dir/*",
|
||||
"-src", "srcdir",
|
||||
"-d", "dest",
|
||||
"-j", "1",
|
||||
"-copy", ".txt",
|
||||
"--server:portfile=testserver,background=false",
|
||||
"--log=debug"
|
||||
};
|
||||
|
||||
int rc = new com.sun.tools.sjavac.Main().go(args, System.out, System.err);
|
||||
if (rc != 0) throw new RuntimeException("Error during compile!");
|
||||
|
||||
if (!Files.exists(Paths.get("dest/" + toBeIncluded)))
|
||||
throw new AssertionError("File missing: " + toBeIncluded);
|
||||
|
||||
if (Files.exists(Paths.get("dest/" + toBeExcluded)))
|
||||
throw new AssertionError("File present: " + toBeExcluded);
|
||||
}
|
||||
|
||||
static void populate(Path root, String... args) throws IOException {
|
||||
if (!Files.exists(root))
|
||||
Files.createDirectory(root);
|
||||
for (int i = 0; i < args.length; i += 2) {
|
||||
String filename = args[i];
|
||||
String content = args[i+1];
|
||||
Path p = root.resolve(filename);
|
||||
Files.createDirectories(p.getParent());
|
||||
try (PrintWriter out = new PrintWriter(Files.newBufferedWriter(p,
|
||||
Charset.defaultCharset()))) {
|
||||
out.println(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue