Skip to content
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

Merged
merged 8 commits into from
Aug 27, 2020

Conversation

ZacSweers
Copy link
Contributor

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.

doctor {
  javaHome {
    failOnError = true
    extraMessage = "Read our wiki here: ..."
  }
}

Resolves #98

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: ..."
  }
}
```
Copy link
Owner

@runningcode runningcode left a 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)
Copy link
Owner

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).

Copy link
Contributor Author

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")
Copy link
Owner

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?

Copy link
Contributor Author

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)

Copy link
Contributor Author

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

ZacSweers and others added 3 commits August 17, 2020 18:36
Co-authored-by: Nelson Osacky <nelson@osacky.com>
Co-authored-by: Nelson Osacky <nelson@osacky.com>
}
}

override fun onFinish(): Finish {
if (recordedErrors.isNotEmpty()) {
logger.error(recordedErrors.joinToString("\n\n"))
Copy link
Owner

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:

Suggested change
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

@runningcode
Copy link
Owner

Can you push another commit? I think that should trigger the circle ci job this time.

@ZacSweers
Copy link
Contributor Author

I can't see the CI results because circleci wants me to make an account
image

@ZacSweers
Copy link
Contributor Author

These pass for me locally 🤔

@runningcode
Copy link
Owner

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.

@runningcode
Copy link
Owner

Can you rebase to include this? #107
Should fix the test issues.

@ZacSweers
Copy link
Contributor Author

Green!

@runningcode runningcode merged commit 872932a into runningcode:master Aug 27, 2020
@ZacSweers ZacSweers deleted the z/moreJavaHome branch August 28, 2020 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make JAVA_HOME issues configurable as warnings
2 participants