I want to use Reflections to select all classes that have a specific Annotation on them from a JAR file that gets created during a Maven build but I think I am running into an issue to do with the files not being in the classpath since the JAR is create during the Maven build and then my code is also run by Maven but I'm not sure if this is correct OR if it is the issue how to go about fixing it.
When testing my code I just run the file directly in Eclipse and it seems to read the JAR and find the classes ok but when the file is called during a Maven build after the JAR is created I get ClassNotFoundExceptions for each class. This is the code block where I am specifying the JAR file and trying to use Reflections to find the classes in a specific module:
webClasses = new URL("jar", "",
"file:" + "C:/development/workspaces/trunk/target/http://ift.tt/2nFANi5");
URLClassLoader cl = URLClassLoader.newInstance(new URL[] { webClasses });
reflections = new Reflections(ClasspathHelper.forClassLoader(cl), new TypeAnnotationsScanner(), cl);
Hopefully I explained that ok, should it be possible to call Reflections on a JAR file from a Maven build and for it to actually work?
Aucun commentaire:
Enregistrer un commentaire