sbt-haxe

Build Status

sbt-haxe is a Sbt plugin to compile Haxe sources in Java/Scala projects.

Usage

Step 1: Install sbt-haxe into your project

Add the following line to your project/plugins.sbt:

addSbtPlugin("com.thoughtworks.microbuilder" % "sbt-haxe" % "3.0.11")

Step 2: Put your Haxe sources at src/haxe/yourPackage/YourHaxeClass.hx

package yourPackage;
import haxe.ds.Vector;
class YourHaxeClass
{
  public static function main(args:Vector<String>)
  {
    trace("Hello, World!");
  }
}

Step 3: Run it!

$ sbt run
[info] Loading global plugins from C:\Users\user\.sbt\0.13\plugins
[info] Loading project definition from D:\Documents\sbt-haxe-test\project
[info] Set current project to sbt-haxe-test (in build file:/D:/Documents/sbt-haxe-test/)
[info] "haxe" "-cp" "D:\Documents\sbt-haxe-test\src\haxe" "-cp" "D:\Documents\sbt-haxe-test\target\scala-2.10\src_managed\haxe" "-java-lib" "C:\Users\user\.sbt\boot\scala-2.10.3\lib\scala-library.jar" "-java" "D:\cygwin\tmp\sbt_97a26bd9" "-D" "no-compilation" "yourPackage.YourHaxeClass"
[info] Compiling 1 Java source to D:\Documents\sbt-haxe-test\target\scala-2.10\classes...
[info] Running yourPackage.YourHaxeClass
YourHaxeClass.hx:7: Hello, World!
[success] Total time: 1 s, completed 2014-7-25 10:00:23

Targets supported

Currently sbt-haxe supports all targets that haxe supported, but all of them are disabled by default except java. If you want to compile to specific target other than java, you need to enable it manually in build.sbt.

And here's a sbt-haxe-sample project to show how to use them.

  • JavaScript enablePlugins(HaxeJsPlugin)
  • PHP enablePlugins(HaxePhpPlugin)
  • Neko enablePlugins(HaxeNekoPlugin)
  • C# enablePlugins(HaxeCSharpPlugin)
  • Python enablePlugins(HaxePythonPlugin)
  • C++ enablePlugins(HaxeCppPlugin)
  • Flash enablePlugins(HaxeFlashPlugin)
  • ActionScript 3 enablePlugins(HaxeAs3Plugin)

Tasks and settings

sbt-haxe provides following tasks and settings:

  • haxe
  • haxe:doc
  • haxe:publish

See HaxeKeys.scala for more information.

Dependencies

sbt-haxe requires Sbt 0.13, Haxe 3.1, hxjava 3.1.0 and Dox 1.0.0.