提交 2422cb6d 编写于 作者: K kohsuke

fixed a bug in using multiple versions of the same plugin.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@4329 71c3de6d-444a-0410-be80-ed276b4c234a
上级 66dde2cf
package hudson.maven.agent;
import org.codehaus.classworlds.ClassRealm;
import org.codehaus.classworlds.ClassWorld;
import org.codehaus.classworlds.DefaultClassRealm;
import org.codehaus.classworlds.Launcher;
import org.codehaus.classworlds.NoSuchRealmException;
import org.codehaus.classworlds.DefaultClassRealm;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.HashSet;
import java.util.Set;
/**
* Entry point for launching Maven and Hudson remoting in the same VM,
......@@ -86,7 +89,22 @@ public class Main {
* Called by the code in remoting to launch.
*/
public static int launch(String[] args) throws NoSuchMethodException, IllegalAccessException, NoSuchRealmException, InvocationTargetException, ClassNotFoundException {
launcher.launch(args);
ClassWorld world = launcher.getWorld();
Set<ClassRealm> builtinRealms = new HashSet<ClassRealm>(world.getRealms());
try {
launcher.launch(args);
} finally {
// delete all realms created by Maven
// this is because Maven creates a child realm for each plugin it loads,
// and the realm id doesn't include the version.
// so unless we discard all the realms multiple invocations
// that use different versions of the same plugin will fail to work correctly.
Set<ClassRealm> all = new HashSet<ClassRealm>(world.getRealms());
all.retainAll(builtinRealms);
for (ClassRealm cr : all)
world.disposeRealm(cr.getId());
}
return launcher.getExitCode();
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册