Skip to content

Commit 18165d7

Browse files
committed
Share tests across modules
1 parent 3e3518e commit 18165d7

File tree

119 files changed

+1280
-1499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+1280
-1499
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
plugins {
2+
id "base-information"
3+
id "java-library"
4+
5+
id "com.diffplug.spotless"
6+
}
7+
8+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9+
// Spotless
10+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11+
12+
spotless {
13+
//Don't fail during the check: rather than enforcing guidelines, we use this plugin to fix mistakes automatically.
14+
enforceCheck false
15+
java {
16+
licenseHeaderFile rootProject.file( 'config/spotless/license.java' )
17+
removeUnusedImports()
18+
indentWithTabs( 4 )
19+
trimTrailingWhitespace()
20+
endWithNewline()
21+
}
22+
}
23+
24+
25+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26+
// Enforced rules
27+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28+
29+
def enforceRulesTask = tasks.register( "enforceRules" ) {
30+
description "Enforces some formatting rules to src/main/java files"
31+
doLast {
32+
def illegalImport = ~/^import (sun|java.awt|org.slf4j)/
33+
def missingNewline = ~/^\s*}\s*(else|catch|finally)/
34+
def lowerEll = ~/\b\d+l\b/
35+
def errors = 0
36+
def tree = fileTree( "src/main/java/" )
37+
tree.include "**/*.java"
38+
tree.each { file ->
39+
def lineNum = 0
40+
def shortName = file.path.substring( rootDir.path.length() )
41+
file.eachLine { line ->
42+
lineNum++
43+
if ( line =~ illegalImport ) {
44+
errors++
45+
logger.error( "Illegal import in ${shortName}\n${lineNum}: ${line}" )
46+
}
47+
if ( line =~ missingNewline ) {
48+
errors++
49+
logger.error( "Missing newline in ${shortName}\n${lineNum}: ${line}" )
50+
}
51+
if ( line =~ lowerEll ) {
52+
errors++
53+
logger.error( "Lowercase long literal in ${shortName}\n${lineNum}: ${line}" )
54+
}
55+
}
56+
}
57+
if ( errors > 0 ) {
58+
throw new GradleException( "Code rules were violated ($errors problems)" )
59+
}
60+
}
61+
}
62+
63+
64+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65+
// Lifecycle
66+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67+
68+
tasks.named( "check" ) {
69+
dependsOn enforceRulesTask
70+
dependsOn tasks.named( "spotlessCheck" )
71+
}
72+
73+
tasks.withType( JavaCompile ).configureEach {javaCompile->
74+
dependsOn tasks.named( "spotlessApply" )
75+
}
76+
Lines changed: 0 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
plugins {
22
id "base-information"
33
id "java-library"
4-
5-
id "com.diffplug.spotless"
6-
id "jacoco"
74
}
85

96
dependencies {
@@ -14,13 +11,6 @@ dependencies {
1411
annotationProcessor libs.loggingProcessor
1512
annotationProcessor libs.logging
1613
annotationProcessor libs.loggingAnnotations
17-
18-
testImplementation jakartaLibs.jpa
19-
testImplementation testLibs.junit5Api
20-
testImplementation testLibs.assertjCore
21-
22-
testRuntimeOnly testLibs.junit5Engine
23-
testRuntimeOnly testLibs.log4j
2414
}
2515

2616

@@ -31,13 +21,6 @@ dependencies {
3121
java {
3222
sourceCompatibility = jdks.versions.baseline.get() as int
3323
targetCompatibility = jdks.versions.baseline.get() as int
34-
35-
withJavadocJar()
36-
withSourcesJar()
37-
}
38-
39-
test {
40-
useJUnitPlatform()
4124
}
4225

4326
// create a single "compile" task
@@ -49,8 +32,6 @@ tasks.register( "compile" ).configure {
4932
tasks.withType( JavaCompile ).configureEach {javaCompile->
5033
options.encoding = "UTF-8"
5134
options.warnings false
52-
53-
dependsOn tasks.named( "spotlessApply" )
5435
}
5536

5637
// To force the build produce the same byte-for-byte archives and hence make Hibernate Models build reproducible.
@@ -60,103 +41,3 @@ tasks.withType( AbstractArchiveTask ).configureEach {
6041
reproducibleFileOrder = true
6142
}
6243

63-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64-
// Javadoc
65-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66-
67-
tasks.named( "javadoc", Javadoc ) {
68-
options {
69-
use = true
70-
encoding = "UTF-8"
71-
72-
addStringOption( "Xdoclint:none", "-quiet" )
73-
74-
tags(
75-
"todo:X",
76-
"apiNote:a:API Note:",
77-
"implSpec:a:Implementation Specification:",
78-
"implNote:a:Implementation Note:"
79-
)
80-
}
81-
}
82-
83-
84-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
85-
// Spotless
86-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
87-
88-
spotless {
89-
//Don't fail during the check: rather than enforcing guidelines, we use this plugin to fix mistakes automatically.
90-
enforceCheck false
91-
java {
92-
licenseHeaderFile rootProject.file( 'config/spotless/license.java' )
93-
removeUnusedImports()
94-
indentWithTabs( 4 )
95-
trimTrailingWhitespace()
96-
endWithNewline()
97-
}
98-
}
99-
100-
101-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102-
// Enforced rules
103-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104-
105-
def enforceRulesTask = tasks.register( "enforceRules" ) {
106-
description "Enforces some formatting rules to src/main/java files"
107-
doLast {
108-
def illegalImport = ~/^import (sun|java.awt|org.slf4j)/
109-
def missingNewline = ~/^\s*}\s*(else|catch|finally)/
110-
def lowerEll = ~/\b\d+l\b/
111-
def errors = 0
112-
def tree = fileTree( "src/main/java/" )
113-
tree.include "**/*.java"
114-
tree.each { file ->
115-
def lineNum = 0
116-
def shortName = file.path.substring( rootDir.path.length() )
117-
file.eachLine { line ->
118-
lineNum++
119-
if ( line =~ illegalImport ) {
120-
errors++
121-
logger.error( "Illegal import in ${shortName}\n${lineNum}: ${line}" )
122-
}
123-
if ( line =~ missingNewline ) {
124-
errors++
125-
logger.error( "Missing newline in ${shortName}\n${lineNum}: ${line}" )
126-
}
127-
if ( line =~ lowerEll ) {
128-
errors++
129-
logger.error( "Lowercase long literal in ${shortName}\n${lineNum}: ${line}" )
130-
}
131-
}
132-
}
133-
if ( errors > 0 ) {
134-
throw new GradleException( "Code rules were violated ($errors problems)" )
135-
}
136-
}
137-
}
138-
139-
140-
141-
142-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143-
// JaCoCo
144-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
145-
146-
def jacocoReportTask = tasks.named( "jacocoTestReport" ) {
147-
dependsOn tasks.named( "test" )
148-
}
149-
150-
jacocoTestReport {
151-
reports {
152-
xml.required = false
153-
csv.required = false
154-
html.outputLocation = layout.buildDirectory.dir( "jacocoHtml" )
155-
}
156-
}
157-
158-
tasks.named( "check" ) {
159-
dependsOn enforceRulesTask
160-
dependsOn tasks.named( "spotlessCheck" )
161-
dependsOn jacocoReportTask
162-
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
11
plugins {
22
id "java-module"
3+
id "testing"
4+
id "code-quality"
35

46
id "maven-publish"
57
id "publishing-config"
68
id "signing-config"
9+
}
10+
11+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12+
// Java handling
13+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14+
15+
java {
16+
withJavadocJar()
17+
withSourcesJar()
18+
}
19+
20+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21+
// Javadoc
22+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23+
24+
tasks.named( "javadoc", Javadoc ) {
25+
options {
26+
use = true
27+
encoding = "UTF-8"
28+
29+
addStringOption( "Xdoclint:none", "-quiet" )
30+
31+
tags(
32+
"todo:X",
33+
"apiNote:a:API Note:",
34+
"implSpec:a:Implementation Specification:",
35+
"implNote:a:Implementation Note:"
36+
)
37+
}
738
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
plugins {
2+
id "testing"
3+
}
4+
5+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6+
// Wire in the shared-tests
7+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8+
9+
// link the
10+
configurations {
11+
sharedTestClasses {
12+
canBeConsumed = false
13+
canBeResolved = true
14+
}
15+
sharedTestResources {
16+
canBeConsumed = false
17+
canBeResolved = true
18+
}
19+
sharedTestRuntimeClasspath {
20+
canBeConsumed = false
21+
canBeResolved = true
22+
extendsFrom testRuntimeClasspath
23+
}
24+
}
25+
26+
dependencies {
27+
testImplementation project( path: ":hibernate-models", configuration: "exposedTestClasses" )
28+
29+
sharedTestClasses project(path: ':hibernate-models', configuration: 'exposedTestClasses')
30+
sharedTestResources project(path: ':hibernate-models', configuration: 'exposedTestResources')
31+
sharedTestRuntimeClasspath project(path: ':hibernate-models', configuration: 'exposedTestRuntimeClasspath')
32+
}
33+
34+
tasks.named( "test", Test ) {
35+
// use the configurations defined above, which depends on the configurations in `:architecture-tests`
36+
testClassesDirs += configurations.sharedTestClasses
37+
38+
classpath += configurations.sharedTestResources
39+
classpath += configurations.sharedTestRuntimeClasspath
40+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
plugins {
2+
id "java-module"
3+
id "jacoco"
4+
}
5+
6+
dependencies {
7+
testImplementation jakartaLibs.jpa
8+
testImplementation testLibs.junit5Api
9+
testImplementation testLibs.assertjCore
10+
11+
testImplementation testLibs.junit5Engine
12+
testImplementation testLibs.log4j
13+
}
14+
15+
test {
16+
useJUnitPlatform()
17+
}
18+
19+
20+
21+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22+
// JaCoCo
23+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24+
25+
def jacocoReportTask = tasks.named( "jacocoTestReport" ) {
26+
dependsOn tasks.named( "test" )
27+
}
28+
29+
jacocoTestReport {
30+
reports {
31+
xml.required = false
32+
csv.required = false
33+
html.outputLocation = layout.buildDirectory.dir( "jacocoHtml" )
34+
}
35+
}
36+
37+
tasks.named( "check" ) {
38+
dependsOn jacocoReportTask
39+
}

hibernate-models-jandex/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id "published-java-module"
3+
id "shared-testing"
34
}
45

56
description = "Jandex support for hibernate-models (isolated dependency)"
@@ -8,6 +9,4 @@ dependencies {
89
api project( ":hibernate-models" )
910

1011
implementation libs.jandex
11-
12-
testImplementation project( ":hibernate-models-testing" )
1312
}

hibernate-models-jandex/src/main/java/org/hibernate/models/jandex/internal/JandexBuilders.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public static <V> JandexValueExtractor<V> buildValueHandlersReturnExtractor(
317317
if ( isDouble( valueTypeDescriptor ) ) {
318318
converterCollector.accept( valueTypeDescriptor, (JandexValueConverter<V>) DoubleValueConverter.JANDEX_DOUBLE_VALUE_WRAPPER );
319319
extractorCollector.accept( valueTypeDescriptor, (JandexValueExtractor<V>) DoubleValueExtractor.JANDEX_DOUBLE_EXTRACTOR );
320-
return (JandexValueExtractor<V>) DoubleValueConverter.JANDEX_DOUBLE_VALUE_WRAPPER;
320+
return (JandexValueExtractor<V>) DoubleValueExtractor.JANDEX_DOUBLE_EXTRACTOR;
321321
}
322322

323323
if ( isFloat( valueTypeDescriptor ) ) {

0 commit comments

Comments
 (0)