Skip to content

Commit 0836195

Browse files
committed
Add junit-bom subproject
Issue: #316
1 parent 4579fe6 commit 0836195

File tree

7 files changed

+164
-100
lines changed

7 files changed

+164
-100
lines changed

build.gradle

Lines changed: 9 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,16 @@ subprojects { subproj ->
291291
}
292292

293293
if (subproj.name in mavenizedProjects) {
294-
apply plugin: 'maven'
295-
apply plugin: 'signing'
296294

297-
if (subproj.name in platformProjects) {
295+
apply from: "$rootDir/gradle/maven.gradle"
296+
297+
subproj.ext.baseline = null
298+
299+
if (subproj.name in jupiterProjects) {
300+
subproj.group = jupiterGroup
301+
subproj.baseline = jupiterBaseline
302+
}
303+
else if (subproj.name in platformProjects) {
298304
subproj.group = platformGroup
299305
subproj.version = platformVersion
300306
subproj.baseline = platformBaseline
@@ -371,102 +377,7 @@ subprojects { subproj ->
371377
}
372378
}
373379

374-
def isSnapshot = project.version.contains('SNAPSHOT')
375-
def isContinuousIntegrationEnvironment = Boolean.parseBoolean(System.getenv('CI'))
376-
def isJitPackEnvironment = Boolean.parseBoolean(System.getenv('JITPACK'))
377-
def signArtifacts = !(isSnapshot || isContinuousIntegrationEnvironment || isJitPackEnvironment)
378-
379-
afterEvaluate {
380-
if (signArtifacts && uploadArchives.enabled) {
381-
signing {
382-
sign configurations.archives
383-
}
384-
}
385-
}
386-
387-
uploadArchives {
388-
389-
dependsOn check
390-
391-
repositories {
392-
mavenDeployer {
393-
394-
if (signArtifacts) {
395-
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
396-
}
397-
398-
def ossrhUsername = rootProject.hasProperty('ossrhUsername') ? rootProject.ossrhUsername : ''
399-
def ossrhPassword = rootProject.hasProperty('ossrhPassword') ? rootProject.ossrhPassword : ''
400-
401-
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
402-
authentication(userName: ossrhUsername, password: ossrhPassword)
403-
}
404-
405-
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
406-
authentication(userName: ossrhUsername, password: ossrhPassword)
407-
}
408-
409-
def projectLicense = licenseOf(project)
410-
411-
pom.project {
412-
name "${project.group}:${project.name}"
413-
packaging 'jar'
414-
description "Module \"${project.name}\" of JUnit 5."
415-
url 'http://junit.org/junit5/'
416-
417-
scm {
418-
connection 'scm:git:git://github.com/junit-team/junit5.git'
419-
developerConnection 'scm:git:git://github.com/junit-team/junit5.git'
420-
url 'https://github.com/junit-team/junit5'
421-
}
422-
423-
licenses {
424-
license {
425-
name projectLicense['name']
426-
url projectLicense['url']
427-
}
428-
}
429380

430-
developers {
431-
developer {
432-
id 'bechte'
433-
name 'Stefan Bechtold'
434-
435-
}
436-
developer {
437-
id 'jlink'
438-
name 'Johannes Link'
439-
440-
}
441-
developer {
442-
id 'marcphilipp'
443-
name 'Marc Philipp'
444-
445-
}
446-
developer {
447-
id 'mmerdes'
448-
name 'Matthias Merdes'
449-
450-
}
451-
developer {
452-
id 'sbrannen'
453-
name 'Sam Brannen'
454-
455-
}
456-
developer {
457-
id 'sormuras'
458-
name 'Christian Stein'
459-
460-
}
461-
}
462-
}
463-
464-
pom.whenConfigured { p ->
465-
p.dependencies = p.dependencies.findAll { dep -> dep.scope != 'test' }
466-
}
467-
}
468-
}
469-
}
470381
} else {
471382
jar.enabled = false
472383
javadoc.enabled = false

gradle.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
group = org.junit.jupiter
1+
group = org.junit
22
version = 5.2.0-SNAPSHOT
3-
baseline = 5.1.0
3+
4+
jupiterGroup = org.junit.jupiter
5+
jupiterBaseline = 5.1.0
46

57
platformGroup = org.junit.platform
68
platformVersion = 1.2.0-SNAPSHOT

gradle/maven.gradle

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
apply plugin: 'maven'
2+
apply plugin: 'signing'
3+
4+
def isSnapshot = project.version.contains('SNAPSHOT')
5+
def isContinuousIntegrationEnvironment = Boolean.parseBoolean(System.getenv('CI'))
6+
def isJitPackEnvironment = Boolean.parseBoolean(System.getenv('JITPACK'))
7+
def signArtifacts = !(isSnapshot || isContinuousIntegrationEnvironment || isJitPackEnvironment)
8+
9+
afterEvaluate {
10+
if (signArtifacts && uploadArchives.enabled) {
11+
signing {
12+
sign configurations.archives
13+
}
14+
}
15+
}
16+
17+
uploadArchives {
18+
19+
dependsOn check
20+
21+
repositories {
22+
mavenDeployer {
23+
24+
if (signArtifacts) {
25+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
26+
}
27+
28+
def ossrhUsername = rootProject.hasProperty('ossrhUsername') ? rootProject.ossrhUsername : ''
29+
def ossrhPassword = rootProject.hasProperty('ossrhPassword') ? rootProject.ossrhPassword : ''
30+
31+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
32+
authentication(userName: ossrhUsername, password: ossrhPassword)
33+
}
34+
35+
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
36+
authentication(userName: ossrhUsername, password: ossrhPassword)
37+
}
38+
39+
def projectLicense = licenseOf(project)
40+
41+
pom.project {
42+
name "${project.group}:${project.name}"
43+
packaging 'jar'
44+
description "Module \"${project.name}\" of JUnit 5."
45+
url 'http://junit.org/junit5/'
46+
47+
scm {
48+
connection 'scm:git:git://github.com/junit-team/junit5.git'
49+
developerConnection 'scm:git:git://github.com/junit-team/junit5.git'
50+
url 'https://github.com/junit-team/junit5'
51+
}
52+
53+
licenses {
54+
license {
55+
name projectLicense['name']
56+
url projectLicense['url']
57+
}
58+
}
59+
60+
developers {
61+
developer {
62+
id 'bechte'
63+
name 'Stefan Bechtold'
64+
65+
}
66+
developer {
67+
id 'jlink'
68+
name 'Johannes Link'
69+
70+
}
71+
developer {
72+
id 'marcphilipp'
73+
name 'Marc Philipp'
74+
75+
}
76+
developer {
77+
id 'mmerdes'
78+
name 'Matthias Merdes'
79+
80+
}
81+
developer {
82+
id 'sbrannen'
83+
name 'Sam Brannen'
84+
85+
}
86+
developer {
87+
id 'sormuras'
88+
name 'Christian Stein'
89+
90+
}
91+
}
92+
}
93+
94+
pom.whenConfigured {
95+
dependencies = dependencies.findAll { dep -> dep.scope != 'test' }
96+
}
97+
}
98+
}
99+
}

junit-bom/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Module junit-bom
2+
3+
This module provides a Bill of Materials POM to ease dependency management
4+
using Maven [1] or Gradle [2]. Please refer to the JUnit 5 User Guide [3] for
5+
details.
6+
7+
[1] https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies
8+
[2] https://docs.gradle.org/4.6-rc-1/userguide/managing_transitive_dependencies.html#sec:bom_import
9+
[3] https://junit.org/junit5/docs/current/user-guide/#dependency-metadata-junit-bom

junit-bom/junit-bom.gradle

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
description = rootProject.description + " (Bill of Materials)"
2+
3+
configurations.archives.artifacts.clear()
4+
artifacts {
5+
archives file("README.md") // work around GRADLE-2406 by attaching text artifact
6+
}
7+
8+
apply from: "$rootDir/gradle/maven.gradle"
9+
10+
uploadArchives {
11+
enabled = true
12+
repositories.mavenDeployer.pom {
13+
project {
14+
artifactId = project.name
15+
name = project.description
16+
description = project.description
17+
}
18+
whenConfigured {
19+
packaging = "pom"
20+
dependencies = []
21+
withXml {
22+
asNode().children().last() + {
23+
delegate.dependencyManagement {
24+
delegate.dependencies {
25+
parent.mavenizedProjects.sort()
26+
.findAll { name -> project.name != name }
27+
.collect { name -> rootProject.project(name) }
28+
.each { project ->
29+
delegate.dependency {
30+
delegate.groupId(project.group)
31+
delegate.artifactId(project.name)
32+
delegate.version(project.version)
33+
}
34+
}
35+
}
36+
}
37+
}
38+
}
39+
}
40+
}
41+
}

platform-tests/src/test/java/org/junit/AutomaticModuleNameTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ private static List<String> moduleDirectoryNames() throws IOException {
6868
.filter(line -> line.startsWith(startOfModuleLine))
6969
.map(line -> line.substring(startOfModuleLine.length(), line.length() - 1))
7070
.filter(name -> !name.equals("junit-platform-console-standalone"))
71+
.filter(name -> !name.equals("junit-bom"))
7172
.filter(name -> !name.endsWith("-java-9"))
7273
.filter(name -> name.startsWith("junit-"))) {
7374
return stream.collect(Collectors.toList());

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ include 'junit-platform-suite-api'
2424
include 'junit-platform-surefire-provider'
2525
include 'junit-vintage-engine'
2626
include 'platform-tests'
27+
include 'junit-bom'
2728

2829
// check that every subproject has a custom build file
2930
// based on the project name

0 commit comments

Comments
 (0)