236 return 2; 237 } 238 239 if (options.has("dry-run")) { 240 return 0; 241 } 242 243 boolean hasOutput = false; 244 245 if (options.has("d")) { 246 hasOutput = true; 247 Path dest = Paths.get((String) options.valueOf("d")); 248 dest = dest.toAbsolutePath(); 249 try { 250 if (!Files.exists(dest)) { 251 Files.createDirectories(dest); 252 } else if (!Files.isDirectory(dest)) { 253 ctx.err.println(format("not.a.directory", dest)); 254 return 4; 255 } 256 ctx.collectClassFiles(dest, targetPackage); 257 } catch (IOException ex) { 258 ctx.err.println(format("cannot.write.class.file", dest, ex)); 259 if (Main.DEBUG) { 260 ex.printStackTrace(ctx.err); 261 } 262 return 5; 263 } 264 } 265 266 String outputName; 267 if (options.has("o")) { 268 outputName = (String) options.valueOf("o"); 269 } else if (hasOutput) { 270 return 0; 271 } else { 272 outputName = options.nonOptionArguments().get(0) + ".jar"; 273 } 274 275 try { 276 ctx.collectJarFile(Paths.get(outputName), targetPackage); 277 } catch (IOException ex) { 278 ctx.err.println(format("cannot.write.jar.file", outputName, ex)); 279 if (Main.DEBUG) { 280 ex.printStackTrace(ctx.err); 281 } 282 return 3; 283 } 284 285 return 0; 286 } 287 288 private static Path getBuiltinHeadersDir() { 289 return Paths.get(System.getProperty("java.home"), "conf", "jextract"); 290 } 291 292 public static void main(String... args) { 293 Main instance = new Main(new Context()); 294 295 System.exit(instance.run(args)); 296 } | 236 return 2; 237 } 238 239 if (options.has("dry-run")) { 240 return 0; 241 } 242 243 boolean hasOutput = false; 244 245 if (options.has("d")) { 246 hasOutput = true; 247 Path dest = Paths.get((String) options.valueOf("d")); 248 dest = dest.toAbsolutePath(); 249 try { 250 if (!Files.exists(dest)) { 251 Files.createDirectories(dest); 252 } else if (!Files.isDirectory(dest)) { 253 ctx.err.println(format("not.a.directory", dest)); 254 return 4; 255 } 256 ctx.collectClassFiles(dest, args, targetPackage); 257 } catch (IOException ex) { 258 ctx.err.println(format("cannot.write.class.file", dest, ex)); 259 if (Main.DEBUG) { 260 ex.printStackTrace(ctx.err); 261 } 262 return 5; 263 } 264 } 265 266 String outputName; 267 if (options.has("o")) { 268 outputName = (String) options.valueOf("o"); 269 } else if (hasOutput) { 270 return 0; 271 } else { 272 outputName = options.nonOptionArguments().get(0) + ".jar"; 273 } 274 275 try { 276 ctx.collectJarFile(Paths.get(outputName), args, targetPackage); 277 } catch (IOException ex) { 278 ctx.err.println(format("cannot.write.jar.file", outputName, ex)); 279 if (Main.DEBUG) { 280 ex.printStackTrace(ctx.err); 281 } 282 return 3; 283 } 284 285 return 0; 286 } 287 288 private static Path getBuiltinHeadersDir() { 289 return Paths.get(System.getProperty("java.home"), "conf", "jextract"); 290 } 291 292 public static void main(String... args) { 293 Main instance = new Main(new Context()); 294 295 System.exit(instance.run(args)); 296 } |