Skip to content

Commit

Permalink
Use the preferred Gradle API
Browse files Browse the repository at this point in the history
  • Loading branch information
gesellix committed Sep 15, 2024
1 parent 9bd1ebb commit 5dcc94f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DebianPackagePlugin implements Plugin<Project> {

def addTasks(Project project) {
project.afterEvaluate {
project.tasks.withType(BuildDebianPackageTask).whenTaskAdded { task ->
project.tasks.withType(BuildDebianPackageTask).configureEach { task ->
def extension = project.extensions.findByName(DEBPKGPLUGIN_EXTENSION_NAME)
task.conventionMapping.with {
changelogFile = { project.file(extension.changelogFile) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class DebianPackagePluginSpec extends Specification {
project.evaluate()
assert DEBPKGTASK_NAME == 'buildDeb'
then: "there is a 'buildDeb' task registered"
project.tasks.findByName('buildDeb') in BuildDebianPackageTask
project.tasks.named('buildDeb').get() in BuildDebianPackageTask
}

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

then: "extension properties are mapped to task properties"
Task buildDebTask = project.tasks.findByName(DEBPKGTASK_NAME)
Task buildDebTask = project.tasks.named(DEBPKGTASK_NAME).getOrNull()
buildDebTask != null
buildDebTask.packagename == "packagename"
buildDebTask.changelogFile == new File("${projectDir}/../packagename/debian/changelog").canonicalFile
Expand All @@ -87,8 +87,8 @@ class DebianPackagePluginSpec extends Specification {
Project project = ProjectBuilder.builder().withName('projectname').withProjectDir(projectDir).build()
project.evaluate()
then:
Task buildDebTask = project.tasks.findByName(DEBPKGTASK_NAME)
Task publicationTask = project.tasks.findByName(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME)
Task buildDebTask = project.tasks.named(DEBPKGTASK_NAME).getOrNull()
Task publicationTask = project.tasks.named(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME).getOrNull()
buildDebTask.taskDependencies.getDependencies(buildDebTask).contains(publicationTask)
}

Expand All @@ -97,7 +97,7 @@ class DebianPackagePluginSpec extends Specification {
Project project = ProjectBuilder.builder().withName('projectname').withProjectDir(projectDir).build()
project.evaluate()
then:
Task buildDebTask = project.tasks.findByName(DEBPKGTASK_NAME)
buildDebTask.taskDependencies.getDependencies(buildDebTask).contains(project.tasks.findByName(ASSEMBLE_TASK_NAME))
Task buildDebTask = project.tasks.named(DEBPKGTASK_NAME).getOrNull()
buildDebTask.taskDependencies.getDependencies(buildDebTask).contains(project.tasks.named(ASSEMBLE_TASK_NAME).get())
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.gesellix.gradle.debian.tasks

import org.gradle.api.logging.Logger
import org.gradle.api.publish.Publication
import org.gradle.api.publish.ivy.IvyPublication
import spock.lang.Specification
import spock.lang.Unroll
Expand All @@ -16,7 +17,7 @@ class ArtifactCollectorTest extends Specification {
}

@Unroll("returns no artifacts for #publicationClass")
def "accepts only MavenPublications"(publicationClass) {
def "accepts only MavenPublications"(Class<Publication> publicationClass) {
def artifacts
def publicationMock = Mock(publicationClass)
given:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ class BuildDebianPackageTaskSpec extends Specification {
}

@Unroll("inadequately configured task should throw #expectedException with message like '#exceptionMessagePattern'")
def "buildPackage with invalid configuration"(taskConfig, expectedException, exceptionMessagePattern) {
def "buildPackage with invalid configuration"(taskConfig, Class<Throwable> expectedException, exceptionMessagePattern) {
when: "task is configured"
taskConfig(task)
task.buildPackage();
task.buildPackage()
then:
def e = thrown(expectedException)
e.message =~ exceptionMessagePattern
Expand Down

0 comments on commit 5dcc94f

Please sign in to comment.