Skip to content

Commit

Permalink
Fix for opening Groovy Editor in non-Java project
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Apr 19, 2018
1 parent 20b5ee2 commit 312cdfe
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ private GroovyClassLoader[] getProjectGroovyClassLoaders(CompilerConfiguration c
String projectName = compilerOptions.groovyProjectName; IProject project = findProject(projectName);
try {
IJavaProject javaProject = JavaCore.create(project);
IClasspathEntry[] classpathEntries = javaProject.getResolvedClasspath(true);
IClasspathEntry[] classpathEntries = javaProject.exists() ? javaProject.getResolvedClasspath(true) : new IClasspathEntry[0];

Map.Entry<IClasspathEntry[], GroovyClassLoader[]> entry = projectClassLoaderCache.computeIfAbsent(projectName, key -> {
Set<String> classPaths = new LinkedHashSet<>(), xformPaths = new LinkedHashSet<>();
calculateClasspath(javaProject, classPaths, xformPaths);
if (javaProject.exists()) calculateClasspath(javaProject, classPaths, xformPaths);

if (GroovyLogManager.manager.hasLoggers()) {
GroovyLogManager.manager.log(TraceCategory.AST_TRANSFORM,
Expand Down Expand Up @@ -226,7 +226,8 @@ private static URLClassLoader newClassLoader(Set<String> classpath, ClassLoader
}).filter(Objects::nonNull).toArray(URL[]::new);

if (NONLOCKING) {
return new org.apache.xbean.classloader.NonLockingJarFileClassLoader("AST Transform loader", urls, parent);
if (parent == null) parent = URLClassLoader.newInstance(new URL[0], null);
return new org.apache.xbean.classloader.NonLockingJarFileClassLoader("GDT non-locking loader", urls, parent);
} else {
return URLClassLoader.newInstance(urls, parent);
}
Expand Down

0 comments on commit 312cdfe

Please sign in to comment.