From 2b710039092ecb652418c47feda707d8646622ad Mon Sep 17 00:00:00 2001 From: clydebarrow <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 4 Jul 2018 19:04:16 +1000 Subject: [PATCH] Add class paths for JVM languages other than Java. Replicates behaviour of Robovm gradle plugin. --- build.sh | 2 +- .../idea/compilation/RoboVmCompileTask.java | 23 +++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index c6041e5df..d5ee7b5a7 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh set -e mvn clean install mvn -f plugins/idea/pom.xml clean install diff --git a/plugins/idea/src/main/java/org/robovm/idea/compilation/RoboVmCompileTask.java b/plugins/idea/src/main/java/org/robovm/idea/compilation/RoboVmCompileTask.java index 0182a3a13..5d8a1d47e 100755 --- a/plugins/idea/src/main/java/org/robovm/idea/compilation/RoboVmCompileTask.java +++ b/plugins/idea/src/main/java/org/robovm/idea/compilation/RoboVmCompileTask.java @@ -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) { @@ -319,6 +323,21 @@ protected void doCompile() throws Exception { return true; } + private void addClassPath(String path, Set 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 @@ -329,7 +348,7 @@ private void configureClassAndSourcepaths(CompileContext context, Config.Builder Set bootClassPaths = new HashSet(); for(String path: classes.getPathsList().getPathList()) { if(!RoboVmPlugin.isSdkLibrary(path)) { - classPaths.add(new File(path)); + addClassPath(path, classPaths); } } @@ -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()); }