Skip to content

Conversation

@quintesse
Copy link
Contributor

Fixes #1857

@quintesse quintesse changed the title Separated JDK management code into its own module refactor: Separated JDK management code into its own module Nov 27, 2024
@quintesse quintesse force-pushed the jdkman_lib branch 2 times, most recently from 8c7ba7e to 4489268 Compare November 28, 2024 19:44
@quintesse quintesse force-pushed the jdkman_lib branch 2 times, most recently from 2d66e04 to 21e1e5a Compare December 13, 2024 22:05
@quintesse quintesse force-pushed the jdkman_lib branch 5 times, most recently from 260870f to 0f35aa5 Compare January 13, 2025 17:42
@quintesse quintesse force-pushed the jdkman_lib branch 7 times, most recently from e0639c0 to f5e2bb3 Compare January 27, 2025 19:56
@quintesse quintesse force-pushed the jdkman_lib branch 6 times, most recently from 1d133d2 to 43b8906 Compare February 5, 2025 23:04
@maxandersen
Copy link
Collaborator

small thing: how come the package is called .jvm when everything else is named JDK+something ?

* This JUL Formatter is used to format JUL log messages in such a way that they
* look similar to JBang log messages.
*/
public class JBangFormatter extends Formatter {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm - originally I explicitly kept "ux output" separate from "logging output" ...is there a reason why we want to redirect all output to JUL ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, you might not want all of the logging output to be confused with UX output, I can understand that.

But there are two things that come to mind:

  1. our output mechanism sure does look like logging (having levels like warn, inifo, error, debug, etc)
  2. to make the new module really independent from JBang I needed a way to generate output that didn't use JBang's system and I didn't want to introduce some new interface

So that's why I decided to switch the module's output to use plain logging but then the output would look different from before, so that's why I decided to capture the logging output and make it look like JBang output.

Now, I thought it would be nice to do the same for anything that could be outputting logging info, but that's just something I decided in the moment and we could easily change that to only work for the module and nothing else.

@@ -0,0 +1,4 @@
handlers=java.util.logging.ConsoleHandler
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this now? (not against it - just want to understand the rationale)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just to make any logging appear as if it comes directly from JBang (with our normal "[jbang]" prefix for every line), which was needed to make the logging output from the new module appear exactly the same as it did before.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok but:
a) what makes it end up in stderr not stdout?
b) doesn't this meddling with jul logging make it harder to embed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a) what do you mean? all JBang messages go to stderr, right? (at least any of the xxxMsg() methods, which is what the JUL logging replaces here)

b) also not sure what you mean here. Using JUL logging is pretty normal, isn't it? You could use it just fine even with logging completely disabled. There's no essential output being generated using JUL.

@quintesse
Copy link
Contributor Author

small thing: how come the package is called .jvm when everything else is named JDK+something ?

Historical reasons, because that was the tool is called that I want to use this module for. But it can of course be anything we want.

@quintesse quintesse force-pushed the jdkman_lib branch 2 times, most recently from efdcb7a to 095ae63 Compare March 5, 2025 13:42
@quintesse quintesse marked this pull request as ready for review March 5, 2025 13:46
@quintesse
Copy link
Contributor Author

Yay, all checks green! I've marked the PR as final now that devkitman has been published and all the tests pass.

build.gradle Outdated
implementation 'com.offbytwo:docopt:0.6.0.20150202'
implementation 'dev.jbang:devkitman:0.1.2'

// implementation 'com.offbytwo:docopt:0.6.0.20150202'
Copy link
Contributor Author

@quintesse quintesse Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably shouldn't be here, but it seemed unused to I commented it out and it slipped into the PR. If you want I can remove it from the PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol - thats a ancient leftover from very early jbang...never needed. lets just nuke it.

shadowJar {
minimize() {
//exclude(dependency('org.slf4j:slf4j-api:.*'))
exclude(dependency('dev.jbang:devkitman:.*'))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

devkitman uses services so this is needed or classes will be missing.

@quintesse quintesse force-pushed the jdkman_lib branch 3 times, most recently from c1b7b49 to cc0c494 Compare March 5, 2025 17:14
@BeforeAll
static void init() throws URISyntaxException, IOException {
try {
// The default ConsoleHandler for logging doesn't like us changing
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah so all this is why i refrained from using JUL for jbang output. why is this in the test class? shouldn't it be in main code path too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in this module JUL is only used for logging, there is no essential output being generated with it. It's a library, it shouldn't do any essential output by itself, it only returns information which the caller can then decide to output or not. The logging is really only used for logging.
Thing is we do have tests that specifically check for certain log lines, we shouldn't really be doing that but I didn't want to change the tests so I added this code to make sure that the output between monolithic JBang and modular JBang would remain 99.9% the same.

@quintesse quintesse force-pushed the jdkman_lib branch 2 times, most recently from 003435a to 1401ab1 Compare March 14, 2025 18:08
@maxandersen maxandersen merged commit edf06a1 into jbangdev:main Mar 15, 2025
10 checks passed
maxandersen added a commit to maxandersen/jbang that referenced this pull request Mar 16, 2025
maxandersen added a commit that referenced this pull request Mar 16, 2025
* fix: stop using comprimised github action

* Revert "refactor: Now using `devkitman` module (#1874)"

This reverts commit edf06a1.
quintesse added a commit to quintesse/jbang that referenced this pull request Mar 28, 2025
quintesse added a commit to quintesse/jbang that referenced this pull request Apr 19, 2025
quintesse added a commit to quintesse/jbang that referenced this pull request Apr 29, 2025
maxandersen pushed a commit to quintesse/jbang that referenced this pull request May 3, 2025
maxandersen pushed a commit to quintesse/jbang that referenced this pull request May 3, 2025
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.

Refactor JDK management code into separate module

2 participants