Skip to content

Commit 5dcc94f

Browse files
committed
Use the preferred Gradle API
1 parent 9bd1ebb commit 5dcc94f

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

src/main/groovy/de/gesellix/gradle/debian/DebianPackagePlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DebianPackagePlugin implements Plugin<Project> {
2525

2626
def addTasks(Project project) {
2727
project.afterEvaluate {
28-
project.tasks.withType(BuildDebianPackageTask).whenTaskAdded { task ->
28+
project.tasks.withType(BuildDebianPackageTask).configureEach { task ->
2929
def extension = project.extensions.findByName(DEBPKGPLUGIN_EXTENSION_NAME)
3030
task.conventionMapping.with {
3131
changelogFile = { project.file(extension.changelogFile) }

src/test/groovy/de/gesellix/gradle/debian/DebianPackagePluginSpec.groovy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class DebianPackagePluginSpec extends Specification {
6363
project.evaluate()
6464
assert DEBPKGTASK_NAME == 'buildDeb'
6565
then: "there is a 'buildDeb' task registered"
66-
project.tasks.findByName('buildDeb') in BuildDebianPackageTask
66+
project.tasks.named('buildDeb').get() in BuildDebianPackageTask
6767
}
6868

6969
def "can handle a debian configuration"() {
@@ -72,7 +72,7 @@ class DebianPackagePluginSpec extends Specification {
7272
project.evaluate()
7373

7474
then: "extension properties are mapped to task properties"
75-
Task buildDebTask = project.tasks.findByName(DEBPKGTASK_NAME)
75+
Task buildDebTask = project.tasks.named(DEBPKGTASK_NAME).getOrNull()
7676
buildDebTask != null
7777
buildDebTask.packagename == "packagename"
7878
buildDebTask.changelogFile == new File("${projectDir}/../packagename/debian/changelog").canonicalFile
@@ -87,8 +87,8 @@ class DebianPackagePluginSpec extends Specification {
8787
Project project = ProjectBuilder.builder().withName('projectname').withProjectDir(projectDir).build()
8888
project.evaluate()
8989
then:
90-
Task buildDebTask = project.tasks.findByName(DEBPKGTASK_NAME)
91-
Task publicationTask = project.tasks.findByName(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME)
90+
Task buildDebTask = project.tasks.named(DEBPKGTASK_NAME).getOrNull()
91+
Task publicationTask = project.tasks.named(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME).getOrNull()
9292
buildDebTask.taskDependencies.getDependencies(buildDebTask).contains(publicationTask)
9393
}
9494

@@ -97,7 +97,7 @@ class DebianPackagePluginSpec extends Specification {
9797
Project project = ProjectBuilder.builder().withName('projectname').withProjectDir(projectDir).build()
9898
project.evaluate()
9999
then:
100-
Task buildDebTask = project.tasks.findByName(DEBPKGTASK_NAME)
101-
buildDebTask.taskDependencies.getDependencies(buildDebTask).contains(project.tasks.findByName(ASSEMBLE_TASK_NAME))
100+
Task buildDebTask = project.tasks.named(DEBPKGTASK_NAME).getOrNull()
101+
buildDebTask.taskDependencies.getDependencies(buildDebTask).contains(project.tasks.named(ASSEMBLE_TASK_NAME).get())
102102
}
103103
}

src/test/groovy/de/gesellix/gradle/debian/tasks/ArtifactCollectorTest.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package de.gesellix.gradle.debian.tasks
22

33
import org.gradle.api.logging.Logger
4+
import org.gradle.api.publish.Publication
45
import org.gradle.api.publish.ivy.IvyPublication
56
import spock.lang.Specification
67
import spock.lang.Unroll
@@ -16,7 +17,7 @@ class ArtifactCollectorTest extends Specification {
1617
}
1718

1819
@Unroll("returns no artifacts for #publicationClass")
19-
def "accepts only MavenPublications"(publicationClass) {
20+
def "accepts only MavenPublications"(Class<Publication> publicationClass) {
2021
def artifacts
2122
def publicationMock = Mock(publicationClass)
2223
given:

src/test/groovy/de/gesellix/gradle/debian/tasks/BuildDebianPackageTaskSpec.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ class BuildDebianPackageTaskSpec extends Specification {
4141
}
4242

4343
@Unroll("inadequately configured task should throw #expectedException with message like '#exceptionMessagePattern'")
44-
def "buildPackage with invalid configuration"(taskConfig, expectedException, exceptionMessagePattern) {
44+
def "buildPackage with invalid configuration"(taskConfig, Class<Throwable> expectedException, exceptionMessagePattern) {
4545
when: "task is configured"
4646
taskConfig(task)
47-
task.buildPackage();
47+
task.buildPackage()
4848
then:
4949
def e = thrown(expectedException)
5050
e.message =~ exceptionMessagePattern

0 commit comments

Comments
 (0)