jozefchutka / YHaxen

YHaxen is a Haxe project management tool written in Haxe. YHaxen can manage a project's variables, dependency validation, tests, builds, and releases.
24 stars 3 forks source link

YHaxen is a Haxe project management tool written in Haxe. YHaxen can manage a project's variables, dependency validation, tests, builds, and releases.

Dependencies & Requirements

Works with:

OS Haxe Neko Haxelib
Win 8.1 3.0.1 -> 3.1.3 2.0.0 3.1.0-rc.4
OSX 3.0.1 -> 3.1.3 2.0.0 3.1.0-rc.4
Ubuntu 14 3.0.1 -> 3.1.3 2.0.0 3.1.0-rc.4

Build with Haxe 3.2.0 is not stable.

Install

Recommended installation from from haxelib:

haxelib install yhaxen

Optionally can be also installed from git:

haxelib git yhaxen git@github.com:jozefchutka/YHaxen.git 0.0.20 src/main/haxe

Build

An yhaxen binary can be build from sources using yhaxen:

haxelib run yhaxen compile -version 123

Optionally can be built from sources using haxe command:

haxe -main yhaxen.Main -neko src/main/haxe/run.n -cp src/main/haxe -lib haxelib_client -D version=123

Usage

The main build configuration is defined in a configuration file (default name is yhaxen.json). Each node in configuration file is optional and does not need to be defined unless is meant to be used.

{
    "variables": [...],
    "dependencies": [...],
    "tests": [...],
    "builds": [...],
    "releases": [...],
}

A config file can be executed using haxelib run yhaxen compile. See further documentation for more details.

Command line arguments

Examples:

yhaxen validate -config src/test/resources/yhaxen.json
yhaxen compile -config "myconfig.json" -logLevel 2 -mode debug
yhaxen release -version 1.2.3 -message "My release message"
yhaxen help

Variables

Different kind of variables are available:

  1. defined in config file (use ${variable:...)
  2. dependency related (use ${dependency:...)
  3. command line arguments (use ${arg:...)
  4. system variables (use ${system:...})

Config Variables

Example:

"variables": [
    {
        "name": "sourceDirectory",
        "value": "src/main/haxe"
    },
    {
        "name": "outputDirectory",
        "value": "bin/debug",
        "modes": ["debug"]
    },
    {
        "name": "outputDirectory",
        "value": "bin/release"
    },
]

Config variable in use:

Dependency Variables

Single dependendcy:

Scope related dependencies:

Other dependency examples:

Argument Variables

Command line arguments haxelib run yhaxen compile version 123:

System Variables

System variables:

Variables Fallback

A default value can be provided if variable is not available:

Phases

  1. validate (variables)
  2. test
  3. compile (build)
  4. release

Each phase has a related section (optional) in the config file. If a phase related section is not defined in config file, the phase is skipped. When a specific phase is requested, each preceding phase is invoked as well (e.g. yhaxen release would run validate, test and compile phase before the actual release).

A specific build in a test or compile phase can be executed by providing a build name (i.e. compile:myBuild). All builds within a phase can be executed by providing * as a build name (i.e. test:*)

Examples:

yhaxen validate
yhaxen test
yhaxen test:*
yhaxen test:testName
yhaxen compile
yhaxen compile:*
yhaxen compile:buildName
yhaxen release -version 0.0.1
yhaxen release -version 0.0.1 -message "Initial release."
yhaxen release -version 0.0.1 -message "Releasing version ${arg:-version}."

Validate

Resolve and install dependencies from GIT or Haxelib (see type parameter).

Example dependency configuration:

"dependencies": [
    {
        "name": "msignal",
        "version": "1.2.2",
        "type": "haxelib"
    },
    {
        "name":"munit",
        "version":"2.1.1",
        "source": "git@github.com:massiveinteractive/MassiveUnit.git",
        "type": "git",
        "subdirectory": "src",
        "scopes": ["test"]
    }
]

Test

Test the compiled source code using a unit testing framework.

Example:

"tests":
[
    {
        "name": "test",
        "command": "haxelib",
        "arguments": ["run", "munit", "test"]
    }
]

Compile

Compile the source code of the project.

Example:

"builds":
[
    {
        "name": "main",
        "command": "haxe",
        "arguments":
        [
            "-main", "Main",
            "-js", "${variable:outputDirectory}/main.js",
            "-cp", "${variable:sourceDirectory}",
            "${dependency:*:classPath:-cp}"
        ]
    }
]

Release

Release versioned project. With git release, all modified files are commited and a tag is created in remote repository.

Example:

"releases":
[
    {
        "type": "haxelib",
        "haxelib": "src/haxelib.json",
        "archiveInstructions":
        [
            {"source": "src/haxelib.json", "target":"haxelib.json"},
            {"source": "doc", "target": "doc"},
            {"source": "bin/run.n", "target": "run.n"}
        ]
    },
    {
        "type": "git",
        "haxelib": "src/haxelib.json"
    }
]