Skip to content

Commit

Permalink
Fix missing task file input declaration (#35)
Browse files Browse the repository at this point in the history
Description
===========

The `CopySpec` allows to define source path declarations from multiple
sources. If the input is a task or a configuration gradle would normally
execute the tasks to produce the connected artifacts. As pointed out in
[issue 30] the publish tasks missed a declaration step to tell gradle to
connect these input/outputs.

Changes
=======

![FIX] missing file input declaration

[issue 30]: #30
  • Loading branch information
Larusso authored Apr 25, 2019
1 parent 8e1d9c1 commit 31cdcf9
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package wooga.gradle.github
import spock.genesis.Gen
import spock.genesis.transform.Iterations
import spock.lang.IgnoreIf
import spock.lang.Issue
import spock.lang.Shared
import spock.lang.Unroll

Expand Down Expand Up @@ -402,4 +403,118 @@ class GithubPublishAssetsIntegrationSpec extends GithubPublishIntegrationWithDef
tagName = "v0.${tag}.0-GithubPublishAssetsIntegrationSpec"
}
@Issue("https://github.com/wooga/atlas-github/issues/30")
def "executes depended tasks and fetches task outputs"() {
given: "a task that produces an output"
buildFile << """
task createOutput {
outputs.file("build/outputs/${assetName}")

doLast {
def outputFile = file("build/outputs/${assetName}")
outputFile.parentFile.mkdirs()
outputFile.text = "${assetContent}"
}
}
""".stripIndent()
and: "a publish task which from points to the custom task"
buildFile << """
task testPublish(type:wooga.gradle.github.publish.tasks.GithubPublish) {
tagName = "$tagName"
releaseName = "$tagName"

from(createOutput)
}
"""
when:
def result = runTasksSuccessfully("testPublish")
then:
result.wasExecuted("createOutput")
def release = getRelease(tagName)
def assets = release.getAssets()
assets.size() == 1
assets[0].name == assetName
where:
tagName = "v0.8.0-GithubPublishIntegrationSpec"
assetName = "list.txt"
assetContent = "Custom content"
}
@Issue("https://github.com/wooga/atlas-github/issues/30")
def "executes depended tasks through configuration"() {
given: "a subproject that produces an artifact"
addSubproject("sub", """
plugins {
id "base"
}

def outputFile = file("build/outputs/${assetName}")

task createOutput {
doLast {
outputFile.parentFile.mkdirs()
outputFile.text = "${assetContent}"
}
}

assemble.dependsOn createOutput

configurations {
output
}

configurations['default'].extendsFrom(configurations.output)

artifacts {
output(outputFile) {
builtBy project.tasks.createOutput
}
}

""".stripIndent())
and: "a dependency to the sub project artifact"
buildFile << """

configurations {
sub
}

dependencies {
sub project(':sub')
}

""".stripIndent()
and: "a publish task which from points to a configuration"
buildFile << """
task testPublish(type:wooga.gradle.github.publish.tasks.GithubPublish) {
tagName = "$tagName"
releaseName = "$tagName"

from(configurations.sub)
}
"""
when:
def result = runTasksSuccessfully("testPublish")
then:
result.wasExecuted(":sub:createOutput")
def release = getRelease(tagName)
def assets = release.getAssets()
assets.size() == 1
assets[0].name == assetName
where:
tagName = "v0.9.0-GithubPublishIntegrationSpec"
assetName = "output.txt"
assetContent = "Custom content"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import groovy.io.FileType
import groovy.json.JsonSlurper
import org.apache.commons.io.FileUtils
import org.gradle.api.Action
import org.gradle.api.Buildable
import org.gradle.api.GradleException
import org.gradle.api.Task
import org.gradle.api.file.CopySpec
import org.gradle.api.file.FileTreeElement
import org.gradle.api.logging.Logger
Expand Down Expand Up @@ -339,6 +341,7 @@ class GithubPublish extends AbstractGithubTask implements GithubPublishSpec {
*/
@Override
GithubPublish from(Object... sourcePaths) {
this.inputs.files(sourcePaths)
assetsCopySpec.from(sourcePaths)
processAssets = true
this
Expand Down Expand Up @@ -366,6 +369,7 @@ class GithubPublish extends AbstractGithubTask implements GithubPublishSpec {
*/
@Override
GithubPublish from(Object sourcePath, Action<? super CopySpec> configureAction) {
this.inputs.files(sourcePath)
assetsCopySpec.from(sourcePath, configureAction)
processAssets = true
this
Expand Down

0 comments on commit 31cdcf9

Please sign in to comment.