mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use runtime classpath to allow groovyc to access indirectly referenced classes in indirect dependencies
This commit is contained in:
@@ -61,7 +61,7 @@ public class GroovyBuilder extends Builder {
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
final List<String> cp = new ArrayList<String>();
|
||||
final Set<String> cp = new LinkedHashSet<String>();
|
||||
//groovy_rt.jar
|
||||
// IMPORTANT! must be the first in classpath
|
||||
cp.add(ClasspathBootstrap.getResourcePath(GroovyCompilerWrapper.class).getPath());
|
||||
@@ -69,6 +69,9 @@ public class GroovyBuilder extends Builder {
|
||||
for (File file : context.getProjectPaths().getClasspathFiles(chunk, ClasspathKind.compile(context.isCompilingTests()), false)) {
|
||||
cp.add(FileUtil.toCanonicalPath(file.getPath()));
|
||||
}
|
||||
for (File file : context.getProjectPaths().getClasspathFiles(chunk, ClasspathKind.runtime(context.isCompilingTests()), false)) {
|
||||
cp.add(FileUtil.toCanonicalPath(file.getPath()));
|
||||
}
|
||||
|
||||
final File tempFile = FileUtil.createTempFile("ideaGroovyToCompile", ".txt", true);
|
||||
final Module representativeModule = chunk.getModules().iterator().next();
|
||||
@@ -98,8 +101,8 @@ public class GroovyBuilder extends Builder {
|
||||
final List<String> cmd = ExternalProcessUtil.buildJavaCommandLine(
|
||||
SystemProperties.getJavaHome() + "/bin/java",
|
||||
"org.jetbrains.groovy.compiler.rt.GroovycRunner",
|
||||
Collections.<String>emptyList(), cp,
|
||||
Arrays.asList("-Xmx384m"/*, "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5858"*/),
|
||||
Collections.<String>emptyList(), new ArrayList<String>(cp),
|
||||
Arrays.asList("-Xmx384m"/*, "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5858"*/),
|
||||
Arrays.<String>asList(myForStubs ? "stubs" : "groovyc", tempFile.getPath())
|
||||
);
|
||||
|
||||
|
||||
@@ -284,6 +284,25 @@ public class Transf implements ASTTransformation {
|
||||
assertOutput("Bar", "239", dep);
|
||||
}
|
||||
|
||||
public void testIndirectDependencies() throws Exception {
|
||||
myFixture.addFileToProject("dependent1/Bar1.groovy", "class Bar1 {}");
|
||||
myFixture.addFileToProject("dependent2/Bar2.groovy", "class Bar2 extends Bar1 {}");
|
||||
PsiFile main = myFixture.addFileToProject("Main.groovy", "class Main extends Bar2 {}");
|
||||
|
||||
Module dep1 = addModule('dependent1')
|
||||
Module dep2 = addModule('dependent2')
|
||||
addDependency dep2, dep1
|
||||
addDependency myModule, dep2
|
||||
|
||||
addGroovyLibrary(dep1);
|
||||
addGroovyLibrary(dep2);
|
||||
|
||||
assertEmpty(make())
|
||||
|
||||
touch(main.virtualFile)
|
||||
assertEmpty(make())
|
||||
}
|
||||
|
||||
public void testExtendFromGroovyAbstractClass() throws Exception {
|
||||
myFixture.addFileToProject "Super.groovy", "abstract class Super {}"
|
||||
myFixture.addFileToProject "AJava.java", "public class AJava {}"
|
||||
@@ -436,6 +455,7 @@ class Usage {
|
||||
|
||||
public static class JpsMode extends GroovyCompilerTest {
|
||||
@Override protected boolean useJps() { true }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+20
-3
@@ -148,18 +148,35 @@ public abstract class GroovyCompilerTestCase extends JavaCodeInsightFixtureTestC
|
||||
}
|
||||
|
||||
protected Module addDependentModule() {
|
||||
Module module = addModule("dependent");
|
||||
addDependency(module, myModule);
|
||||
return module;
|
||||
}
|
||||
|
||||
protected void addDependency(final Module from, final Module to) {
|
||||
new WriteCommandAction(getProject()) {
|
||||
@Override
|
||||
protected void run(Result result) throws Throwable {
|
||||
final ModifiableRootModel model = ModuleRootManager.getInstance(from).getModifiableModel();
|
||||
model.addModuleOrderEntry(to);
|
||||
model.commit();
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
|
||||
}
|
||||
|
||||
protected Module addModule(final String name) {
|
||||
return new WriteCommandAction<Module>(getProject()) {
|
||||
@Override
|
||||
protected void run(Result<Module> result) throws Throwable {
|
||||
final VirtualFile depRoot = myFixture.getTempDirFixture().findOrCreateDir("dependent");
|
||||
final VirtualFile depRoot = myFixture.getTempDirFixture().findOrCreateDir(name);
|
||||
|
||||
final ModifiableModuleModel moduleModel = ModuleManager.getInstance(getProject()).getModifiableModel();
|
||||
String moduleName = moduleModel.newModule(depRoot.getPath() + "/dependent.iml", StdModuleTypes.JAVA).getName();
|
||||
String moduleName = moduleModel.newModule(depRoot.getPath() + "/" + name + ".iml", StdModuleTypes.JAVA).getName();
|
||||
moduleModel.commit();
|
||||
|
||||
final Module dep = ModuleManager.getInstance(getProject()).findModuleByName(moduleName);
|
||||
final ModifiableRootModel model = ModuleRootManager.getInstance(dep).getModifiableModel();
|
||||
model.addModuleOrderEntry(myModule);
|
||||
final ContentEntry entry = model.addContentEntry(depRoot);
|
||||
entry.addSourceFolder(depRoot, false);
|
||||
model.setSdk(ModuleRootManager.getInstance(myModule).getSdk());
|
||||
|
||||
Reference in New Issue
Block a user