Jason Dillon asked last night on IRC why the PackgeBuilderShellMojo for the m2 packaging plugin used reflection to create the PackageBuilder. We need to control the classloader for PackageBuilder pretty closely so it has the same classpath as j2ee- system. In maven 1, IIUC, plugins get instantiated using a child classloader of the project calling the plugin: this classloader typically has a more or less random selection of large numbers of geronimo jars in it, far more than j2ee-system, and in particular including all the classes for the dependencies of the module/ configuration you are trying to build. The only solution I could see for m1 was to construct a classloader myself and load PackageBuilder in my own classloader and access the instance by reflection.

I believe the situation is better in m2 and that the plugin is instantiated using a classloader determined solely by the plugin's pom. If so, we should be safe in eliminating this extra reflection code and in fact using PackageBuilder directly without the "shell". If not, we should keep using the inconvenient reflection code.

thanks
david jencks

Reply via email to