src/share/classes/org/openjdk/jigsaw/cli/Packager.java

Print this page

        

*** 25,35 **** package org.openjdk.jigsaw.cli; import java.lang.module.*; import java.io.*; - import java.security.SignatureException; import java.util.*; import static java.lang.System.out; import static java.lang.System.err; --- 25,34 ----
*** 59,72 **** --fast : use fastest, rather then best compression */ public class Packager { ! private static JigsawModuleSystem jms = JigsawModuleSystem.instance(); ! private static boolean jigsawDevMode = System.getenv("JIGSAW_DEV_MODE") != null; /** Temp dir for modules to be pre-installed into */ private static File tmp_dst; --- 58,71 ---- --fast : use fastest, rather then best compression */ public class Packager { ! private static final JigsawModuleSystem jms = JigsawModuleSystem.instance(); ! private static final boolean jigsawDevMode = System.getenv("JIGSAW_DEV_MODE") != null; /** Temp dir for modules to be pre-installed into */ private static File tmp_dst;
*** 133,151 **** private static void createTempWorkDir() throws Command.Exception { try { ! tmp_dst = File.createTempFile("jigsaw",null); Files.delete(tmp_dst); Files.mkdirs(tmp_dst, "jigsaw temp directory"); } ! catch (IOException x) { throw new Command.Exception(x); } } class Jmod extends Command<SimpleLibrary> { private String getModuleVersion(String modulename) throws Command.Exception { --- 132,183 ---- private static void createTempWorkDir() throws Command.Exception { try { ! tmp_dst = File.createTempFile("jigsaw", null); Files.delete(tmp_dst); Files.mkdirs(tmp_dst, "jigsaw temp directory"); + } catch (IOException x) { + throw new Command.Exception(x); } ! } ! ! class Contents extends Command<SimpleLibrary> { ! protected void go(SimpleLibrary lib) ! throws Command.Exception ! { ! String jmodName = takeArg(); ! finishArgs(); ! try (FileInputStream fis = new FileInputStream(jmodName); ! DataInputStream dis = new DataInputStream(fis); ! ModuleFile.Reader reader = new ModuleFile.Reader(dis)) { ! List<String> contents = reader.getContents(); ! for (String fn : contents) ! out.format(" %s%n", fn); ! } catch (IOException x) { throw new Command.Exception(x); } } + } + class Show extends Command<SimpleLibrary> { + protected void go(SimpleLibrary lib) + throws Command.Exception + { + String jmodName = takeArg(); + finishArgs(); + try (FileInputStream fis = new FileInputStream(jmodName); + DataInputStream dis = new DataInputStream(fis); + ModuleFile.Reader reader = new ModuleFile.Reader(dis)) { + ModuleInfo mi = jms.parseModuleInfo(reader.readStart()); + Commands.formatModule(out, mi, verbose); + } catch (IOException x) { + throw new Command.Exception(x); + } + } + } class Jmod extends Command<SimpleLibrary> { private String getModuleVersion(String modulename) throws Command.Exception {
*** 589,613 **** cleanup(); } } } ! private static Map<String,Class<? extends Command<SimpleLibrary>>> commands = new HashMap<>(); static { commands.put("deb", Deb.class); commands.put("jmod", Jmod.class); } private OptionParser parser; private static OptionSpec<File> resourcePath; // ## private void usage() { out.format("%n"); ! out.format("usage: jpkg [-v] [-L <library>] [-r <resource-dir>] [-i <include-dir>] [-m <module-dir>] [-d <output-dir>] [-c <command>] [-n <name>] [-e <e-mail@address>] [-s <short description>] [-l <long description>] [-x <extra metadata>] [deb|jmod] <module-name>%n"); out.format("%n"); try { parser.printHelpOn(out); } catch (IOException x) { throw new AssertionError(x); --- 621,654 ---- cleanup(); } } } ! private static final Map<String,Class<? extends Command<SimpleLibrary>>> commands = new HashMap<>(); static { + commands.put("contents", Contents.class); commands.put("deb", Deb.class); commands.put("jmod", Jmod.class); + commands.put("show", Show.class); } private OptionParser parser; private static OptionSpec<File> resourcePath; // ## private void usage() { out.format("%n"); ! out.format("usage: jpkg contents <module-file>%n"); ! out.format(" jpkg show [-v] <module-file>%n"); ! out.format(" jpkg [-v] [-L <library>] [-r <resource-dir>] "); ! out.format( "[-i <include-dir>] [-m <module-dir>] "); ! out.format( "[-d <output-dir>] [-c <command>] [-n <name>] "); ! out.format( "[-e <e-mail@address>] [-s <short description>] "); ! out.format( "[-l <long description>] [-x <extra metadata>] "); ! out.format( "[deb|jmod] <module-name>%n"); out.format("%n"); try { parser.printHelpOn(out); } catch (IOException x) { throw new AssertionError(x);
*** 812,821 **** --- 853,866 ---- if (cmd == Deb.class) (new Deb()).run(null, opts); else if (cmd == Jmod.class) (new Jmod()).run(null, opts); + else if (cmd == Contents.class) + (new Contents()).run(null, opts); + else if (cmd == Show.class) + (new Show()).run(null, opts); } /** * Helper method to check if a path exists before using it further. *
*** 822,832 **** * @param path to check * @param type of path being checked * * @throws Command.Exception if path doesn't exist */ ! private static final void checkIfPathExists(File path, String type) throws Command.Exception { if (!path.exists()) throw new Command.Exception("%s path doesn't exist: %s", type, path); --- 867,877 ---- * @param path to check * @param type of path being checked * * @throws Command.Exception if path doesn't exist */ ! private static void checkIfPathExists(File path, String type) throws Command.Exception { if (!path.exists()) throw new Command.Exception("%s path doesn't exist: %s", type, path);
*** 838,848 **** * @param path to check * @param type of path being checked * * @throws Command.Exception if path isn't readable */ ! private static final void checkIfPathIsReadable(File path, String type) throws Command.Exception { if (!path.canRead()) throw new Command.Exception("%s path isn't readable: %s", type, path); --- 883,893 ---- * @param path to check * @param type of path being checked * * @throws Command.Exception if path isn't readable */ ! private static void checkIfPathIsReadable(File path, String type) throws Command.Exception { if (!path.canRead()) throw new Command.Exception("%s path isn't readable: %s", type, path);
*** 854,864 **** * @param path to check * @param type of path being checked * * @throws Command.Exception if path is not a directory */ ! private static final void checkIfPathIsDirectory(File path, String type) throws Command.Exception { if (!path.isDirectory()) throw new Command.Exception("%s path is not a directory: %s", type, path); --- 899,909 ---- * @param path to check * @param type of path being checked * * @throws Command.Exception if path is not a directory */ ! private static void checkIfPathIsDirectory(File path, String type) throws Command.Exception { if (!path.isDirectory()) throw new Command.Exception("%s path is not a directory: %s", type, path);
*** 870,880 **** * @param path to check * @param type of path being checked * * @throws Command.Exception if path is not a directory */ ! private static final void checkPathArgument(File path, String type) throws Command.Exception { checkIfPathExists(path, type); checkIfPathIsReadable(path, type); checkIfPathIsDirectory(path, type); --- 915,925 ---- * @param path to check * @param type of path being checked * * @throws Command.Exception if path is not a directory */ ! private static void checkPathArgument(File path, String type) throws Command.Exception { checkIfPathExists(path, type); checkIfPathIsReadable(path, type); checkIfPathIsDirectory(path, type);