-
-
Notifications
You must be signed in to change notification settings - Fork 140
Show only the error message when build tool fails #1472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6bdc982
Show only the error message when built tool fails
vtrifonov 710e1ed
fixed error logging when there's an error not from BuildToolTask
vtrifonov df9f599
Copy helper gradle files from app folder when building
vmutafov 28d9536
catch Throwable instead of Exception to catch Errors as well
vtrifonov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,4 +20,5 @@ bin/ | |
| .settings | ||
|
|
||
| .classpath | ||
| android-runtime.iml | ||
| android-runtime.iml | ||
| test-app/build-tools/*.log | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import static org.gradle.internal.logging.text.StyledTextOutput.Style | ||
|
|
||
| class BuildToolTask extends JavaExec { | ||
| void setOutputs(def logger) { | ||
| def logFile = new File("$workingDir/${name}.log") | ||
| if(logFile.exists()) { | ||
| logFile.delete() | ||
| } | ||
| standardOutput new FileOutputStream(logFile) | ||
| errorOutput new FailureOutputStream(logger, logFile) | ||
| } | ||
| } | ||
|
|
||
| class FailureOutputStream extends OutputStream { | ||
| private logger | ||
| private File logFile | ||
| private currentLine = "" | ||
| private firstWrite = true | ||
| FailureOutputStream(inLogger, inLogFile) { | ||
| logger = inLogger | ||
| logFile = inLogFile | ||
| } | ||
|
|
||
| @Override | ||
| void write(int i) throws IOException { | ||
| if(firstWrite) { | ||
| println "" | ||
| firstWrite = false | ||
| } | ||
| currentLine += String.valueOf((char) i) | ||
| } | ||
|
|
||
| @Override | ||
| void flush() { | ||
| if(currentLine?.trim()) { | ||
| logger.withStyle(Style.Failure).println currentLine.trim() | ||
| currentLine = "" | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| void close() { | ||
| if(!firstWrite && logFile.exists()) { | ||
| logger.withStyle(Style.Info).println "Detailed log here: ${logFile.getAbsolutePath()}\n" | ||
| } | ||
| super.close() | ||
| } | ||
| } | ||
|
|
||
| ext.BuildToolTask = BuildToolTask |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import org.gradle.internal.logging.text.StyledTextOutputFactory | ||
|
|
||
| import static org.gradle.internal.logging.text.StyledTextOutput.Style | ||
| def outLogger = services.get(StyledTextOutputFactory).create("colouredOutputLogger") | ||
|
|
||
| class CustomExecutionLogger extends BuildAdapter implements TaskExecutionListener { | ||
| private logger | ||
| private failedTask | ||
|
|
||
| CustomExecutionLogger(passedLogger) { | ||
| logger = passedLogger | ||
| } | ||
|
|
||
| void buildStarted(Gradle gradle) { | ||
| failedTask = null | ||
| } | ||
|
|
||
| void beforeExecute(Task task) { | ||
| } | ||
|
|
||
| void afterExecute(Task task, TaskState state) { | ||
| def failure = state.getFailure() | ||
| if(failure) { | ||
| failedTask = task | ||
| } | ||
| } | ||
|
|
||
| void buildFinished(BuildResult result) { | ||
| def failure = result.getFailure() | ||
| if(failure) { | ||
| if(failedTask && (failedTask.getClass().getName().contains("BuildToolTask"))) { | ||
| // the error from this task is already logged | ||
| return | ||
| } | ||
|
|
||
| println "" | ||
| logger.withStyle(Style.FailureHeader).println failure.getMessage() | ||
|
|
||
| def causeException = failure.getCause() | ||
| while (causeException != null) { | ||
| failure = causeException | ||
| causeException = failure.getCause() | ||
| } | ||
| if(failure != causeException) { | ||
| logger.withStyle(Style.Failure).println failure.getMessage() | ||
| } | ||
| println "" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| gradle.useLogger(new CustomExecutionLogger(outLogger)) |
Submodule android-dts-generator
updated
1 files
| +16 −10 | dts-generator/src/main/java/com/telerik/Main.java |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.