Skip to content

Fix annotation processing when running javac without -d <directory>#126

Merged
ctrueden merged 2 commits into
masterfrom
javac-annotations
Nov 12, 2014
Merged

Fix annotation processing when running javac without -d <directory>#126
ctrueden merged 2 commits into
masterfrom
javac-annotations

Conversation

@dscho
Copy link
Copy Markdown
Contributor

@dscho dscho commented Oct 7, 2014

Samuel Inverso noticed, and Mark Hiner diagnosed, that compiling SciJava
plugins using javac without specifying an output directory will write the
annotation index into an incorrect location (instead of META-INF/json/ it
is written into the top-level directory).

This can be verified using a very simple example x1.java file:

-- snip --
import org.scijava.plugin.Plugin;
import org.scijava.plugin.SciJavaPlugin;

@plugin(type = SciJavaPlugin.class)
public class x1 implements SciJavaPlugin { }
-- snap --

The reason is that javac's DefaultFileManager will strip out any
subdirectory in the path passed to the createResource() method unless
an output directory is specified.

Work around that by detecting the situation and creating the subdirectory
explicitly.

This fixes imagej/imagej-launcher#22.

Signed-off-by: Johannes Schindelin johannes.schindelin@gmx.de

@dscho
Copy link
Copy Markdown
Contributor Author

dscho commented Oct 7, 2014

@hinerm @ctrueden what do you think?

@ctrueden
Copy link
Copy Markdown
Member

ctrueden commented Oct 7, 2014

Makes sense. A comment in the source about it would be good—otherwise 👍!

@hinerm
Copy link
Copy Markdown
Member

hinerm commented Oct 7, 2014

Agreed with @ctrueden . Thanks for tracking this down & fixing it so quickly @dscho !

dscho added 2 commits October 7, 2014 18:11
Samuel Inverso noticed, and Mark Hiner diagnosed, that compiling SciJava
plugins using javac without specifying an output directory will write the
annotation index into an incorrect location (instead of META-INF/json/ it
is written into the top-level directory).

This can be verified using a very simple example x1.java file:

-- snip --
import org.scijava.plugin.Plugin;
import org.scijava.plugin.SciJavaPlugin;

@plugin(type = SciJavaPlugin.class)
public class x1 implements SciJavaPlugin { }
-- snap --

The reason is that javac's DefaultFileManager will strip out any
subdirectory in the path passed to the createResource() method unless
an output directory is specified.

Work around that by detecting the situation and creating the subdirectory
explicitly.

This fixes imagej/imagej-launcher#22.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho force-pushed the javac-annotations branch from 3b43cc9 to c637b29 Compare October 7, 2014 16:12
@dscho
Copy link
Copy Markdown
Contributor Author

dscho commented Nov 12, 2014

@ctrueden @hinerm Just noted that this still has not made it into master. As part of my closure, could one of you review the updated PR and merge if appropriate, or close if not?

ctrueden added a commit that referenced this pull request Nov 12, 2014
Fix annotation processing when running javac without -d <directory>
@ctrueden ctrueden merged commit 0b033f1 into master Nov 12, 2014
@ctrueden ctrueden deleted the javac-annotations branch November 12, 2014 17:03
@ctrueden
Copy link
Copy Markdown
Member

Thanks for the reminder!

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.

Javac doesn't produce META-INF directory when output dir is unspecified

3 participants