Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.integtests
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.InputFiles
import org.gradle.integtests.fixtures.AbstractIntegrationSpec
import spock.lang.Issue
class TaskUpToDateIntegrationTest extends AbstractIntegrationSpec {
@Issue("https://issues.gradle.org/browse/GRADLE-3540")
def "order of #annotation marks task not up-to-date"() {
buildFile << """
class MyTask extends DefaultTask {
@Output${files ? "Files" : "Directories"} FileCollection out
@TaskAction def exec() {
out.each { it${files ? ".text = 'data' + it.name" : ".mkdirs(); new File(it, 'contents').text = 'data' + it.name"} }
}
}
task myTask(type: MyTask) {
if (providers.gradleProperty("reverse").isPresent()) {
out = files("out2", "out1")
} else {
out = files("out1", "out2")
}
}
"""
run "myTask"
noneSkipped()
when:
run "myTask"
then:
skipped ":myTask"
when:
run "myTask", "-Preverse"
then:
executedAndNotSkipped ":myTask"
where:
annotation | files
'@OutputFiles' | true
'@OutputDirectories' | false
}
@Issue("https://issues.gradle.org/browse/GRADLE-3540")
def "hash set output files marks task up-to-date"() {
buildFile << """
class MyTask extends DefaultTask {
@OutputFiles Set out = new HashSet()
@TaskAction def exec() {
out.each { it.text = 'data' }
}
}
task myTask(type: MyTask) {
out.addAll([file("out1"), file("out2")])
}
"""
when:
run ':myTask'
then:
executedAndNotSkipped ':myTask'
when:
run ':myTask'
then:
skipped ':myTask'
}
@Issue("https://github.com/gradle/gradle/issues/3073")
def "optional output changed from null to non-null marks task not up-to-date"() {
buildFile << """
class CustomTask extends DefaultTask {
@OutputFile
@Optional
File outputFile
@TaskAction
void doAction() {
if (outputFile != null) {
outputFile.write "Task is running"
}
}
}
task customTask(type: CustomTask) {
outputFile = providers.gradleProperty('outputFile').map { file(it) }.orNull
}
"""
when:
succeeds "customTask"
then:
executedAndNotSkipped ":customTask"
when:
succeeds "customTask", "-PoutputFile=log.txt"
then:
executedAndNotSkipped ":customTask"
}
@Issue("https://github.com/gradle/gradle/issues/3073")
def "output files changed from #before to #after marks task #upToDateString"() {
buildFile << """
class CustomTask extends DefaultTask {
@OutputFiles
List