Skip to content

Commit

Permalink
Add class paths for JVM languages other than Java. (#316)
Browse files Browse the repository at this point in the history
Replicates behaviour of Robovm gradle plugin.
  • Loading branch information
clydebarrow authored and florianf committed Jul 9, 2018
1 parent d152b61 commit 2de696d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
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

0 comments on commit 2de696d

Please sign in to comment.