final File configFile = File.createTempFile("wro", ".properties");
FileUtils.write(configFile, "wroSources=" + wroSources.getAbsolutePath().replace(File.separatorChar, '/'));
final GeonetworkMavenWrojManagerFactory managerFactory = new GeonetworkMavenWrojManagerFactory();
managerFactory.setExtraConfigFile(configFile);
final GeonetWroModelFactory wroModelFactory = (GeonetWroModelFactory) managerFactory.newModelFactory();
final ReadOnlyContext context = (ReadOnlyContext) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
new Class[]{ReadOnlyContext.class}, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return null;
}
});
wroModelFactory.setContext(context);
wroModelFactory.setGeonetworkRootDirectory(getGeonetworkRootDirectory());
return wroModelFactory.create();
}