Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions buildSrc/src/main/groovy/code-quality.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
plugins {
id "base-information"
id "java-library"

id "com.diffplug.spotless"
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Spotless
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

spotless {
//Don't fail during the check: rather than enforcing guidelines, we use this plugin to fix mistakes automatically.
enforceCheck false
java {
licenseHeaderFile rootProject.file( 'config/spotless/license.java' )
removeUnusedImports()
indentWithTabs( 4 )
trimTrailingWhitespace()
endWithNewline()
}
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Enforced rules
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

def enforceRulesTask = tasks.register( "enforceRules" ) {
description "Enforces some formatting rules to src/main/java files"
doLast {
def illegalImport = ~/^import (sun|java.awt|org.slf4j)/
def missingNewline = ~/^\s*}\s*(else|catch|finally)/
def lowerEll = ~/\b\d+l\b/
def errors = 0
def tree = fileTree( "src/main/java/" )
tree.include "**/*.java"
tree.each { file ->
def lineNum = 0
def shortName = file.path.substring( rootDir.path.length() )
file.eachLine { line ->
lineNum++
if ( line =~ illegalImport ) {
errors++
logger.error( "Illegal import in ${shortName}\n${lineNum}: ${line}" )
}
if ( line =~ missingNewline ) {
errors++
logger.error( "Missing newline in ${shortName}\n${lineNum}: ${line}" )
}
if ( line =~ lowerEll ) {
errors++
logger.error( "Lowercase long literal in ${shortName}\n${lineNum}: ${line}" )
}
}
}
if ( errors > 0 ) {
throw new GradleException( "Code rules were violated ($errors problems)" )
}
}
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Lifecycle
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tasks.named( "check" ) {
dependsOn enforceRulesTask
dependsOn tasks.named( "spotlessCheck" )
}

tasks.withType( JavaCompile ).configureEach {javaCompile->
dependsOn tasks.named( "spotlessApply" )
}

119 changes: 0 additions & 119 deletions buildSrc/src/main/groovy/java-module.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
plugins {
id "base-information"
id "java-library"

id "com.diffplug.spotless"
id "jacoco"
}

dependencies {
Expand All @@ -14,13 +11,6 @@ dependencies {
annotationProcessor libs.loggingProcessor
annotationProcessor libs.logging
annotationProcessor libs.loggingAnnotations

testImplementation jakartaLibs.jpa
testImplementation testLibs.junit5Api
testImplementation testLibs.assertjCore

testRuntimeOnly testLibs.junit5Engine
testRuntimeOnly testLibs.log4j
}


Expand All @@ -31,13 +21,6 @@ dependencies {
java {
sourceCompatibility = jdks.versions.baseline.get() as int
targetCompatibility = jdks.versions.baseline.get() as int

withJavadocJar()
withSourcesJar()
}

test {
useJUnitPlatform()
}

// create a single "compile" task
Expand All @@ -49,8 +32,6 @@ tasks.register( "compile" ).configure {
tasks.withType( JavaCompile ).configureEach {javaCompile->
options.encoding = "UTF-8"
options.warnings false

dependsOn tasks.named( "spotlessApply" )
}

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

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Javadoc
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tasks.named( "javadoc", Javadoc ) {
options {
use = true
encoding = "UTF-8"

addStringOption( "Xdoclint:none", "-quiet" )

tags(
"todo:X",
"apiNote:a:API Note:",
"implSpec:a:Implementation Specification:",
"implNote:a:Implementation Note:"
)
}
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Spotless
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

spotless {
//Don't fail during the check: rather than enforcing guidelines, we use this plugin to fix mistakes automatically.
enforceCheck false
java {
licenseHeaderFile rootProject.file( 'config/spotless/license.java' )
removeUnusedImports()
indentWithTabs( 4 )
trimTrailingWhitespace()
endWithNewline()
}
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Enforced rules
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

def enforceRulesTask = tasks.register( "enforceRules" ) {
description "Enforces some formatting rules to src/main/java files"
doLast {
def illegalImport = ~/^import (sun|java.awt|org.slf4j)/
def missingNewline = ~/^\s*}\s*(else|catch|finally)/
def lowerEll = ~/\b\d+l\b/
def errors = 0
def tree = fileTree( "src/main/java/" )
tree.include "**/*.java"
tree.each { file ->
def lineNum = 0
def shortName = file.path.substring( rootDir.path.length() )
file.eachLine { line ->
lineNum++
if ( line =~ illegalImport ) {
errors++
logger.error( "Illegal import in ${shortName}\n${lineNum}: ${line}" )
}
if ( line =~ missingNewline ) {
errors++
logger.error( "Missing newline in ${shortName}\n${lineNum}: ${line}" )
}
if ( line =~ lowerEll ) {
errors++
logger.error( "Lowercase long literal in ${shortName}\n${lineNum}: ${line}" )
}
}
}
if ( errors > 0 ) {
throw new GradleException( "Code rules were violated ($errors problems)" )
}
}
}




// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// JaCoCo
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

def jacocoReportTask = tasks.named( "jacocoTestReport" ) {
dependsOn tasks.named( "test" )
}

jacocoTestReport {
reports {
xml.required = false
csv.required = false
html.outputLocation = layout.buildDirectory.dir( "jacocoHtml" )
}
}

tasks.named( "check" ) {
dependsOn enforceRulesTask
dependsOn tasks.named( "spotlessCheck" )
dependsOn jacocoReportTask
}
31 changes: 31 additions & 0 deletions buildSrc/src/main/groovy/published-java-module.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
plugins {
id "java-module"
id "testing"
id "code-quality"

id "maven-publish"
id "publishing-config"
id "signing-config"
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Java handling
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

java {
withJavadocJar()
withSourcesJar()
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Javadoc
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tasks.named( "javadoc", Javadoc ) {
options {
use = true
encoding = "UTF-8"

addStringOption( "Xdoclint:none", "-quiet" )

tags(
"todo:X",
"apiNote:a:API Note:",
"implSpec:a:Implementation Specification:",
"implNote:a:Implementation Note:"
)
}
}
45 changes: 45 additions & 0 deletions buildSrc/src/main/groovy/shared-testing.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Sets up shared testing
// to execute tests from hibernate-models in the context of other modules.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

plugins {
id "testing"
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Wire in the shared-tests
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// link the
configurations {
sharedTestClasses {
canBeConsumed = false
canBeResolved = true
}
sharedTestResources {
canBeConsumed = false
canBeResolved = true
}
sharedTestRuntimeClasspath {
canBeConsumed = false
canBeResolved = true
extendsFrom testRuntimeClasspath
}
}

dependencies {
testImplementation project( ":hibernate-models-testing" )

sharedTestClasses project(path: ':hibernate-models', configuration: 'exposedTestClasses')
sharedTestResources project(path: ':hibernate-models', configuration: 'exposedTestResources')
sharedTestRuntimeClasspath project(path: ':hibernate-models', configuration: 'exposedTestRuntimeClasspath')
}

tasks.named( "test", Test ) {
// use the configurations defined above, which depends on the configurations in `:architecture-tests`
testClassesDirs += configurations.sharedTestClasses

classpath += configurations.sharedTestResources
classpath += configurations.sharedTestRuntimeClasspath
}
44 changes: 44 additions & 0 deletions buildSrc/src/main/groovy/testing.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Module that need testing
// - automatically applied by published-java-module
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

plugins {
id "java-module"
id "jacoco"
}

dependencies {
testImplementation jakartaLibs.jpa
testImplementation testLibs.junit5Api
testImplementation testLibs.assertjCore

testImplementation testLibs.junit5Engine
testImplementation testLibs.log4j
}

test {
useJUnitPlatform()
}



// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// JaCoCo
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

def jacocoReportTask = tasks.named( "jacocoTestReport" ) {
dependsOn tasks.named( "test" )
}

jacocoTestReport {
reports {
xml.required = false
csv.required = false
html.outputLocation = layout.buildDirectory.dir( "jacocoHtml" )
}
}

tasks.named( "check" ) {
dependsOn jacocoReportTask
}
3 changes: 1 addition & 2 deletions hibernate-models-jandex/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id "published-java-module"
id "shared-testing"
}

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

implementation libs.jandex

testImplementation project( ":hibernate-models-testing" )
}
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public static <V> JandexValueExtractor<V> buildValueHandlersReturnExtractor(
if ( isDouble( valueTypeDescriptor ) ) {
converterCollector.accept( valueTypeDescriptor, (JandexValueConverter<V>) DoubleValueConverter.JANDEX_DOUBLE_VALUE_WRAPPER );
extractorCollector.accept( valueTypeDescriptor, (JandexValueExtractor<V>) DoubleValueExtractor.JANDEX_DOUBLE_EXTRACTOR );
return (JandexValueExtractor<V>) DoubleValueConverter.JANDEX_DOUBLE_VALUE_WRAPPER;
return (JandexValueExtractor<V>) DoubleValueExtractor.JANDEX_DOUBLE_EXTRACTOR;
}

if ( isFloat( valueTypeDescriptor ) ) {
Expand Down
Loading