Skip to content

v3.0.0 #52

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

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 12 additions & 7 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
java-version: [ 21, 24 ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v2
- name: Set up JDK ${{ matrix.java-version }} on ${{ matrix.os }}
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
java-version: ${{ matrix.java-version }}
distribution: 'zulu'
cache: 'gradle'
- name: Build with Gradle
run: ./gradlew build
run: ./gradlew build --stacktrace --info
221 changes: 117 additions & 104 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,32 @@
* Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
*/

import org.apache.tools.ant.filters.ReplaceTokens

/**
* @author <a href="mailto:franz.wilhelmstoetter@gmail.com">Franz Wilhelmstötter</a>
* @since 1.0
* @version 1.2
* @since 1.2
* @version 3.0
*/

plugins {
alias(libs.plugins.jmh)
base
alias(libs.plugins.version.catalog.update)
alias(libs.plugins.jmh)
}

rootProject.version = FacileJDBC.VERSION
rootProject.version = providers.gradleProperty("facilejdbc.version").get()

tasks.named<Wrapper>("wrapper") {
version = "8.14.3"
gradleVersion = "8.14"
distributionType = Wrapper.DistributionType.ALL
}

/**
* Project configuration *before* the projects has been evaluated.
* Project configuration *before* the projects have been evaluated.
*/
allprojects {
group = FacileJDBC.GROUP
version = FacileJDBC.VERSION
version = rootProject.version

repositories {
flatDir {
Expand All @@ -53,41 +54,63 @@ allprojects {
}

configurations.all {
resolutionStrategy.failOnVersionConflict()
resolutionStrategy.preferProjectModules()
}
}

/**
* Project configuration *after* the projects has been evaluated.
*/
gradle.projectsEvaluated {
subprojects {
val project = this
subprojects {
val project = this

tasks.withType<JavaCompile> {
options.compilerArgs.add("-Xlint:" + xlint())
}
tasks.withType<Test> {
useTestNG()
}

plugins.withType<JavaPlugin> {
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
plugins.withType<JavaPlugin> {

configure<JavaPluginExtension> {
modularity.inferModulePath.set(true)
}
configure<JavaPluginExtension> {
modularity.inferModulePath = true

setupJava(project)
setupTestReporting(project)
setupJavadoc(project)
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

setupJava(project)
setupTestReporting(project)
}

tasks.withType<JavaCompile> {
modularity.inferModulePath = true

options.compilerArgs.add("-Xlint:${xlint()}")
}

}

gradle.projectsEvaluated {
subprojects {
if (plugins.hasPlugin("maven-publish")) {
setupPublishing(project)
}
}

// Enforcing the library version defined in the version catalogs.
val catalogs = extensions.getByType<VersionCatalogsExtension>()
val libraries = catalogs.catalogNames
.map { catalogs.named(it) }
.flatMap { catalog -> catalog.libraryAliases.map { alias -> Pair(catalog, alias) } }
.map { it.first.findLibrary(it.second).get().get() }
.filter { it.version != null }
.map { it.toString() }
.toTypedArray()

configurations.all {
resolutionStrategy.preferProjectModules()
resolutionStrategy.force(*libraries)
}
}
}

/**
Expand All @@ -96,11 +119,11 @@ gradle.projectsEvaluated {
fun setupJava(project: Project) {
val attr = mutableMapOf(
"Implementation-Title" to project.name,
"Implementation-Version" to FacileJDBC.VERSION,
"Implementation-Version" to project.version,
"Implementation-URL" to FacileJDBC.URL,
"Implementation-Vendor" to FacileJDBC.NAME,
"ProjectName" to FacileJDBC.NAME,
"Version" to FacileJDBC.VERSION,
"Version" to project.version,
"Maintainer" to FacileJDBC.AUTHOR,
"Project" to project.name,
"Project-Version" to project.version,
Expand All @@ -122,6 +145,31 @@ fun setupJava(project: Project) {
attributes(attr)
}
}

project.tasks.withType<Javadoc> {
val doclet = options as StandardJavadocDocletOptions
doclet.addBooleanOption("Xdoclint:accessibility,html,reference,syntax", true)
doclet.addStringOption("-show-module-contents", "api")
doclet.addStringOption("-show-packages", "exported")
doclet.version(true)
doclet.docEncoding = "UTF-8"
doclet.charSet = "UTF-8"
doclet.linkSource(true)
doclet.linksOffline(
"https://docs.oracle.com/en/java/javase/21/docs/api/",
"${project.rootDir}/buildSrc/resources/javadoc/java.se"
)
doclet.windowTitle = "Jenetics ${project.version}"
doclet.docTitle = "<h1>Jenetics ${project.version}</h1>"
doclet.bottom = "&copy; ${Env.COPYRIGHT_YEAR} Franz Wilhelmst&ouml;tter &nbsp;<i>(${Env.BUILD_DATE})</i>"

doclet.addStringOption("docfilessubdirs")
doclet.tags = listOf(
"apiNote:a:API Note:",
"implSpec:a:Implementation Requirements:",
"implNote:a:Implementation Note:"
)
}
}

/**
Expand All @@ -131,7 +179,7 @@ fun setupTestReporting(project: Project) {
project.apply(plugin = "jacoco")

project.configure<JacocoPluginExtension> {
toolVersion = "0.8.11"
toolVersion = libs.jacoco.agent.get().version.toString()
}

project.tasks {
Expand All @@ -146,96 +194,46 @@ fun setupTestReporting(project: Project) {
}

named<Test>("test") {
useTestNG()
finalizedBy("jacocoTestReport")
}
}
}

/**
* Setup of the projects Javadoc.
*/
fun setupJavadoc(project: Project) {
project.tasks.withType<Javadoc> {
val doclet = options as StandardJavadocDocletOptions
doclet.addBooleanOption("Xdoclint:accessibility,html,reference,syntax", true)

exclude("**/internal/**")

doclet.memberLevel = JavadocMemberLevel.PROTECTED
doclet.version(true)
doclet.docEncoding = "UTF-8"
doclet.charSet = "UTF-8"
doclet.linkSource(true)
doclet.linksOffline(
"https://docs.oracle.com/en/java/javase/17/docs/api/",
"${project.rootDir}/buildSrc/resources/javadoc/java.se"
)
doclet.windowTitle = "FacileJDBC ${project.version}"
doclet.docTitle = "<h1>FacileJDBC ${project.version}</h1>"
doclet.bottom = "&copy; ${Env.COPYRIGHT_YEAR} Franz Wilhelmst&ouml;tter &nbsp;<i>(${Env.BUILD_DATE})</i>"
doclet.stylesheetFile = project.file("${project.rootDir}/buildSrc/resources/javadoc/stylesheet.css")

doclet.tags = listOf(
"apiNote:a:API Note:",
"implSpec:a:Implementation Requirements:",
"implNote:a:Implementation Note:"
fun snippetPaths(project: Project): String? {
return File("${project.projectDir}/src/main/java").walk()
.filter { file -> file.isDirectory && file.endsWith("snippet-files") }
.joinToString(
transform = { file -> file.absolutePath },
separator = File.pathSeparator
)

doLast {
project.copy {
from("src/main/java") {
include("io/**/doc-files/*.*")
}
includeEmptyDirs = false
into(destinationDir!!)
}
}
}

val javadoc = project.tasks.findByName("javadoc") as Javadoc?
if (javadoc != null) {
project.tasks.register<io.jenetics.gradle.ColorizerTask>("colorizer") {
directory = javadoc.destinationDir!!
}

javadoc.doLast {
val colorizer = project.tasks.findByName("colorizer")
colorizer?.actions?.forEach {
it.execute(colorizer)
}
}
}
.ifEmpty { null }
}

/**
* The Java compiler XLint flags.
*/
fun xlint(): String {
// See https://docs.oracle.com/javase/9/tools/javac.htm#JSWOR627
// See https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html
return listOf(
"auxiliaryclass",
"cast",
"auxiliaryclass",
"classfile",
"dep-ann",
"deprecation",
"divzero",
"empty",
"exports",
"finally",
"module",
"opens",
"overrides",
"rawtypes",
"removal",
"serial",
// "serial" -- Creates unnecessary warnings.,
"static",
"try",
"unchecked"
).joinToString(separator = ",")
}

val identifier = "${FacileJDBC.ID}-${FacileJDBC.VERSION}"
val identifier = "${FacileJDBC.ID}-${providers.gradleProperty("facilejdbc.version").get()}"

/**
* Setup of the Maven publishing.
Expand All @@ -248,26 +246,29 @@ fun setupPublishing(project: Project) {

project.tasks.named<Jar>("sourcesJar") {
filter(
org.apache.tools.ant.filters.ReplaceTokens::class, "tokens" to mapOf(
"__identifier__" to identifier,
"__year__" to Env.COPYRIGHT_YEAR
)
ReplaceTokens::class, "tokens" to mapOf(
"__identifier__" to identifier,
"__year__" to Env.COPYRIGHT_YEAR
)
)
}

project.tasks.named<Jar>("javadocJar") {
filter(
org.apache.tools.ant.filters.ReplaceTokens::class, "tokens" to mapOf(
"__identifier__" to identifier,
"__year__" to Env.COPYRIGHT_YEAR
)
ReplaceTokens::class, "tokens" to mapOf(
"__identifier__" to identifier,
"__year__" to Env.COPYRIGHT_YEAR
)
)
}

project.configure<PublishingExtension> {
publications {
create<MavenPublication>("mavenJava") {
artifactId = FacileJDBC.ID
suppressPomMetadataWarningsFor("testFixturesApiElements")
suppressPomMetadataWarningsFor("testFixturesRuntimeElements")

artifactId = project.name
from(project.components["java"])
versionMapping {
usage("java-api") {
Expand Down Expand Up @@ -313,6 +314,19 @@ fun setupPublishing(project: Project) {
uri(layout.buildDirectory.dir("repos/releases"))
}
}

// Exclude test fixtures from publication, as we use them only internally
plugins.withId("org.gradle.java-test-fixtures") {
val component = components["java"] as AdhocComponentWithVariants
component.withVariantsFromConfiguration(configurations["testFixturesApiElements"]) { skip() }
component.withVariantsFromConfiguration(configurations["testFixturesRuntimeElements"]) { skip() }

// Workaround to not publish test fixtures sources added by com.vanniktech.maven.publish plugin
// TODO: Remove as soon as https://github.com/vanniktech/gradle-maven-publish-plugin/issues/779 closed
afterEvaluate {
component.withVariantsFromConfiguration(configurations["testFixturesSourcesElements"]) { skip() }
}
}
}

project.apply(plugin = "signing")
Expand All @@ -322,4 +336,3 @@ fun setupPublishing(project: Project) {
}

}

Loading
Loading