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 Package Manager Friendly Start Up Script #2005

Merged
merged 1 commit into from
Mar 2, 2022

Conversation

schrieveslaach
Copy link
Contributor

@schrieveslaach schrieveslaach commented Feb 7, 2022

Introducing a package manager friendly start up script to make the handling of jdt.ls easier (fixes #1823 and fixes #1934).

Why did I choose Python and not bash? Basically to address the following concern:

The tricky part is getting and testing something for Windows, Mac, Linux.

The script has been written to be platform agnostic so that it can be used on Window, Linux, and Mac. So there is no need to write separate scripts for each platform.

It also adds some logic to bootstrap Lombok out of the box. This feature could be hidden behind a command line option.

@eclipse-ls-bot
Copy link

Can one of the admins verify this patch?

@schrieveslaach
Copy link
Contributor Author

@languitar, as you are the maintainer of the AUR jdtls version and I'm trying to bring it to Homebrew, your feedback is highly appreciated (at least from my point of view).

@languitar
Copy link

On first sight this looks good. Apart from the magic of finding java etc. this looks a lot like what I use in my AUR package.

Copy link
Contributor

@mfussenegger mfussenegger left a comment

Choose a reason for hiding this comment

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

I'm not a maintainer but noticed a couple of things:

  • I think python might still refer to python2 on some systems, which would break because at least pathlib wouldn't be available. Some afaik also don't create one at all - but only python3 (?)
  • The Running from the command line section in the readme would probably need an update.
  • I think on windows it is still not uncommon to not have python at all?
  • This would remove the option to easily configure heap size and GC. Not sure if that's a common use case, just want to point it out.
  • I suspect the version check would fail if using early access releases. Not sure if this is common enough to support - but just to mention it.
❮ ./.local/jdks/jdk-17ea-panama/bin/java -version
openjdk version "17-panama" 2021-09-14
OpenJDK Runtime Environment (build 17-panama+3-167)
OpenJDK 64-Bit Server VM (build 17-panama+3-167, mixed mode, sharing)

~
❮ ./.local/jdks/jdk-19ea-panama/bin/java -version
openjdk version "19-panama" 2022-09-20
OpenJDK Runtime Environment (build 19-panama+1-13)
OpenJDK 64-Bit Server VM (build 19-panama+1-13, mixed mode, sharing)

I am not sure about the output of builds other than OpenJDK?

With that in mind - I think a start-up script would in general be a nice addition.

@schrieveslaach
Copy link
Contributor Author

@mfussenegger, @languitar, thanks for your feedback. I'll look into this.

I already added #!/usr/bin/env python3 to ensure that Python 3 will be used.

org.eclipse.jdt.ls.product/scripts/jdtls Outdated Show resolved Hide resolved
org.eclipse.jdt.ls.product/scripts/jdtls Outdated Show resolved Hide resolved
org.eclipse.jdt.ls.product/scripts/jdtls Outdated Show resolved Hide resolved
@schrieveslaach schrieveslaach force-pushed the start-up-script branch 2 times, most recently from 184aaff to bef2456 Compare February 21, 2022 11:28
@schrieveslaach
Copy link
Contributor Author

@languitar, @mfussenegger, I've updated this PR and I took your comments into account. Do you mind to have another look?

Copy link

@languitar languitar left a comment

Choose a reason for hiding this comment

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

I don't know which minimum version of Python you want to target. But for modern (tm) Python one would probably migrate all the os.path calls to pathlib.

org.eclipse.jdt.ls.product/scripts/jdtls Outdated Show resolved Hide resolved
Copy link
Contributor

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

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

Many users have noted this would be really good to have, so I think it's worth adding. @testforstephen let me know what you think about this.

Note that the script is not currently packaged in the final tarball at org.eclipse.jdt.ls.product/distro/jdt-language-server-1.9.0-202202221741.tar.gz, but I guess this is fine as it's meant as more a developer utility.

README.md Outdated Show resolved Hide resolved
org.eclipse.jdt.ls.product/scripts/jdtls Show resolved Hide resolved
org.eclipse.jdt.ls.product/scripts/jdtls Outdated Show resolved Hide resolved
Copy link
Contributor

@testforstephen testforstephen left a comment

Choose a reason for hiding this comment

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

I understand adding a startup script would bring some value. As a Java developer, I'm more used to add wrapper scripts using maven wrapper way, that's more clean and no extra dependencies.

However, if the target audience of this PR is mainly for the automated Package Manager, using python might be fine. To keep the implementation simple, i'd like to remove the extra python dependencies for defusedxml and semver. And also don't handle lombok.jar in the startup of language server, since Lombok support is out of scope of eclipse.jdt.ls project.

@schrieveslaach
Copy link
Contributor Author

I updated the PR and addressed the suggestions

But for modern (tm) Python one would probably migrate all the os.path calls to pathlib.

@languitar, moved to pathlib

Note that the script is not currently packaged in the final tarball at org.eclipse.jdt.ls.product/distro/jdt-language-server-1.9.0-202202221741.tar.gz, but I guess this is fine as it's meant as more a developer utility.

@rgrunber, actually I intended to ensure that the script will be part of the final tar.gz because it is requested by the homebrew maintainers (see here. I updated the PR so that it is included now.

To keep the implementation simple, i'd like to remove the extra python dependencies for defusedxml and semver. And also don't handle lombok.jar in the startup of language server, since Lombok support is out of scope of eclipse.jdt.ls project.

@testforstephen, I remove the Python packages and removed the Lombok option (I think I'll write a Neovim plugin to resolve Lombok that can be used in conjunction with @mfussenegger's nvim-jdtls).

I've added some other command line option to specify additional Java properties to be able to specify the Lombok Java agent.

… since Lombok support is out of scope of eclipse.jdt.ls project.

@testforstephen, is it completely out of scope (I'm asking out of curiosity)? I've discovered an issues while loading the lombok Java agent and I would like to report those.

@schrieveslaach schrieveslaach force-pushed the start-up-script branch 2 times, most recently from 87c48ca to d05c137 Compare February 24, 2022 12:51
Copy link

@languitar languitar left a comment

Choose a reason for hiding this comment

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

Some minor things I still see.

org.eclipse.jdt.ls.product/scripts/jdtls.py Outdated Show resolved Hide resolved
org.eclipse.jdt.ls.product/scripts/jdtls.py Outdated Show resolved Hide resolved
org.eclipse.jdt.ls.product/scripts/jdtls.py Outdated Show resolved Hide resolved
@rgrunber
Copy link
Contributor

rgrunber commented Mar 2, 2022

@testforstephen looks like issues have been addressed here. Have a look and let me know if you're fine with merging.

Copy link
Contributor

@testforstephen testforstephen left a comment

Choose a reason for hiding this comment

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

Once the license header issue @rgrunber commented has been addressed, it's OK to merge.

@rgrunber rgrunber merged commit 7a5ba47 into eclipse-jdtls:master Mar 2, 2022
@rgrunber
Copy link
Contributor

rgrunber commented Mar 2, 2022

@schrieveslaach thanks for taking the time to address all the suggestions.

@schrieveslaach schrieveslaach deleted the start-up-script branch March 2, 2022 13:47
@schrieveslaach
Copy link
Contributor Author

Thanks for merging. 🙂


def main(args):
parser = argparse.ArgumentParser()
parser.add_argument("--validate-java-version", default=True, action=argparse.BooleanOptionalAction)

Choose a reason for hiding this comment

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

argparse.BooleanOptionalAction is only available in python 3.9. So essentially everyone using python version < 3.9, get the above error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Issue has been raised in #2153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants