Skip to content

Commit

Permalink
Set correct build target when generating export methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Larusso committed Jun 8, 2018
1 parent 23bd8ff commit d87ff6e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class UnityBuildPlayerTaskIntegrationSpec extends UnityIntegrationSpec {

result.standardOutput.contains("-executeMethod ${expectedExportMethod}")
result.standardOutput.contains("platform=${expectedPlatform}")
result.standardOutput.contains("-buildTarget ${expectedPlatform}")
result.standardOutput.contains("environment=${expectedEnvironment}")

where:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ package wooga.gradle.unity.build.tasks
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.OutputDirectory
import wooga.gradle.unity.batchMode.BatchModeFlags
import wooga.gradle.unity.batchMode.BuildTarget
import wooga.gradle.unity.tasks.internal.AbstractUnityProjectTask

class UnityBuildPlayerTask extends AbstractUnityProjectTask {
Expand Down Expand Up @@ -49,6 +51,14 @@ class UnityBuildPlayerTask extends AbstractUnityProjectTask {

void setBuildPlatform(String platform) {
buildPlatform = platform
try {
buildTarget = platform as BuildTarget
}
catch(IllegalArgumentException ignored) {
logger.warn("build target ${platform} unknown")
buildTarget = BuildTarget.undefined
}

}

void buildPlatform(String platform) {
Expand Down Expand Up @@ -84,6 +94,10 @@ class UnityBuildPlayerTask extends AbstractUnityProjectTask {
protected void exec() {
args "-executeMethod", getExportMethodName()
args "-CustomArgs:platform=${getBuildPlatform()};environment=${getBuildEnvironment()};outputPath=${getOutputDirectory().getPath()}"

if (buildTarget == BuildTarget.undefined) {
args BatchModeFlags.BUILD_TARGET, getBuildPlatform()
}
super.exec()
}
}

0 comments on commit d87ff6e

Please sign in to comment.