Skip to content

Commit

Permalink
Introduce a BOM for Mockito's artifacts (closes #2321)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Keller committed Jun 11, 2021
1 parent ef34307 commit 7b5d9e8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 32 deletions.
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")

rootProject.name = "mockito"

Expand Down

0 comments on commit 7b5d9e8

Please sign in to comment.