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

Configure Built-In plantuml to not steal keyboard focus on MacOS X #547

Closed
arthurvl opened this issue Feb 16, 2024 · 5 comments
Closed

Configure Built-In plantuml to not steal keyboard focus on MacOS X #547

arthurvl opened this issue Feb 16, 2024 · 5 comments

Comments

@arthurvl
Copy link

Is your feature request related to a problem? Please describe.
Running a JavaDoc with UMLDoclet from maven repeatedly steals keyboard focus on MacOS X. This makes it hard to use the computer while the javadoc generation is running.

Describe the solution you'd like
It would be good to provide a mechanism to set the java.awt.headless=true property for the run context of the built-in plantuml, or do so by default.

Describe alternatives you've considered
Setting java.awt.headless through _JAVA_OPTIONS works but is somewhat clunky. Neither JAVA_OPTS nor MAVEN_OPTS will be picked up. Setting it through additionalJOptions or additionalOptions also does not work. Having to set it at all can now only be documented in a readme or faq, rather than set in e.g. the pom.xml.

@sjoerdtalsma
Copy link
Contributor

Thank you for the investigation.
I looked into this and there seems to be something already setting the 'headless' state before the doclet class even gets loaded:

public class UMLDoclet extends StandardDoclet {
    static {
        System.setProperty("java.awt.headless", "true");
    }
    // ...
    public UMLDoclet() {
        super();
        this.config = new DocletConfig();
        System.out.println("Headless? java.awt.headless=" + System.getProperty("java.awt.headless")
                + ", GraphicsEnvironment.isHeadless()=" + java.awt.GraphicsEnvironment.isHeadless());
    }
}

Results in: Headless? java.awt.headless=true, GraphicsEnvironment.isHeadless()=false

The java module system also prevents us from using filthy reflection tools to try manipulate the private static GraphicsEnvironment.headless field directly.

Do you have other suggestions that will autoconfigure the built-in PlantUML behave decently?

@sjoerdtalsma
Copy link
Contributor

Perhaps the maven javadoc plugin could (/should) set this system property by default?
I can't imagine any usecase for running anything non-headless from the javadoc plugin.

@sjoerdtalsma
Copy link
Contributor

Results in: Headless? java.awt.headless=true, GraphicsEnvironment.isHeadless()=false

Okay, that may have been a bit premature running tests from my IDE 🫣.

Commandline maven gives me:

[INFO] --- maven-javadoc-plugin:3.6.3:jar (attach-javadocs) @ umldoclet ---
[INFO] No previous run data found, generating javadoc.
[INFO] 
Headless? java.awt.headless=true, GraphicsEnvironment.isHeadless()=true

I'll create a version where I set the java.awt.headless system property directly when loading the doclet class (first 'contact' UMLDoclet gets). It won't hurt and might even fix the issue. 🤞

@sjoerdtalsma
Copy link
Contributor

@arthurvl Could you please check whether the problem still exists with version 2.1.2?

@sjoerdtalsma
Copy link
Contributor

Closing this issue to lack of activity. @arthurvl feel free to re-open if you still experience this issue with the latest version.

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

No branches or pull requests

2 participants