Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Attach paketUnityInstall task to all relevant tasks (#13)
Browse files Browse the repository at this point in the history
* Attach paketUnityInstall task to all relevant tasks

* Removed unused variable declaration
  • Loading branch information
marcolink authored and Larusso committed Jan 11, 2018
1 parent 93de0cb commit ad327f4
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

package wooga.gradle.paket.get

import spock.lang.Ignore
import spock.lang.Unroll
import wooga.gradle.paket.PaketIntegrationDependencyFileSpec
import wooga.gradle.paket.unity.PaketUnityPlugin

class PaketInstallIntegrationSpec extends PaketIntegrationDependencyFileSpec {

Expand Down Expand Up @@ -188,6 +188,5 @@ class PaketInstallIntegrationSpec extends PaketIntegrationDependencyFileSpec {
then:
!lockFile.text.contains("$nuget1 ($version1)")
lockFile.text.contains("$nuget2 ($version2)")

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import nebula.test.IntegrationSpec
import nebula.test.functional.ExecutionResult
import spock.lang.Shared
import spock.lang.Unroll
import wooga.gradle.paket.get.PaketGetPlugin

class PaketUnityIntegrationSpec extends IntegrationSpec {

Expand Down Expand Up @@ -72,7 +73,7 @@ class PaketUnityIntegrationSpec extends IntegrationSpec {

then:
hasNoSource(result, "paketUnityBootstrap")
hasNoSource(result,taskToRun)
hasNoSource(result, taskToRun)

where:
taskToRun << bootstrapTestCases
Expand Down Expand Up @@ -113,12 +114,12 @@ class PaketUnityIntegrationSpec extends IntegrationSpec {
then: "bootstrap task was [UP-TO-DATE]"
result1.wasUpToDate("paketUnityBootstrap")

when:"delete bootstrapper"
when: "delete bootstrapper"
def paketDir = new File(projectDir, '.paket')
def paketBootstrap = new File(paketDir, 'paket.unity3d.bootstrapper.exe')
paketBootstrap.delete()

and:"run the task again"
and: "run the task again"
def result2 = runTasksSuccessfully(taskToRun)

then:
Expand All @@ -145,6 +146,44 @@ class PaketUnityIntegrationSpec extends IntegrationSpec {
taskToRun << bootstrapTestCases
}

@Unroll
def "run paketUnityInstall after #taskToRun"(String taskToRun) {
given: "a small test nuget package"
def nuget = "Mini"

and: "apply paket get plugin to get paket unity install task"
buildFile << """
${applyPlugin(PaketGetPlugin)}
""".stripIndent()

and: "paket dependency file and lock"
def dependencies = createFile("paket.dependencies")
createFile("paket.lock")

dependencies << """
source https://nuget.org/api/v2
nuget $nuget
""".stripIndent()

and: "the future packages directory"
def packagesDir = new File(projectDir, 'packages')
assert !packagesDir.exists()

when:
def result = runTasksSuccessfully(taskToRun)

then:
result.wasExecuted(PaketUnityPlugin.INSTALL_TASK_NAME)

where:
taskToRun | _
PaketGetPlugin.INSTALL_TASK_NAME | _
PaketGetPlugin.UPDATE_TASK_NAME | _
PaketGetPlugin.RESTORE_TASK_NAME | _
"paketUpdateMini" | _
}

boolean hasNoSource(ExecutionResult result, String taskName) {
containsOutput(result.standardOutput, taskName, "NO-SOURCE")
}
Expand Down
15 changes: 10 additions & 5 deletions src/main/groovy/wooga/gradle/paket/unity/PaketUnityPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

package wooga.gradle.paket.unity

import org.gradle.api.Action
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.tasks.TaskContainer
import wooga.gradle.paket.base.PaketBasePlugin
import wooga.gradle.paket.base.tasks.AbstractPaketTask
import wooga.gradle.paket.get.PaketGetPlugin
import wooga.gradle.paket.get.tasks.PaketUpdate
import wooga.gradle.paket.unity.tasks.PaketUnityBootstrap
import wooga.gradle.paket.unity.tasks.PaketUnityInstall

Expand Down Expand Up @@ -71,13 +71,18 @@ class PaketUnityPlugin implements Plugin<Project> {

void configurePaketDependencyInstallIfPresent() {
project.plugins.withType(PaketGetPlugin) {

def paketUnityInstall = tasks[INSTALL_TASK_NAME]
def paketInstall = project.tasks[PaketGetPlugin.INSTALL_TASK_NAME]
def paketUpdate = project.tasks[PaketGetPlugin.UPDATE_TASK_NAME]
def paketRestore = project.tasks[PaketGetPlugin.RESTORE_TASK_NAME]

[paketInstall, paketUpdate, paketRestore].each { Task task ->
task.finalizedBy tasks[PaketUnityPlugin.INSTALL_TASK_NAME]
Closure configClosure = { task ->
task.finalizedBy paketUnityInstall
}

project.tasks.withType(PaketUpdate, configClosure)

[paketInstall, paketRestore].each configClosure
}
}
}

0 comments on commit ad327f4

Please sign in to comment.