Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add class paths for JVM languages other than Java. #316

Merged
merged 1 commit into from
Jul 9, 2018
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
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/sh
#!/bin/sh
set -e
mvn clean install
mvn -f plugins/idea/pom.xml clean install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
* or if we perform an ad-hoc/IPA build from the RoboVM menu.
*/
public class RoboVmCompileTask implements CompileTask {
// A list of languages (other than java) for which we might expect to find .class files. Idea compiles these into separate directories,
// but only provides the /classes/java/main in the list of classpaths.
private static final String[] jvmLangs = {"groovy", "scala", "kotlin"};

@Override
public boolean execute(CompileContext context) {
if(context.getMessageCount(CompilerMessageCategory.ERROR) > 0) {
Expand Down Expand Up @@ -319,6 +323,21 @@ protected void doCompile() throws Exception {
return true;
}

private void addClassPath(String path, Set<File> classPaths) {
File f = new File(path);
if(f.exists())
classPaths.add(f);
// if this refers to a java class path, add paths for other JVM languages as well
if(path.contains("/classes/java/")) {
for(String jvmLang: jvmLangs) {
File filePath = new File(path.replace("/java/", "/" + jvmLang + "/"));
if(filePath.exists()) {
classPaths.add(filePath);
}
}
}
}

private void configureClassAndSourcepaths(CompileContext context, Config.Builder builder, Module module) {
// gather the boot and user classpaths. RoboVM RT libs may be
// specified in a Maven/Gradle build file, in which case they'll
Expand All @@ -329,7 +348,7 @@ private void configureClassAndSourcepaths(CompileContext context, Config.Builder
Set<File> bootClassPaths = new HashSet<File>();
for(String path: classes.getPathsList().getPathList()) {
if(!RoboVmPlugin.isSdkLibrary(path)) {
classPaths.add(new File(path));
addClassPath(path, classPaths);
}
}

Expand All @@ -341,7 +360,7 @@ private void configureClassAndSourcepaths(CompileContext context, Config.Builder
for(Module mod: context.getCompileScope().getAffectedModules()) {
String path = CompilerPaths.getModuleOutputPath(mod, false);
if(path != null && !path.isEmpty()) {
classPaths.add(new File(path));
addClassPath(path, classPaths);
} else {
RoboVmPlugin.logWarn(context.getProject(), "Output path of module %s not defined", mod.getName());
}
Expand Down