diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2022-04-02 06:12:50 +0200 |
---|---|---|
committer | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2022-04-02 06:12:50 +0200 |
commit | c8607ba782f90ef847488f0fc5bdc365c1e83317 (patch) | |
tree | fe8aa5ee5835b69f2f21f74a300f8efc32e52e69 /src/eclipseAgent/lombok/eclipse | |
parent | 110434ff60a14d2dfe8014459ffbea3ce7d6388b (diff) | |
download | lombok-c8607ba782f90ef847488f0fc5bdc365c1e83317.tar.gz lombok-c8607ba782f90ef847488f0fc5bdc365c1e83317.tar.bz2 lombok-c8607ba782f90ef847488f0fc5bdc365c1e83317.zip |
[#3143] Review and update jopatai's work on the maven/ecj agent jar
* Update copyright headers
* Update code style (tabs, not spaces, spaces around + operator - that's about it)
* Use `x.class.getResourceAsStream`, not `x.getClass().` - minor mostly irrelevant nit.
* Rename and re-locate the jar itself.
* 'ecj' as an alias for this command seems a bit too cavalier' removed it.
* The source is in its own 'root' src dir, it doesn't really fit in the eclipse agent sources - it's more a maven agent.
* Fixed a bug where a filehandle wasn't safe closed. Mostly irrelevant (JVM would quite afterwards anyway).
* Slight rewording of the ecj docs.
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse')
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/MavenEcjBootstrapApp.java | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/MavenEcjBootstrapApp.java b/src/eclipseAgent/lombok/eclipse/agent/MavenEcjBootstrapApp.java index d08422be..7f9d4d36 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/MavenEcjBootstrapApp.java +++ b/src/eclipseAgent/lombok/eclipse/agent/MavenEcjBootstrapApp.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2022 The Project Lombok Authors. + * Copyright (C) 2022 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,7 +26,6 @@ import java.io.FileOutputStream; import java.io.FileWriter; import java.io.InputStream; import java.io.PrintStream; -import java.util.Arrays; import java.util.List; import com.zwitserloot.cmdreader.CmdReader; @@ -45,18 +44,14 @@ public class MavenEcjBootstrapApp extends LombokApp { @Override public String getAppDescription() { return "Creates .mvn/jvm.config and .mvn/lombok-bootstrap.jar for\n" + - "use with the ECJ compiler."; - } - - @Override public List<String> getAppAliases() { - return Arrays.asList("ecj"); + "use with the ECJ compiler."; } private static class CmdArgs { @Shorthand("w") @Description("Overwrite existing files. Defaults to false.") boolean overwrite = false; - + @Shorthand("o") @Description("The root of a Maven project. Defaults to the current working directory.") String output; @@ -103,7 +98,7 @@ public class MavenEcjBootstrapApp extends LombokApp { err = e; } if (result != 0) { - System.err.println("Could not create "+mvn.getPath()); + System.err.println("Could not create " + mvn.getPath()); if (err != null) err.printStackTrace(System.err); } return result; @@ -136,15 +131,21 @@ public class MavenEcjBootstrapApp extends LombokApp { return 1; } try { - InputStream input = this.getClass().getResourceAsStream("/lombok/eclipse/agent/lombok-bootstrap.jar"); + InputStream input = MavenEcjBootstrapApp.class.getResourceAsStream("/lombok/launch/mavenEcjBootstrapAgent.jar"); FileOutputStream output = new FileOutputStream(jar); - byte[] buffer = new byte[4096]; - int length; - while ((length = input.read(buffer)) > 0) output.write(buffer, 0, length); - output.flush(); - output.close(); - System.out.println("Successfully created: " + canonical(jar)); - return 0; + try { + byte[] buffer = new byte[4096]; + int length; + while ((length = input.read(buffer)) > 0) output.write(buffer, 0, length); + output.flush(); + output.close(); + System.out.println("Successfully created: " + canonical(jar)); + return 0; + } finally { + try { + output.close(); + } catch (Exception ignore) {} + } } catch (Exception e) { System.err.println("Could not create: " + canonical(jar)); e.printStackTrace(System.err); |