I'm working on a feature in the Arquillian plugin that Dan asked
about, which is to be able to export @Deployments that are part of the project's
tests. To do this I need to invoke the static method on a test class to create the Archive
that has to be exported.
Not only do you need access to the method you need the full classpath initialized for the
project for it work.
The problem is that is seems to be impossible to load a class that is
in the user's project, although I already have an instance of the JavaSource object
that describes the class. I believe it would be best to not rely on the question if the
user's project has been compiled or not. So what should happen is the following:
-Compile the class based on the JavaSource object
-(optionally) Create a temporarily .class object
-Load the class
-(optionally) instantiate it
I guess this is something that other plugins might need too in the future, so it would be
better to find a reusable solution instead of hacking my way around it.
yeah, Dan asked the same for eclipse tooling and I don't really have a good answer
beyond creating an isolated classloader
that loads the users full classpath and execute (optimally under a security manager to
avoid too many accidents).
/max
http://about.me/maxandersen