[jOOQ/jOOQ#18586] Ad-hoc compilation of code generator shouldn't require
adding jooq-codegen dependency to project, explicitly
This commit is contained in:
parent
2c445515e4
commit
0940e170dc
@ -57,6 +57,7 @@ import org.jooq.util.jaxb.tools.MiniJAXB;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
@ -286,12 +287,19 @@ public class Plugin extends AbstractMojo {
|
||||
private URLClassLoader getClassLoader() throws MojoExecutionException {
|
||||
try {
|
||||
List<String> classpathElements = project.getRuntimeClasspathElements();
|
||||
URL urls[] = new URL[classpathElements.size()];
|
||||
List<URL> urls = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < urls.length; i++)
|
||||
urls[i] = new File(classpathElements.get(i)).toURI().toURL();
|
||||
// [#18586] Re-add also plugin dependencies to the plugin class path, explicitly.
|
||||
// E.g. when passing the URL list to the in-memory compilation utility.
|
||||
PluginDescriptor d = (PluginDescriptor) getPluginContext().get("pluginDescriptor");
|
||||
if (d != null)
|
||||
for (URL u : d.getClassRealm().getURLs())
|
||||
urls.add(u);
|
||||
|
||||
return new URLClassLoader(urls, getClass().getClassLoader());
|
||||
for (String e : classpathElements)
|
||||
urls.add(new File(e).toURI().toURL());
|
||||
|
||||
return new URLClassLoader(urls.toArray(new URL[0]), getClass().getClassLoader());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new MojoExecutionException("Couldn't create a classloader.", e);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user