Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.netbeans.modules.gradle.javaee.web;

import java.io.File;
import org.netbeans.modules.gradle.api.NbGradleProject;
import org.netbeans.modules.gradle.javaee.api.GradleWebProject;
import java.util.Collection;
Expand Down Expand Up @@ -56,6 +57,11 @@ public Collection<FileObject> getWebRoots() {

FileObject getDefaultWebRoot() {
GradleWebProject wp = GradleWebProject.get(project);
return wp != null ? FileUtil.toFileObject(wp.getWebAppDir()) : null;
if(wp != null && wp.getWebAppDir() != null) {
File normalizedFile = FileUtil.normalizeFile(wp.getWebAppDir());
return FileUtil.toFileObject(normalizedFile);
} else {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -355,17 +355,23 @@ private String searchLocation(Testcase tc, String className, String methodName,
.values()
.stream()
.flatMap(gradleJavaSourceSet -> gradleJavaSourceSet.getSourceDirs(SourceType.JAVA).stream())
.distinct()
.collect(
Collectors.toMap(
f -> ClasspathInfo.create(f),
f -> f.toPath()
f -> f.toPath(),
// Should not happen, each path is only considered once (see distinct() before)
// in any case this would catch it
(f1, f2) -> f1
)
);
}

String relativePath = null;
for (Map.Entry<ClasspathInfo, Path> ci : classpathInfo.entrySet()) {
if (ci.getKey() == null) continue;
if (ci.getKey() == null) {
continue;
}
FileObject fo = SourceUtils.getFile(ElementHandle.createTypeElementHandle(ElementKind.CLASS, className), ci.getKey());
if (fo != null) {
relativePath = ci.getValue().relativize(FileUtil.toFile(fo).toPath()).toString();
Expand Down