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

How to run (de)lombok with big classpath? #1795

Closed
larsgrefer opened this issue Jul 26, 2018 · 6 comments
Closed

How to run (de)lombok with big classpath? #1795

larsgrefer opened this issue Jul 26, 2018 · 6 comments

Comments

@larsgrefer
Copy link
Contributor

I'm developing a gradle plugin which contains a task for running delombok.

I currenty invoke delombok using a command like this:
(one argument per line for better readability)

/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/bin/java
-Dfile.encoding=UTF-8
-Djava.io.tmpdir=/Volumes/Daten/git/gradle-plugins-test/lombok/build/tmp/delombok
-Duser.country=DE
-Duser.language=de
-Duser.variant
-cp /Users/larsgrefer/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.0/c4647d46f0742746ac07ce4abeeee9b2fb18d147/lombok-1.18.0.jar
lombok.launch.Main
delombok
--format=pretty
--target=/Volumes/Daten/git/gradle-plugins-test/lombok/build/delombok/main
--classpath=/Users/larsgrefer/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.8.0-beta2/ba136e771a794f77ab41fa879706e5cbd5b20f39/slf4j-api-1.8.0-beta2.jar:/Users/larsgrefer/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.0/c4647d46f0742746ac07ce4abeeee9b2fb18d147/lombok-1.18.0.jar
/Volumes/Daten/git/gradle-plugins-test/lombok/src/main/java

On big project this command can exceed 32767 characters which causes errors on windows: https://blogs.msdn.microsoft.com/oldnewthing/20031210-00/?p=41553

What I've tried so far:

Classpath Manifest

A common and well known workaround for such problems when invoking java applications with a long classpath, is to create a single jar which contains the actual classpath in its MANIFEST.MF.
Unfortunately this does'nt work for delombok's --classpath-option

Calling lombok.launch.Main.main() directly

Since the gradle task from which I want to run delombok is a java process itself, i've tried to directly invoke lomboks main()-method. Unfortunately this isn't an option too, because lombok internally calls System.exit().

Possible solutions

Support argfiles

Other java tools like javac, javadoc and ajc allow you to put all your command line arguments into an file, which can be passed to the process instead of the actual arguments: https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html#BHCCFGCD

Provide an API

It would be great to have a java API to invoke (de)lombok directly without the need of creating an additional java process

@rspilker
Copy link
Collaborator

As far as I can see, we only call System.exit() if something goes wrong, or if you pass the help parameter.

@larsgrefer
Copy link
Contributor Author

lombok.core.Main#main(String[] args) calls System.exit() in every case

@rspilker
Copy link
Collaborator

@rzwitserloot is going to implement the @filename syntax soon. In the meantime, we we will only call System.exit if the return code is not zero.

@larsgrefer
Copy link
Contributor Author

larsgrefer commented Oct 15, 2018

Since Java 9 the java command natively supports @argument files, so implementing this in lombok would only be necessary for java 8.

A nicer option would be a java API for invoking lombok, so I don't have to start an additional process

@larsgrefer
Copy link
Contributor Author

I just experimented with the native @file-support in Java 9+. Unfortunately this seems not to work for the actual application arguments but only for the arguments directly read by the JVM

@rzwitserloot
Copy link
Collaborator

delombok specifically now supports @args.txt. Check it out in edge: https://projectlombok.org/download-edge

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

3 participants