prezi / gradle-haxe-plugin

Gradle Haxe Plugin
Other
23 stars 4 forks source link

How do you use the plugin? #39

Open tomlarkworthy opened 9 years ago

tomlarkworthy commented 9 years ago

My gradle is

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath group: 'com.prezi.haxe', name: 'gradle-haxe-plugin',
                version: '4.1.5'
    }
}

apply plugin: 'haxe'

haxe {
    // Set compiler options here for all platforms
    inlcude "com.example.test.haxe"

    targetPlatforms {
        js {
            // Set compiler options here for only the JavaScript target
            inlcude "com.example.test.haxe.javascript"
            flag "-D js-enabled"
        }
        swc {
            // Set compiler options here for only the Flash target
            flag "-D only-for-flash"
        }
    }
}

but it does not recognize the haxe {...} command. I am clearly not understanding how to link the plugin into the gradle environment (but there are no instruction on how to do so)

tomlarkworthy commented 9 years ago

Ok it was kinda working like that, now just figuring out how to link munit in a non-horrible way

tomlarkworthy commented 9 years ago

haxe-test-compile/jsTest/tests/TestMain.hx:1: characters 7-39 : Type not found : massive.munit.client.PrintClient

tomlarkworthy commented 9 years ago

Slowly getting there. A full example would be mind blowingly useful. My tests and JS compile, but the test runner is opening the test window for class MainTest, and not on the generate TestSuite. I don't know how to set the paramaters for the TestRunner

lptr commented 9 years ago

There's sort of an example here: https://github.com/prezi/gradle-haxe-plugin/tree/master/src/test/at, but yeah, the project could definitely use some more documentation. The original plan was to refactor the whole thing when the new Gradle configuration model comes out, but it's still not out. I hear it's not too long now, and then this can be done in a much nicer way. Until then ask away, I'll try to answer what I can.

tomlarkworthy commented 9 years ago

Hello!

It seems super powerful but quite difficult to get going. The example you link does not include the munit integration.

When I run "./gradlew test" a browser window pops up. Inspecting the console reveals its running my "MainTest", rather than the "TestSuite" generate code. I am trying to get it to run test that I have setup in example.HelloWorld. My config:

haxe {
    // Set compiler options here for all platforms
    include "example.HelloWorld"

    targetPlatforms {
        js {
            // Set compiler options here for only the JavaScript target
            flag "-D js-enabled"
        }
    }
}

In /build/haxe-test-compile/jsTest/tests/TestSuite.hx

There is a correctly wired up test suite:-

import massive.munit.TestSuite;

import example.HelloWorldTest;

/**
 * Auto generated Test Suite for MassiveUnit.
 * Refer to munit command line tool for more information (haxelib run munit)
 */

class TestSuite extends massive.munit.TestSuite
{       

    public function new()
    {
        super();

        add(example.HelloWorldTest);
    }
}

I just can't figure out how to tell my gradle build file to run it instead of going for the default "Main" and default "MainTest"

(I have tried a number of main, test, file combinations)

tomlarkworthy commented 9 years ago

Oh is the intention I put my src files in the same directory as the git repo test project dirs?

tomlarkworthy commented 9 years ago

ok I started from scratch from the sample project

I can;t compile it becuase I can;t satisfy the following dependancies

dependencies {
        jsNode group: "haxelib3", name: "nodejs", version: "2.0.1"
        test group: "haxelib3", name: "hamcrest", version: "1.2.1"
        test group: "haxelib3", name: "mlib", version: "2.0.2"
        test group: "haxelib3", name: "munit", version: "2.1.0"
}

Googling "haxelib3" doesn't reveal anything. Haxelib is the haxe package manager but I am not sure how these dependancies are supposed to satisfied from a gradle environment.

tomlarkworthy commented 9 years ago

OK I am stuck. I tried putting your example in its own repo, but I can't get it to work. As mentioned above I can;t fullfil the dependancies. I have haxelib installed, but I am not sure what technology to link the repo. Are you using Ivy in some capacity for that??!?

https://github.com/tomlarkworthy/gradle-haxe-plugin-bootstrap