Output directory is incorrect for non-Windows #322

Closed
lombokissues opened this Issue Jul 14, 2015 · 3 comments

Projects

None yet

2 participants

@lombokissues
Collaborator

Migrated from Google Code (issue 249)

@lombokissues
Collaborator

👤 anthony@whitford.com   🕗 Aug 08, 2011 at 04:25 UTC

From a non-Windows machine (Mac OS X or Linux Ubuntu, for example), run something like:

$ java -jar lombok.jar delombok /Users/anthony/Documents/lombok.maven/test-maven-lombok/src/main/lombok/ -d /Users/anthony/Documents/lombok.maven/test-maven-lombok/target/generated-sources/delombok

Then, list the file in the output directory:

$ ls -l /Users/anthony/Documents/lombok.maven/test-maven-lombok/target/generated-sources/delombok

In my example, I have a source code file: /Users/anthony/Documents/lombok.maven/test-maven-lombok/src/main/lombok/org/projectlombok/test/DataExample.java
Since I specified the source path to be /Users/anthony/Documents/lombok.maven/test-maven-lombok/src/main/lombok/, I am expecting the generated files to be:
/Users/anthony/Documents/lombok.maven/test-maven-lombok/target/generated-sources/delombok/org/projectlombok/test/DataExample.java
Alas, what I see instead is:
/Users/anthony/Documents/lombok.maven/test-maven-lombok/target/generated-sources/delombok/Users/anthony/Documents/lombok.maven/test-maven-lombok/src/main/lombok/org/projectlombok/test/DataExample.java

I have seen this problem with 0.10.RC1 through 0.10.RC3 -- but only on non-Windows (Mac and Ubuntu). Windows works as expected.

Consider the following debug from Delombok.createFileWriter:

inBase : /Users/anthony/Documents/lombok.maven/test-maven-lombok/src/main/lombok
inBase.toURI : file:/Users/anthony/Documents/lombok.maven/test-maven-lombok/src/main/lombok/
file : /Users/anthony/Documents/lombok.maven/test-maven-lombok/src/main/lombok/org/projectlombok/test/DataExample.java
relative : /Users/anthony/Documents/lombok.maven/test-maven-lombok/src/main/lombok/org/projectlombok/test/DataExample.java

You can see that "relative" is not properly being transformed to be "relative." I would expect it to become:
org/projectlombok/test/DataExample.java

It would seem that the URI being generated for the last argument from this line:
else rawWriter = createFileWriter(output, baseMap.get(unit), unit.sourcefile.toUri());
is lacking the "file:/" prefix, so the relativize is not working…

I can resolve this problem by changing this line:

URI relative = inBase.toURI().relativize(file);

to:

    URI base = inBase.toURI();
    URI relative = base.relativize(base.resolve(file));

Note that I'm running into this problem during testing of the new lombok-maven-plugin. I am using Java 6 update 26 on Mac OSX Lion. Thanks for your help.

@lombokissues
Collaborator

👤 r.spilker   🕗 Aug 08, 2011 at 20:04 UTC

Fixed in d00576e and will be in 0.10.0. Implemented just like you suggested and attributed to you in the commit.

@lombokissues lombokissues added this to the 0.10.0 milestone Jul 14, 2015
@lombokissues
Collaborator

End of migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment