{"record":{"id":"2befe56fe5a8eb3f","repo":"elastic/elasticsearch","slug":"capturing-output-is-not-supported-when-indentingco","errorCode":null,"errorMessage":"Capturing output is not supported when indentingConsoleOutput is configured.","messagePattern":"Capturing output is not supported when indentingConsoleOutput is configured\\.","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/LoggedExec.java","lineNumber":145,"sourceCode":"        getNonTrackedEnvironment().putAll(providerFactory.environmentVariablesPrefixedBy(\"VAULT\"));\n        Provider<String> javaToolchainHome = providerFactory.environmentVariable(\"JAVA_TOOLCHAIN_HOME\");\n        if (javaToolchainHome.isPresent()) {\n            getEnvironment().put(\"JAVA_TOOLCHAIN_HOME\", javaToolchainHome);\n        }\n        Provider<String> javaRuntimeHome = providerFactory.environmentVariable(\"RUNTIME_JAVA_HOME\");\n        if (javaRuntimeHome.isPresent()) {\n            getEnvironment().put(\"RUNTIME_JAVA_HOME\", javaRuntimeHome);\n        }\n        Provider<String> path = providerFactory.environmentVariable(\"PATH\");\n        if (path.isPresent()) {\n            getEnvironment().put(\"PATH\", path);\n        }\n    }\n\n    @TaskAction\n    public void run() {\n        if (getCaptureOutput().get() && getIndentingConsoleOutput().isPresent()) {\n            throw new GradleException(\"Capturing output is not supported when indentingConsoleOutput is configured.\");\n        }\n        Consumer<Logger> outputLogger;\n        OutputStream out = new ByteArrayOutputStream();\n        outputLogger = getIndentingConsoleOutput().isPresent() ? logger -> {} : logger -> logger.error(byteStreamToString(out));\n\n        OutputStream finalOutputStream = getIndentingConsoleOutput().isPresent()\n            ? new IndentingOutputStream(System.out, getIndentingConsoleOutput().get())\n            : out;\n        ExecResult execResult = execOperations.exec(execSpec -> {\n            execSpec.setIgnoreExitValue(true);\n            execSpec.setStandardOutput(finalOutputStream);\n            execSpec.setErrorOutput(finalOutputStream);\n            execSpec.setExecutable(getExecutable().get());\n            execSpec.environment(getEnvironment().get());\n            execSpec.environment(getNonTrackedEnvironment().get());\n            if (getArgs().isPresent()) {\n                execSpec.setArgs(getArgs().get());\n            }","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/LoggedExec.java#L127-L163","documentation":"LoggedExec.run() throws at task execution when both getCaptureOutput() is true AND getIndentingConsoleOutput() is present. The two modes are mutually exclusive: capture buffers output to a ByteArrayOutputStream for later getOutput() retrieval, while indenting streams output directly to System.out with a version-prefixed indent. Enabling both is contradictory (you cannot both buffer for later and stream live).","triggerScenarios":"Configuring a LoggedExec task with both getCaptureOutput().set(true) and getIndentingConsoleOutput().set(someVersion) on the same task instance. The check runs at @TaskAction time, so the failure appears during task execution, not configuration.","commonSituations":"Copy-pasting task config that set captureOutput for programmatic output access while another block set indentingConsoleOutput for pretty CI logs; upgrading Gradle task definitions where these were previously compatible.","solutions":["If you need programmatic access to output, keep captureOutput=true and remove indentingConsoleOutput.","If you want indented live console output, keep indentingConsoleOutput and remove captureOutput (you cannot call getOutput()).","Split into two LoggedExec tasks if both behaviors are genuinely needed for different consumers."],"exampleFix":"// before\nloggedExec {\n  captureOutput = true\n  indentingConsoleOutput = '8.0' // throws at execution\n}\n// after (choose one)\nloggedExec {\n  captureOutput = true\n}\n// OR\nloggedExec {\n  indentingConsoleOutput = '8.0'\n}","handlingStrategy":"validation","validationCode":"if (loggedExec.getCaptureOutput().get() && loggedExec.getIndentingConsoleOutput().isPresent()) {\n    throw new IllegalStateException(\"captureOutput and indentingConsoleOutput are mutually exclusive on \" + loggedExec.getName());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Choose one output mode per LoggedExec task: capture (for getOutput()) OR indent (for live pretty logs).","Audit task configurations when copy-pasting between tasks that used different modes.","If both behaviors are needed, split into two tasks."],"tags":["gradle","build-tools","exec","configuration-validation"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}