-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add more granularity to JAVA_HOME
checks
#104
Conversation
This adds some more granularity and functionality to `JAVA_HOME` in the plugin. Namely - now you can configure fail-vs-log behavior and add a custom extra message. This also changes/breaks the API for a nested control block. ```gradle doctor { javaHome { failOnError = true extraMessage = "Read our wiki here: ..." } } ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! Thank you so much for the contribution, just some small things and we'll be good to merge this!
if (failOnError) { | ||
throw GradleException(pill) | ||
} else { | ||
logger.error(pill) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks great, but I think we want to have this print the warning at the end of the build.
to do this, you can return the pill
in the onFinish()
method as Finish.Message(pill)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works, just keep a list of all of them and print all at the end?
|
||
val result = createRunner() | ||
.withEnvironment(mapOf("JAVA_HOME" to "foo")) | ||
.withArguments("tasks") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does adding forwardOutput()
give any clues as to why this is failing in the logs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea, I was just copying the previous test (which is also ignored)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was leaving these as a toe-hold
Co-authored-by: Nelson Osacky <nelson@osacky.com>
} | ||
} | ||
|
||
override fun onFinish(): Finish { | ||
if (recordedErrors.isNotEmpty()) { | ||
logger.error(recordedErrors.joinToString("\n\n")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have my own silly API design here that we'll need to follow in order to get a consistent printout of all the error messages together. A build can generate multiple warnings or errors so they are grouped using this API.
To get a consistent printout and so that all the errors are printed together at the end of the build we'll need to do something like this:
logger.error(recordedErrors.joinToString("\n\n")) | |
return Finish.Message(recordedErrors.joinToString("\n\n")) |
That being said, you might need to add a new class to Finish
where you can pass a list of messages.
Here's an example from DownloadSpeedMeasurer: https://github.com/runningcode/gradle-doctor/blob/master/doctor-plugin/src/main/java/com/osacky/doctor/DownloadSpeedMeasurer.kt#L50
Can you push another commit? I think that should trigger the circle ci job this time. |
These pass for me locally 🤔 |
The failure is due to some memory misconfiguration for the test task. This has been happening more and more lately in this project. I opened a PR to see if I can fix this. Otherwise even if you need to create a circle CI account you should still be able to see the test results. It is an open source project so everyone can see them. I can understand not wanting to create an account though. We'll need to change the way the logging is working (like this #104 (comment)) before we can merge this though. Let me know if you would like me to take that over. |
Can you rebase to include this? #107 |
Green! |
This adds some more granularity and functionality to
JAVA_HOME
in the plugin. Namely - now you can configure fail-vs-log behavior and add a custom extra message. This also changes/breaks the API for a nested control block.Resolves #98