classLoader = createClassLoader(pluginId, TestPlugin1.class.getName(), "parent");
pluginRegistry = new DefaultPluginRegistry(classLoader);
}
private ClassLoader createClassLoader(final String id, String implClass, String name) throws IOException {
TestFile classPath = testDir.createDir(name);
Properties props = new Properties();
props.setProperty("implementation-class", implClass);
final TestFile propertiesFile = classPath.file(id + ".properties");
propertiesFile.getParentFile().mkdirs();
GUtil.saveProperties(props, propertiesFile);
final ClassLoader classLoader = context.mock(ClassLoader.class, name);
context.checking(new Expectations() {{
allowing(classLoader).getResource("META-INF/gradle-plugins/" + id + ".properties");
will(returnValue(propertiesFile.toURI().toURL()));
}});
return classLoader;
}