Custom BuildTargetScope - Has anyone successfully created a new module target?

It seems as though it should be possible to create your own extension to JVMModuleBuildTarget. (I am trying to do this in order to support another JVM-based language as a separate target.) But when I do this, the builder process itself seems to ignore it. Here are lines 902-904 of IncProjectBuilder.java:

final BuildTarget<?> target = targets.iterator().next();
if (target instanceof ModuleBuildTarget) {
return runModuleLevelBuilders(context, new ModuleChunk(Collections.singleton((ModuleBuildTarget)target)));
}

(Apologies...I do not see any way to format code.)

ModuleBuildTarget is the java-specific concrete extension to JVMModuleBuildTarget. If I create another JVMModuleBuildTarget, it is ignored by this code, and not handled later as a non-module target either.

I am wondering if this bit of code should have been implemented in terms of JVMModuleBuildTarget, rather than ModuleBuildTarget.

Or perhaps there's another way to accomplish this?

0
6 comments

If you want to support another JVM-based language (btw what language?), and its source files are located under ordinary java source roots, and you want to invoke compilation for its files in the same way (by 'Build Module'/'Build Project' actions) you don't need to create a new BuildTarget. Just provide an implementation of ModuleLevelBuilder (see its javadoc for details) and reuse the standard ModuleBuildTarget. ModuleLevelBuilder isn't Java specific, it's JVM-specific, and we use it to compile groovy and Kotlin files as well as java files.

0

The language we are compiling is Gosu (gosu-lang.org).  These are extremely large projects which contain both java and gosu.  We are trying to separate the targets in order to make each target smaller.

0

How these large projects are organized? Do they have many small/medium modules or they have few large modules? Are there modules containing both java and gosu files?

0

Some of our projects contain many small/medium modules, with a mix of java-only, gosu-only and java-plus-gosu. Some are single-module.

The situation that I am trying to address right now is a single large module which contains both types of file.

0

If a module contains both java and gosu code what kind of dependencies are allowed? Is it possible to call gosu code from java code? Is it possible to use java classes from gosu code?

0

Gosu routinely calls Java.  I believe Java can only call Gosu reflectively.

0

Please sign in to leave a comment.