Skip to content

Commit

Permalink
more sophisticated output forwarding from exec tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
original-brownbear committed Nov 6, 2017
1 parent c8d704c commit 87dc146
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ RUN ln -s /tmp/vendor /opt/logstash/vendor

ADD gradlew /opt/logstash/gradlew
ADD gradle/wrapper /opt/logstash/gradle/wrapper
ADD buildSrc /opt/logstash/buildSrc
RUN /opt/logstash/gradlew wrapper

ADD versions.yml /opt/logstash/versions.yml
Expand Down
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ apply plugin: 'de.undercouch.download'

import de.undercouch.gradle.tasks.download.Download
import de.undercouch.gradle.tasks.download.Verify
import org.logstash.gradle.ExecLogOutputStream
import org.yaml.snakeyaml.Yaml

allprojects {
Expand Down Expand Up @@ -144,11 +145,9 @@ task installTestGems(dependsOn: downloadAndInstallJRuby, type: Exec) {
outputs.files file("${projectDir}/Gemfile.lock")
outputs.files fileTree("${projectDir}/vendor/bundle/gems")
outputs.files fileTree("${projectDir}/vendor/jruby")
standardOutput = new ExecLogOutputStream(System.out)
errorOutput = new ExecLogOutputStream(System.err)
commandLine './vendor/jruby/bin/jruby', "${projectDir}/vendor/jruby/bin/rake".toString(), "test:install-core"
standardOutput = new ByteArrayOutputStream()
ext.output = {
standardOutput.toString()
}
}

// If you are running a JRuby snapshot we will skip the integrity check.
Expand Down
3 changes: 3 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
group = 'org.logstash'

apply plugin: 'java'
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.logstash.gradle;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

/**
* Stream that can be used to forward Gradle Exec task output to an arbitrary {@link PrintStream}.
*/
public final class ExecLogOutputStream extends ByteArrayOutputStream {

/**
* Underlying {@link PrintStream} to flush output to.
*/
private final PrintStream stream;

/**
* Ctor.
* @param stream PrintStream to flush to
*/
public ExecLogOutputStream(final PrintStream stream) {
this.stream = stream;
}

@Override
public synchronized void flush() {
stream.print(toString());
reset();
}
}

0 comments on commit 87dc146

Please sign in to comment.