Tasks

January 29, 2018 ยท View on GitHub

The plugin will add a number of tasks you can use

Task nameDepends onTypeDescription
activateUnitywooga.gradle.unity.tasks.ActivateActivates unity with provides credentials. Gets skipped when credentials are missing
returnUnityLicensewooga.gradle.unity.tasks.ReturnLicenseReturns the current licesne to license server. Gets skipped when license directory is empty
exportUnityPackageactivationTask, setupwooga.gradle.unity.tasks.UnityPackageexports configured assets into an .unitypackage file
testtestEditMode, testPlayModeDefaultTaskruns editMode and playMode tasks
testEditModeactivationTask, setupDefaultTaskruns testEditMode for all testBuildTargets (testEditModeAndroid, testEditModeIos ...)
testPlayModeactivationTask, setupDefaultTaskruns testPlayMode for all testBuildTargets (testPlayModeAndroid, testPlayModeIos ...)
testEditMode[TestBuildTarget]testEditModewooga.gradle.unity.tasks.Taskruns unity editor tests on testBuildTarget and writes reports to reportsDir
testPlayMode[TestBuildTarget]testPlayModewooga.gradle.unity.tasks.Taskruns unity playMode tests on testBuildTarget and writes reports to reportsDir

Example Test Task structure:

:check
\--- :test
     +--- :testEditMode
     |    +--- :testEditModeAndroid
     |    \--- :testEditModeIos
     \--- :testPlayMode
          +--- :testPlayModeAndroid
          \--- :testPlayModeIos

Custom Batchmode task

You can call any abitary unity batchmode command either with the BatchModeSpec or the wooga.gradle.unity.tasks.Unity task type:

build.gradle

task(performBatchmodeTask, type:wooga.gradle.unity.tasks.Unity) {
    args "-executeMethod", "MyEditorScript.PerformBuild"
}

-or-

task(performBatchmodeSpec) {
    doLast {
        unity.batchMode {
            unityPath = project.file("/Applications/Unity-5.5.3f1/Unity.app/Contents/MacOS/Unity")
        }
    }
}

The Unity task type is the prefered way of calling unity batchmode commands because it works better with autoActivation/ReturnLicense If you want to use this feature along with one or multiple tasks running the BatchModeSpec you need to make sure the task returnUnityLicense runs after these custom tasks. See the [unity manual][unity_cmd] for a complete list of possible batchmode arguments.

build.gradle

task(performBatchmodeSpec) {
    ...
}

tasks.returnUnityLicense.mustRunAfter performBatchmodeSpec

Export unity package

By default the exportUnityPackage will be skipped because of missing sources. You need to tell the task what sources you want to include into the package. The produced archive will be added to the unitypackage configuration.

build.gradle

exportUnityPackage {
    inputFiles file('Assets')
}

Editor tests

The editor tests comes in two flavors: Unity 5.5 and Unity 5.6. These versions have different commandline parameters and options. The wooga.gradle.unity.tasks.Test will adjust the settings based on the unity version. It will figure out at runtime if your version is 5.5 or 5.6. It will always fallback to 5.5 logic if it couldn't figure out the version.

PlayMode tests

The plugin automatically detects if playMode test are enabled and creates corresponding tasks.

:check
\--- :test
     +--- :testEditMode
     |    +--- :testEditModeAndroid
     |    \--- :testEditModeIos
     \--- :testPlayMode
          +--- :testPlayModeAndroid
          \--- :testPlayModeIos

Setting up custom test tasks

build.gradle unity 5.5

task("myTests", type:wooga.gradle.unity.tasks.Test) {
    categories = ["Category1",..]
    filter = ["filter",..]
    verbose = true
    teamcity = false
}

build.gradle unity 5.6

task("myEditModeTests", type:wooga.gradle.unity.tasks.Test) {
    testPlatform = "editmode"
}

task("myPlayModeTests", type:wooga.gradle.unity.tasks.Test) {
    testPlatform = "playmode"
}