org.ysb33r.grolifant5.internal.v8.runnable.DefaultExecOutput.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grolifant5-80 Show documentation
Show all versions of grolifant5-80 Show documentation
Building blocks which are key to writing various kinds of Gradle plugins, but which are not easily obtainable from Gradle core itself
/*
* ============================================================================
* (C) Copyright Schalk W. Cronje 2016 - 2024
*
* This software is licensed under the Apache License 2.0
* See http://www.apache.org/licenses/LICENSE-2.0 for license details
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
* ============================================================================
*/
package org.ysb33r.grolifant5.internal.v8.runnable
import groovy.transform.CompileStatic
import org.gradle.api.provider.Provider
import org.gradle.process.ExecResult
import org.ysb33r.grolifant5.api.core.runnable.ExecOutput
import org.ysb33r.grolifant5.api.core.runnable.ExecStreamContent
/**
* Wraps the output from an execution.
*
* Similar to {@link org.gradle.process.ExecOutput}.
*
* @author Schalk W. Cronjé
*
* @since 5.0
*/
@CompileStatic
class DefaultExecOutput implements ExecOutput {
static ExecOutput fromResult(org.gradle.process.ExecOutput execResult) {
new DefaultExecOutput(
execResult.result,
new StreamContent(execResult.standardOutput.asText, execResult.standardOutput.asBytes),
new StreamContent(execResult.standardError.asText, execResult.standardError.asBytes)
)
}
final Provider result
final ExecStreamContent standardOutput
final ExecStreamContent standardError
private DefaultExecOutput(
Provider result,
ExecStreamContent out,
ExecStreamContent err
) {
this.result = result
this.standardOutput = out
this.standardError = err
}
private static class StreamContent implements ExecStreamContent {
final Provider asText
final Provider asBytes
StreamContent(
final Provider asText,
final Provider asBytes
) {
this.asText = asText
this.asBytes = asBytes
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy