Skip to content

Commit

Permalink
Fix publish task
Browse files Browse the repository at this point in the history
Apparently the previous fix prevented gradle from ever registering the dependency between tasks. Or it did not matter for task scheduling any more. Thus this update

Signed-off-by: l-1sqared <30831153+l-1squared@users.noreply.github.com>
  • Loading branch information
l-1squared committed Oct 12, 2022
1 parent 5528c07 commit 3804c76
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions jgiven-maven-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,25 @@ task generatePom(type: Copy, dependsOn: copyClasses) {
}
}

task generateMavenPlugin(type: CrossPlatformExec, dependsOn: generatePom){
Set<Task> findPublishTask(String projectName){
project.rootProject.findProject(projectName).getTasks().findAll {it instanceof PublishToMavenLocal}
}

task generateMavenPlugin(type: CrossPlatformExec, dependsOn: [generatePom, findPublishTask("jgiven-core"), findPublishTask("jgiven-html5-report")]){
// currenlty it seems to be the more or less only clean solution
// to generate a plugin.xml file to use maven directly
// if anyone has a better solution please let us know!
buildCommand 'mvn', '-nsu', '-U', '-f', 'build/maven/pom.xml', 'plugin:descriptor'
}

Set<Task> findPublishTask(String projectName){
rootProject.findProject(projectName).getTasks().findAll {it instanceof PublishToMavenLocal}
}

generateMavenPlugin.onlyIf {
// as the generateMavenPlugin task requires mvn, it is only executed
// when actually uploading the archives
// that way the standard build stays maven-free
boolean shallGeneratePlugin = gradle.taskGraph.getAllTasks().any{it instanceof AbstractPublishToMaven}
if(shallGeneratePlugin){
generateMavenPlugin.dependsOn += findPublishTask("jgiven-core")
generateMavenPlugin.dependsOn += findPublishTask("jgiven-html5-report")
}
return shallGeneratePlugin

gradle.taskGraph.getAllTasks()
.findAll{task -> !findPublishTask("jgiven-core").contains(task)}
.findAll{ task -> !findPublishTask("jgiven-html5-report").contains(task) }
.any{it instanceof AbstractPublishToMaven}
}

task copyMavenPlugin(type: Copy, dependsOn: generateMavenPlugin) {
Expand Down

0 comments on commit 3804c76

Please sign in to comment.