Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a BOM for Mockito's artifacts (closes #2321) #2323

Merged
merged 1 commit into from Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions gradle/java-library.gradle
@@ -1,7 +1,5 @@
apply plugin: "java"

group = 'org.mockito'

if (!archivesBaseName.startsWith("mockito-")) {
archivesBaseName = "mockito-" + project.name
}
Expand Down
72 changes: 43 additions & 29 deletions gradle/java-publication.gradle
@@ -1,30 +1,35 @@
//Sources/javadoc artifacts required by Maven module publications
def licenseSpec = copySpec {
from project.rootDir
include "LICENSE"
}
group = 'org.mockito'

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
with licenseSpec
}
plugins.withId("java") {
//Sources/javadoc artifacts required by Maven module publications
def licenseSpec = copySpec {
from project.rootDir
include "LICENSE"
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from tasks.javadoc
with licenseSpec
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
with licenseSpec
}

jar {
with licenseSpec
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from tasks.javadoc
with licenseSpec
}

artifacts {
archives sourcesJar
archives javadocJar
artifacts {
archives sourcesJar
archives javadocJar
}

jar {
with licenseSpec
}
}


tasks.withType(GenerateModuleMetadata) {
enabled = false
}
Expand All @@ -34,20 +39,27 @@ apply plugin: "maven-publish"
publishing {
publications {
javaLibrary(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
plugins.withId("java") {
from components.java
artifact sourcesJar
artifact javadocJar
}
plugins.withId("java-platform") {
from components.javaPlatform
}

artifactId = project.archivesBaseName

pom {
name = artifactId
description = project.description

//Gradle does not write 'jar' packaging to the pom (unlike other packaging types).
//This is OK because 'jar' is implicit/default:
// https://maven.apache.org/guides/introduction/introduction-to-the-pom.html#minimal-pom
packaging = project.tasks.jar.extension
plugins.withId("java") {
//Gradle does not write 'jar' packaging to the pom (unlike other packaging types).
//This is OK because 'jar' is implicit/default:
// https://maven.apache.org/guides/introduction/introduction-to-the-pom.html#minimal-pom
packaging = project.tasks.jar.extension
}

url = "https://github.com/mockito/mockito"
licenses {
Expand Down Expand Up @@ -88,8 +100,10 @@ publishing {
repositories { maven { url = "$buildDir/repo" } }
}

plugins.withId("java") {
//fleshes out problems with Maven pom generation when building
tasks.build.dependsOn("publishJavaLibraryPublicationToMavenLocal")
tasks.build.dependsOn("publishJavaLibraryPublicationToMavenLocal")
}

apply plugin: 'signing' //https://docs.gradle.org/current/userguide/signing_plugin.html
signing {
Expand Down
3 changes: 2 additions & 1 deletion settings.gradle.kts
Expand Up @@ -16,7 +16,8 @@ include("deprecatedPluginsTest",
"memory-test",
"errorprone",
"junitJupiterParallelTest",
"osgi-test")
"osgi-test",
"bom")
realdadfish marked this conversation as resolved.
Show resolved Hide resolved

rootProject.name = "mockito"

Expand Down
23 changes: 23 additions & 0 deletions subprojects/bom/bom.gradle
@@ -0,0 +1,23 @@
plugins {
id('java-platform')
}

description = "Mockito Bill of Materials (BOM)"

if (!archivesBaseName.startsWith("mockito-")) {
archivesBaseName = "mockito-" + project.name
}

apply from: "$rootDir/gradle/java-publication.gradle"

dependencies {
constraints {
project.rootProject.subprojects.forEach { subproject ->
if (!subproject.name.endsWith("Test") &&
!subproject.name.endsWith("-test") &&
subproject.name != "bom") {
api(subproject)
}
}
}
}