Skip to content

Commit

Permalink
Publish module-alignment metadata (#2075)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Jan 13, 2025
1 parent 6c584d3 commit 21d467d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
15 changes: 9 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ apply from: script("ide")

boolean isCiServer = System.env["CI"] || System.env["GITHUB_ACTIONS"]
subprojects {
if (it.name == "spock-bom") return

apply plugin: "java-library"
apply plugin: "groovy"
apply plugin: "jacoco"
Expand Down Expand Up @@ -160,6 +162,7 @@ subprojects {
}

dependencies {
api platform(projects.spockBom)
implementation(project.name == "spock-gradle" ? [] : groovylibs.groovy)
}

Expand Down Expand Up @@ -238,7 +241,7 @@ tasks.register("collectTestXml") {
tasks.register("codeCoverageReport", JacocoReport) {
group = 'Coverage reports'
description = "Creates an aggregate coverage for the whole project."
def reportingProjects = subprojects
def reportingProjects = subprojects - project(projects.spockBom.path)
dependsOn(reportingProjects.tasks.collectMany { it.withType(Test) })

additionalSourceDirs.from(reportingProjects.sourceSets.main.allSource.srcDirs)
Expand Down Expand Up @@ -348,8 +351,8 @@ tasks.register("tagRelease", Exec) {
tasks.register("javadoc", Javadoc) {
title "Spock Framework API Documentation ($variantLessVersion)"
destinationDir file("build/javadoc/$variantLessVersion")
source subprojects.collect { project -> project.tasks.named("javadoc").map { it.source } }
classpath = files(subprojects.collect { project -> project.tasks.named("javadoc").map { it.classpath } })
source((subprojects - project(projects.spockBom.path)).collect { project -> project.tasks.named("javadoc").map { it.source } })
classpath = files((subprojects - project(projects.spockBom.path)).collect { project -> project.tasks.named("javadoc").map { it.classpath } })
}

configureJavadoc(tasks.named("javadoc"), true)
Expand All @@ -358,9 +361,9 @@ tasks.register("groovydoc", Groovydoc) {
docTitle "Spock Framework API Documentation ($variantLessVersion)"
windowTitle "Spock Framework API Documentation ($variantLessVersion)"
destinationDir file("build/groovydoc/$variantLessVersion")
source subprojects.collect { project -> project.tasks.named("groovydoc").map { it.source } }
classpath = files(subprojects.collect { project -> project.tasks.named("groovydoc").map { it.classpath } })
groovyClasspath = files(projects.spockCore.dependencyProject.tasks.named("groovydoc").map { it.groovyClasspath })
source((subprojects - project(projects.spockBom.path)).collect { project -> project.tasks.named("groovydoc").map { it.source } })
classpath = files((subprojects - project(projects.spockBom.path)).collect { project -> project.tasks.named("groovydoc").map { it.classpath } })
groovyClasspath = files(project(projects.spockCore.path).tasks.named("groovydoc").map { it.groovyClasspath })

access = GroovydocAccess.PROTECTED
processScripts = false
Expand Down
4 changes: 3 additions & 1 deletion gradle/publishMaven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ publishing {
maven(MavenPublication) {
afterEvaluate {
pom.packaging = project.ext.packaging
if (project.ext.packaging != "pom") {
if (project.ext.packaging == "pom") {
from(components.javaPlatform)
} else {
from(components.java)
artifact(sourcesJar)
artifact(javadocJar)
Expand Down
35 changes: 13 additions & 22 deletions spock-bom/bom.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
apply from: script("publishMaven")

def modifyBom = { xml ->
def projectNode = xml.asNode()

projectNode.appendNode('properties').appendNode('spock.version', project.fullVersion)

def dependencyManagement = projectNode.appendNode('dependencyManagement').appendNode('dependencies')
plugins {
id('java-platform')
}
apply from: script('publishMaven')

def mvnProjects = project.parent.subprojects.findAll { it.plugins.hasPlugin('maven-publish') } // find all published projects
mvnProjects -= project // don't self reference
(rootProject.subprojects - project).each {
evaluationDependsOn(it.path)
}

String groupId = project.group
mvnProjects.name.each {
dependencyManagement.appendNode('dependency').with { dep ->
dep.appendNode('groupId', groupId)
dep.appendNode('artifactId', it)
dep.appendNode('version', '${spock.version}')
dependencies {
constraints {
def mvnProjects = rootProject.subprojects.findAll { it.plugins.hasPlugin('maven-publish') } // find all published projects
mvnProjects -= project // don't self reference
mvnProjects.each {
api("${it.group}:${it.name}:${it.version}")
}
}
}

ext.displayName = 'Spock Framework - Bill of Materials'
description = 'This bill of materials provides managed spock dependencies.'
ext.packaging = 'pom'

publishing.publications.maven {
pom {
withXml modifyBom
}
}

0 comments on commit 21d467d

Please sign in to comment.