I created a small utility to run some command with...
# plugin-development
g
I created a small utility to run some command within a plugin
Copy code
context(project: Project)
operator fun String.invoke(): String {
    val output = ByteArrayOutputStream()
    project.providers.exec {
        commandLine(split(Regex("\\s+")))
        standardOutput = output
    }
    return output.toString().trim()
}
but whenever I try to execute some command, I do get > An exception occurred applying plugin request [id: 'io.github.theapache64.korduino.gradle', version: '0.0.1'] > > Failed to apply plugin 'io.github.theapache64.korduino.gradle'. > > Could not create provider for value source ProcessOutputValueSource.
this seems working though
Copy code
return project.providers.exec {
        commandLine("pwd")
    }.standardOutput.asText.get()
v
If you would enable
--stacktrace
you would probably get a clear error that you must not set
standardOutput
when using
providers.exec
.
👍 1