Skip to content

Adding another JVM language

Mat Bentley edited this page Dec 9, 2013 · 10 revisions

The Java Koans can work with Koans written in other JVM languages as well. For example, to use the engine w/ koans written in Groovy:

  1. Add compilation command to koans\lib\file-compiler\src\com\sandwich\util\io\filecompiler\compilationcommands.properties. For example, to add groovy support I added this line:
.groovy=groovyc -d ${bindir} -classpath ${classpath} ${filename}  
  1. Update the compilationcommands.properties file in the koans\koans\app\lib\file-compiler.jar either by rebuilding the file-compiler project, or opening the jar in an archive utility. The file in the jar should match what you updated in step 1.
  2. Create your koan. An example of a Groovy Koan might look like this:
package groovy.beginner;

import com.sandwich.koan.Koan;
import static com.sandwich.util.Assert.*;
import static com.sandwich.koan.constant.KoanConstants.__; 

class AboutGroovy {
	@Koan groovyListLiteral(){
		def list = __
		assertEquals([1, 2, 3], list)
	}
}

Make sure the test methods use the @Koan annotation and that it's located in a directory that is consistent with the package in the class. For example, I put the AboutGroovy file in the koans\koans\src*groovy\beginner* directory because its package is groovy.beginner.
4. Add the reference to your suite in the koans\koans\app\config\PathToEnlightment.xml
5. Add any jars the language's classes will need to koans\koans\app\lib. For Groovy I added groovy-2.2.1.jar and asm-4.1.jar files.
6. Test your koan running either run.sh or run.bat w/ the argument "groovy.beginner.AboutGroovy" to test your Koan out.

Clone this wiki locally