You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2018/12/15 16:48:41 UTC
ant git commit: directly log link's output to Ant's log
Repository: ant
Updated Branches:
refs/heads/logoutput-jmod-link [created] b74d5b366
directly log link's output to Ant's log
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/b74d5b36
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/b74d5b36
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/b74d5b36
Branch: refs/heads/logoutput-jmod-link
Commit: b74d5b366d6b28f20b3b07c0b129005646209764
Parents: 6b576f1
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sat Dec 15 17:48:06 2018 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Dec 15 17:48:06 2018 +0100
----------------------------------------------------------------------
.../apache/tools/ant/taskdefs/modules/Link.java | 32 +++++++++-----------
1 file changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/b74d5b36/src/main/org/apache/tools/ant/taskdefs/modules/Link.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/modules/Link.java b/src/main/org/apache/tools/ant/taskdefs/modules/Link.java
index 343b867..c827cca 100644
--- a/src/main/org/apache/tools/ant/taskdefs/modules/Link.java
+++ b/src/main/org/apache/tools/ant/taskdefs/modules/Link.java
@@ -18,11 +18,12 @@
package org.apache.tools.ant.taskdefs.modules;
+import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
import java.io.PrintStream;
-import java.io.ByteArrayOutputStream;
import java.io.Reader;
-import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
@@ -52,6 +53,8 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.LogOutputStream;
+
import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.LogLevel;
import org.apache.tools.ant.types.Path;
@@ -59,10 +62,10 @@ import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.types.ResourceCollection;
import org.apache.tools.ant.util.CompositeMapper;
-import org.apache.tools.ant.util.MergingMapper;
-
import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.util.MergingMapper;
import org.apache.tools.ant.util.ResourceUtils;
+import org.apache.tools.ant.util.TeeOutputStream;
/**
* Assembles jmod files into an executable image. Equivalent to the
@@ -1943,10 +1946,16 @@ extends Task {
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
+ OutputStream sysout = stdout;
+ OutputStream syserr = stderr;
+ if (verboseLevel != null) {
+ sysout = new TeeOutputStream(stdout, new LogOutputStream(this, verboseLevel.getLevel()));
+ syserr = new TeeOutputStream(stderr, new LogOutputStream(this, verboseLevel.getLevel()));
+ }
int exitCode;
- try (PrintStream out = new PrintStream(stdout);
- PrintStream err = new PrintStream(stderr)) {
+ try (PrintStream out = new PrintStream(sysout);
+ PrintStream err = new PrintStream(syserr)) {
exitCode = jlink.run(out, err, args.toArray(new String[0]));
}
@@ -1964,17 +1973,6 @@ extends Task {
throw new BuildException(message.toString(), getLocation());
}
- if (verboseLevel != null) {
- int level = verboseLevel.getLevel();
-
- if (stdout.size() > 0) {
- log(stdout.toString(), level);
- }
- if (stderr.size() > 0) {
- log(stderr.toString(), level);
- }
- }
-
log("Created " + outputDir.getAbsolutePath(), Project.MSG_INFO);
}