9797 */
9898public class EclipseHelper extends DirectoryIndexer {
9999
100+ private static final String FORCE_ANNOTATION_INDEX_PROPERTY = "force.annotation.index" ;
100101 static Set <URL > indexed = new HashSet <URL >();
101102 private boolean bannerShown ;
102103
103104 private static boolean debug =
104105 "debug" .equals (System .getProperty ("scijava.log.level" ));
106+ private boolean autoDetectEclipse = true ;
105107
106108 private static void debug (final String message ) {
107109 if (debug ) {
@@ -131,10 +133,13 @@ public static void updateAnnotationIndex(final ClassLoader loader) {
131133 return ;
132134 }
133135 EclipseHelper helper = new EclipseHelper ();
136+ if (Boolean .getBoolean (FORCE_ANNOTATION_INDEX_PROPERTY )) {
137+ helper .autoDetectEclipse = false ;
138+ }
134139 boolean first = true ;
135140 for (final URL url : ((URLClassLoader ) loader ).getURLs ()) {
136141 debug ("Checking URL: " + url );
137- if (first ) {
142+ if (helper . autoDetectEclipse && first ) {
138143 if (!"file" .equals (url .getProtocol ()) ||
139144 (!url .getPath ().endsWith ("/" ) && !url .getPath ().contains ("surefire" )))
140145 {
@@ -177,7 +182,7 @@ private void maybeIndex(final URL url, final ClassLoader loader) {
177182 * but crucially also the target/classes/ and target/test-classes/
178183 * directories which may need to be indexed.
179184 */
180- if (path .matches (".*/target/surefire/surefirebooter[0-9]*\\ .jar" )) try {
185+ if (! autoDetectEclipse || path .matches (".*/target/surefire/surefirebooter[0-9]*\\ .jar" )) try {
181186 final JarFile jar = new JarFile (path );
182187 Manifest manifest = jar .getManifest ();
183188 if (manifest != null ) {
@@ -186,7 +191,7 @@ private void maybeIndex(final URL url, final ClassLoader loader) {
186191 if (classPath != null ) {
187192 for (final String element : classPath .split (" +" ))
188193 try {
189- maybeIndex (new URL (element ), loader );
194+ maybeIndex (new URL (url , element ), loader );
190195 }
191196 catch (MalformedURLException e ) {
192197 e .printStackTrace ();
@@ -286,6 +291,7 @@ else if (file.isDirectory()) {
286291 * </p>
287292 */
288293 public static void main (final String ... args ) {
294+ System .setProperty (FORCE_ANNOTATION_INDEX_PROPERTY , "true" );
289295 updateAnnotationIndex (Thread .currentThread ().getContextClassLoader ());
290296 }
291297
0 commit comments