From 2ab3f1b95c93b2f085dfec19e35996c82209ebc8 Mon Sep 17 00:00:00 2001 From: Peter Kriens Date: Tue, 18 Oct 2022 16:10:46 +0200 Subject: [PATCH] [#5395] -export failure deadlock] This patch will not block the saving of the files when the export fails. Then the next time it all falls in place again. Signed-off-by: Peter Kriens --- .../src/aQute/bnd/build/Project.java | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/biz.aQute.bndlib/src/aQute/bnd/build/Project.java b/biz.aQute.bndlib/src/aQute/bnd/build/Project.java index 33b1b1e3fc..32d21a8e72 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/build/Project.java +++ b/biz.aQute.bndlib/src/aQute/bnd/build/Project.java @@ -1966,30 +1966,34 @@ public File[] buildLocal(boolean underTest) throws Exception { return null; } - Map exports = builder.doExports(selectedRunFiles); - getInfo(builder); if (!isOk()) { return null; } - for (Map.Entry ee : exports.entrySet()) { - try (Resource resource = ee.getValue()) { - File outputFile = ee.getKey(); - File actual = write(resource::write, outputFile); + if (!selectedRunFiles.isEmpty()) { + Map exports = builder.doExports(selectedRunFiles); - if (actual != null) { - buildFilesSet.add(actual); - } else { - error("Could not save %s", outputFile); + getInfo(builder); + + if (isOk()) { + + for (Map.Entry ee : exports.entrySet()) { + try (Resource resource = ee.getValue()) { + File outputFile = ee.getKey(); + File actual = write(resource::write, outputFile); + + if (actual != null) { + buildFilesSet.add(actual); + } else { + error("Could not save %s", outputFile); + } + } } } } - if (!isOk()) { - return null; - } boolean bfsWrite = !bfs.exists() || (lastModified > bfs.lastModified()); if (buildfiles != null) { @@ -2622,7 +2626,8 @@ public Jar getValidJar(Jar jar, String id) throws Exception { return jar; } - public String _project(@SuppressWarnings("unused") String args[]) { + public String _project(@SuppressWarnings("unused") + String args[]) { return IO.absolutePath(getBase()); } @@ -2713,7 +2718,8 @@ public void action(String command, Object... args) throws Exception { /** * Run all before command plugins */ - void before(@SuppressWarnings("unused") Project p, String a) { + void before(@SuppressWarnings("unused") + Project p, String a) { List testPlugins = getPlugins(CommandPlugin.class); for (CommandPlugin testPlugin : testPlugins) { testPlugin.before(this, a); @@ -2723,7 +2729,8 @@ void before(@SuppressWarnings("unused") Project p, String a) { /** * Run all after command plugins */ - void after(@SuppressWarnings("unused") Project p, String a, Throwable t) { + void after(@SuppressWarnings("unused") + Project p, String a, Throwable t) { List testPlugins = getPlugins(CommandPlugin.class); for (int i = testPlugins.size() - 1; i >= 0; i--) { testPlugins.get(i) @@ -2737,7 +2744,8 @@ public void refreshAll() { } @SuppressWarnings("unchecked") - public void script(@SuppressWarnings("unused") String type, String script) throws Exception { + public void script(@SuppressWarnings("unused") + String type, String script) throws Exception { script(type, script, new Object[0]); } @@ -2760,7 +2768,8 @@ public void script(String type, String script, Object... args) throws Exception .eval((Map) p, new StringReader(script)); } - public String _repos(@SuppressWarnings("unused") String args[]) throws Exception { + public String _repos(@SuppressWarnings("unused") + String args[]) throws Exception { List repos = getPlugins(RepositoryPlugin.class); List names = new ArrayList<>(); for (RepositoryPlugin rp : repos)