Lines 46-52
Link Here
|
46 |
import java.net.URI; |
46 |
import java.net.URI; |
47 |
import java.net.URISyntaxException; |
47 |
import java.net.URISyntaxException; |
48 |
import java.net.URL; |
48 |
import java.net.URL; |
|
|
49 |
import java.util.ArrayList; |
49 |
import java.util.Iterator; |
50 |
import java.util.Iterator; |
|
|
51 |
import java.util.List; |
50 |
import java.util.Map; |
52 |
import java.util.Map; |
51 |
import java.util.WeakHashMap; |
53 |
import java.util.WeakHashMap; |
52 |
import org.netbeans.api.java.classpath.ClassPath; |
54 |
import org.netbeans.api.java.classpath.ClassPath; |
Lines 92-100
Link Here
|
92 |
|
94 |
|
93 |
private static class SrcOutDirs { |
95 |
private static class SrcOutDirs { |
94 |
|
96 |
|
95 |
FileObject srcDir; |
97 |
FileObject[] srcDirs; |
96 |
FileObject outDir; |
98 |
FileObject outDir; |
97 |
FileObject testSrcDir; |
99 |
FileObject[] testSrcDirs; |
98 |
FileObject testOutDir; |
100 |
FileObject testOutDir; |
99 |
} |
101 |
} |
100 |
|
102 |
|
Lines 138-148
Link Here
|
138 |
|
140 |
|
139 |
// is fo under test source? |
141 |
// is fo under test source? |
140 |
boolean forTest = false; |
142 |
boolean forTest = false; |
141 |
if (dirs.testSrcDir != null && |
143 |
if (dirs.testSrcDirs != null) { |
142 |
(dirs.testSrcDir.equals(fo) || FileUtil.isParentOf(dirs.testSrcDir, fo))) { |
144 |
for (FileObject f : dirs.testSrcDirs) { |
143 |
|
145 |
if (f.equals(fo) || FileUtil.isParentOf(f, fo)) { |
144 |
forTest = true; |
146 |
forTest = true; |
|
|
147 |
break; |
145 |
} |
148 |
} |
|
|
149 |
} |
150 |
} |
146 |
|
151 |
|
147 |
// Do not use srcCp as the key, different fo under same src dir seems returning diff instance of srcCp |
152 |
// Do not use srcCp as the key, different fo under same src dir seems returning diff instance of srcCp |
148 |
Reference<Global> globalRef = forTest ? ProjectToGlobalForTest.get(project) : ProjectToGlobal.get(project); |
153 |
Reference<Global> globalRef = forTest ? ProjectToGlobalForTest.get(project) : ProjectToGlobal.get(project); |
Lines 153-165
Link Here
|
153 |
} |
158 |
} |
154 |
} |
159 |
} |
155 |
|
160 |
|
156 |
String srcPath = ""; |
161 |
String[] srcPath; |
157 |
String outPath = ""; |
162 |
String outPath; |
158 |
if (forTest) { |
163 |
if (forTest) { |
159 |
srcPath = dirs.testSrcDir == null ? "" : FileUtil.toFile(dirs.testSrcDir).getAbsolutePath(); |
164 |
if (dirs.testSrcDirs == null) { |
|
|
165 |
srcPath = new String[] {""}; |
166 |
} else { |
167 |
srcPath = new String[dirs.testSrcDirs.length]; |
168 |
int ind = 0; |
169 |
for (FileObject f : dirs.testSrcDirs) { |
170 |
srcPath[ind] = FileUtil.toFile(f).getAbsolutePath(); |
171 |
ind++; |
172 |
} |
173 |
} |
160 |
outPath = dirs.testOutDir == null ? "" : FileUtil.toFile(dirs.testOutDir).getAbsolutePath(); |
174 |
outPath = dirs.testOutDir == null ? "" : FileUtil.toFile(dirs.testOutDir).getAbsolutePath(); |
161 |
} else { |
175 |
} else { |
162 |
srcPath = dirs.srcDir == null ? "" : FileUtil.toFile(dirs.srcDir).getAbsolutePath(); |
176 |
if (dirs.srcDirs == null) { |
|
|
177 |
srcPath = new String[] {""}; |
178 |
} else { |
179 |
srcPath = new String[dirs.srcDirs.length]; |
180 |
int ind = 0; |
181 |
for (FileObject f : dirs.srcDirs) { |
182 |
srcPath[ind] = FileUtil.toFile(f).getAbsolutePath(); |
183 |
ind++; |
184 |
} |
185 |
} |
163 |
outPath = dirs.outDir == null ? "" : FileUtil.toFile(dirs.outDir).getAbsolutePath(); |
186 |
outPath = dirs.outDir == null ? "" : FileUtil.toFile(dirs.outDir).getAbsolutePath(); |
164 |
} |
187 |
} |
165 |
|
188 |
|
Lines 170-177
Link Here
|
170 |
} else { |
193 |
} else { |
171 |
settings.verbose().value_$eq(false); |
194 |
settings.verbose().value_$eq(false); |
172 |
} |
195 |
} |
173 |
|
196 |
// settings.sourcepath().tryToSetColon(scala.netbeans.Wrapper$.MODULE$.stringList(srcPath)); |
174 |
settings.sourcepath().tryToSet(scala.netbeans.Wrapper$.MODULE$.stringList(new String[]{srcPath})); |
|
|
175 |
//settings.outdir().tryToSet(scala.netbeans.Wrapper$.MODULE$.stringList(new String[]{"-d", outPath})); |
197 |
//settings.outdir().tryToSet(scala.netbeans.Wrapper$.MODULE$.stringList(new String[]{"-d", outPath})); |
176 |
settings.outputDirs().setSingleOutput(outPath); |
198 |
settings.outputDirs().setSingleOutput(outPath); |
177 |
|
199 |
|
Lines 198-203
Link Here
|
198 |
settings.bootclasspath().tryToSet(scala.netbeans.Wrapper$.MODULE$.stringList(new String[]{sb.toString()})); |
220 |
settings.bootclasspath().tryToSet(scala.netbeans.Wrapper$.MODULE$.stringList(new String[]{sb.toString()})); |
199 |
|
221 |
|
200 |
sb.delete(0, sb.length()); |
222 |
sb.delete(0, sb.length()); |
|
|
223 |
for (String s : srcPath) { |
224 |
sb.append(s).append(File.pathSeparator); |
225 |
} |
226 |
if (compCp.entries().size() == 0) { |
227 |
sb.setLength(sb.length() - 1); |
228 |
} |
229 |
System.out.println("cp1=" + sb.toString()); |
201 |
computeClassPath(project, sb, compCp); |
230 |
computeClassPath(project, sb, compCp); |
202 |
if (forTest && !inStdLib && dirs.outDir != null) { |
231 |
if (forTest && !inStdLib && dirs.outDir != null) { |
203 |
sb.append(File.pathSeparator).append(dirs.outDir); |
232 |
sb.append(File.pathSeparator).append(dirs.outDir); |
Lines 301-320
Link Here
|
301 |
private static SrcOutDirs findDirsInfo(Project project) { |
330 |
private static SrcOutDirs findDirsInfo(Project project) { |
302 |
SrcOutDirs dirs = new SrcOutDirs(); |
331 |
SrcOutDirs dirs = new SrcOutDirs(); |
303 |
|
332 |
|
304 |
SourceGroup[] sgs = ProjectUtils.getSources(project).getSourceGroups(SOURCES_TYPE_SCALA); |
333 |
SourceGroup[] sgs1 = ProjectUtils.getSources(project).getSourceGroups(SOURCES_TYPE_SCALA); |
305 |
if (sgs.length == 0) { |
334 |
SourceGroup[] sgs2 = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); |
306 |
//as a fallback use java ones.. |
335 |
List<FileObject> sources = new ArrayList<FileObject>(); |
307 |
sgs = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); |
336 |
List<FileObject> testsources = new ArrayList<FileObject>(); |
|
|
337 |
if (sgs1.length > 0) { |
338 |
sources.add(sgs1[0].getRootFolder()); |
339 |
dirs.outDir = findOutDir(project, sgs1[0].getRootFolder()); |
340 |
if (sgs1.length > 1) { |
341 |
testsources.add(sgs1[1].getRootFolder()); |
342 |
dirs.testOutDir = findOutDir(project, sgs1[1].getRootFolder()); |
308 |
} |
343 |
} |
309 |
if (sgs.length > 0) { |
|
|
310 |
dirs.srcDir = sgs[0].getRootFolder(); |
311 |
dirs.outDir = findOutDir(project, dirs.srcDir); |
312 |
if (sgs.length > 1) { |
313 |
dirs.testSrcDir = sgs[1].getRootFolder(); |
314 |
dirs.testOutDir = findOutDir(project, dirs.testSrcDir); |
315 |
} |
344 |
} |
|
|
345 |
if (sgs2.length > 0) { |
346 |
sources.add(sgs2[0].getRootFolder()); |
347 |
dirs.outDir = findOutDir(project, sgs2[0].getRootFolder()); |
348 |
if (sgs2.length > 1) { |
349 |
testsources.add(sgs2[1].getRootFolder()); |
350 |
dirs.testOutDir = findOutDir(project, sgs2[1].getRootFolder()); |
316 |
} |
351 |
} |
317 |
|
352 |
} |
|
|
353 |
dirs.srcDirs = sources.toArray(new FileObject[0]); |
354 |
dirs.testSrcDirs = testsources.toArray(new FileObject[0]); |
318 |
return dirs; |
355 |
return dirs; |
319 |
} |
356 |
} |
320 |
|
357 |
|