diff --git a/.agent/rules/build-tool.md b/.agent/rules/build-tool.md new file mode 100644 index 0000000..26368b3 --- /dev/null +++ b/.agent/rules/build-tool.md @@ -0,0 +1,8 @@ +--- +trigger: always_on +--- + +The build tool is gradle +to check if the project is compiling and running correctly use the ./gradlew check +github is used, +the repository is found at https://github.com/triplem/gradle-by-example/ \ No newline at end of file diff --git a/.agent/rules/common.md b/.agent/rules/common.md new file mode 100644 index 0000000..55528c8 --- /dev/null +++ b/.agent/rules/common.md @@ -0,0 +1,6 @@ +--- +trigger: always_on +--- + +store all communications and proposals into adoc files +store those files in a new directory 'antigravity' \ No newline at end of file diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 62f48f9..74a4bc2 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -2,6 +2,7 @@ name: CI Build on: push: + branches: [ main ] pull_request: branches: [ main ] @@ -23,7 +24,7 @@ jobs: java-version: '21' - name: Validate Gradle Wrapper - uses: gradle/actions/wrapper-validation@v3 + uses: gradle/actions/wrapper-validation@v5 - name: Setup Gradle and Compile uses: gradle/actions/setup-gradle@v3 @@ -43,7 +44,7 @@ jobs: distribution: 'temurin' java-version: '21' - name: Validate Gradle Wrapper - uses: gradle/actions/wrapper-validation@v3 + uses: gradle/actions/wrapper-validation@v5 - name: Validate Version Catalog uses: gradle/actions/setup-gradle@v3 with: diff --git a/build.gradle.kts b/build.gradle.kts index 7f5c235..1b9f344 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,13 +1,8 @@ plugins { - id("org.jetbrains.dokka") - - // due to late-binding not working, aggregation should define tasks doc-consumer id("org.javafreedom.aggregation-conventions") - id("org.javafreedom.verification.jacoco-consumer-conventions") id("org.javafreedom.verification.test-consumer-conventions") id("org.javafreedom.documentation.documentation-consumer-conventions") - id("org.javafreedom.verification.sonarqube-conventions") } @@ -15,22 +10,7 @@ allprojects { group = "org.javafreedom.gradle" } -repositories { - mavenCentral() -} - -// Configure Dokka V2 for multi-module documentation -dokka { - dokkaPublications.html { - outputDirectory.set(layout.buildDirectory.dir("dokka")) - } -} - dependencies { implementation(project(":app")) asciidoc(project(":documentation")) - - dokka(project(":app")) - dokka(project(":list")) - dokka(project(":utilities")) } diff --git a/buildSrc/src/main/kotlin/org.javafreedom.aggregation-conventions.gradle.kts b/buildSrc/src/main/kotlin/org.javafreedom.aggregation-conventions.gradle.kts index fedc84e..5863ec1 100644 --- a/buildSrc/src/main/kotlin/org.javafreedom.aggregation-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/org.javafreedom.aggregation-conventions.gradle.kts @@ -4,6 +4,7 @@ plugins { id("org.javafreedom.verification.jacoco-consumer-conventions") id("io.gitlab.arturbosch.detekt") id("org.sonarqube") + id("org.jetbrains.dokka") } // right now, there is no real aggregation of detekt, therefor we are just adding all @@ -58,3 +59,18 @@ subprojects { } } +// Configure Dokka V2 for multi-module documentation +dokka { + dokkaPublications.html { + outputDirectory.set(layout.buildDirectory.dir("dokka")) + } +} + +dependencies { + subprojects.forEach { subproject -> + if (subproject.name != "documentation") { + dokka(subproject) + } + } +} + diff --git a/buildSrc/src/main/kotlin/org.javafreedom.kotlin-common-conventions.gradle.kts b/buildSrc/src/main/kotlin/org.javafreedom.kotlin-common-conventions.gradle.kts index b55ed38..dd7ef5a 100644 --- a/buildSrc/src/main/kotlin/org.javafreedom.kotlin-common-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/org.javafreedom.kotlin-common-conventions.gradle.kts @@ -50,6 +50,7 @@ dependencies { // Add additional dependencies useful for development implementation(libs.findLibrary("kotlinLogging").get()) + implementation(libs.findLibrary("slf4jApi").get()) // Testing dependencies testImplementation(libs.findBundle("testing").get()) diff --git a/buildSrc/src/main/kotlin/org/javafreedom/documentation/documentation-consumer-conventions.gradle.kts b/buildSrc/src/main/kotlin/org/javafreedom/documentation/documentation-consumer-conventions.gradle.kts index d82a54b..dd08efe 100644 --- a/buildSrc/src/main/kotlin/org/javafreedom/documentation/documentation-consumer-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/org/javafreedom/documentation/documentation-consumer-conventions.gradle.kts @@ -13,7 +13,7 @@ val asciidoc by configurations.creating { } val dokkaGenerateTask = tasks.named("dokkaGenerate") -val testReportTask = tasks.named("testReport") +val testReportTask = tasks.named("testAggregateTestReport") val jacocoReportTask = tasks.named("aggregateJacocoTestReport") val detektReportTask = tasks.named("aggregateDetekt") val rootDetektTask = tasks.named("detekt") @@ -32,9 +32,11 @@ tasks.register("aggregateReports") { into("dokka") } - from(layout.buildDirectory.dir("reports/allTests")) { - into("tests") + from(layout.buildDirectory.dir("reports/tests/test/aggregated-results")) { + into("tests/unit") } + + from(layout.buildDirectory.dir("reports/jacoco/aggregateJacocoTestReport")) { into("jacoco") diff --git a/buildSrc/src/main/kotlin/org/javafreedom/verification/test-consumer-conventions.gradle.kts b/buildSrc/src/main/kotlin/org/javafreedom/verification/test-consumer-conventions.gradle.kts index 7ea2f0d..843684c 100644 --- a/buildSrc/src/main/kotlin/org/javafreedom/verification/test-consumer-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/org/javafreedom/verification/test-consumer-conventions.gradle.kts @@ -2,25 +2,17 @@ package org.javafreedom.verification plugins { kotlin("jvm") + id("test-report-aggregation") } -val testReportData by configurations.creating { - isCanBeResolved = true - isCanBeConsumed = false - extendsFrom(configurations.implementation.get()) - attributes { - attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION)) - attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named("test-report-data")) - } -} - -val testReportTask = tasks.register("testReport") { - destinationDirectory.set(layout.buildDirectory.dir("reports/allTests")) - // Use test results from testReportData configuration - (getTestResults() as ConfigurableFileCollection) - .from(testReportData.incoming.artifactView { lenient(true) }.files) +dependencies { + testReportAggregation(project(":app")) + testReportAggregation(project(":list")) + testReportAggregation(project(":utilities")) } -tasks.check { - dependsOn(testReportTask) +reporting { + reports { + val integrationTestAggregateTestReport by creating(org.gradle.api.tasks.testing.AggregateTestReport::class) + } } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/org/javafreedom/verification/test-producer-conventions.gradle.kts b/buildSrc/src/main/kotlin/org/javafreedom/verification/test-producer-conventions.gradle.kts index 69c2e53..a2f8432 100644 --- a/buildSrc/src/main/kotlin/org/javafreedom/verification/test-producer-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/org/javafreedom/verification/test-producer-conventions.gradle.kts @@ -24,17 +24,8 @@ testing { val integrationTest by registering(JvmTestSuite::class) { dependencies { implementation(project()) - // Inherit all test dependencies - implementation(platform(libs.findLibrary("kotlin-bom").get())) - implementation(libs.findLibrary("kotlin-stdlib").get()) - implementation(libs.findLibrary("kotlinLogging").get()) - implementation(libs.findLibrary("kotlin-test").get()) - implementation(libs.findLibrary("kotlin-test-junit5").get()) - implementation(libs.findLibrary("junitJupiterApi").get()) - implementation(libs.findLibrary("assertkJvm").get()) - runtimeOnly(libs.findLibrary("junitJupiterEngine").get()) } - + targets { all { testTask.configure { @@ -48,6 +39,14 @@ testing { } } +// Inherit dependencies from test suite +configurations.named("integrationTestImplementation") { + extendsFrom(configurations.getByName("testImplementation")) +} +configurations.named("integrationTestRuntimeOnly") { + extendsFrom(configurations.getByName("testRuntimeOnly")) +} + // Configure Kotlin compilation to allow internal visibility for integration tests afterEvaluate { kotlin.target.compilations.named("integrationTest") { @@ -61,26 +60,7 @@ tasks.check { // IDEA integration is handled automatically by test-suites plugin -// ----------------------------- -// Add configuration to allow aggregation of unit-test-reports -// ----------------------------- - -// Share the test report data to be aggregated for the whole project -configurations.create("binaryTestResultsElements") { - isVisible = false - isCanBeResolved = false - isCanBeConsumed = true - extendsFrom(configurations.implementation.get()) - attributes { - attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION)) - attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named("test-report-data")) - } - outgoing.artifact(tasks.test.map { task -> task.binaryResultsDirectory.get() }) - outgoing.artifact(tasks.named("integrationTest").map { task -> - (task as Test).binaryResultsDirectory.get() - }) -} tasks.withType().configureEach { useJUnitPlatform() diff --git a/gradle.properties b/gradle.properties index f104a16..f320eff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,10 @@ github_org=triplem + org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m org.gradle.caching=true org.gradle.configuration-cache=true org.gradle.configuration-cache.problems=warn org.gradle.parallel=true + org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 13c624f..5e5055c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,29 +1,29 @@ [versions] # Language versions -kotlin = "2.0.20" +kotlin = "2.3.0" java = "21" # Testing frameworks -junit = "5.11.0" +junit = "5.13.4" assertk = "0.28.1" # Documentation -dokka = "2.0.0" +dokka = "2.1.0" asciidoctor = "4.0.4" # Code quality and security -detekt = "1.23.7" -sonarqube = "5.1.0.4882" +detekt = "1.23.8" +sonarqube = "7.2.2.6593" # Logging -kotlin-logging = "3.0.5" -slf4j = "2.0.16" +kotlin-logging = "7.0.3" +slf4j = "2.0.17" # Utilities -commons-text = "1.12.0" +commons-text = "1.15.0" # Build and deployment -docker = "9.4.0" +docker = "10.0.0" [libraries] # Kotlin libraries @@ -47,7 +47,7 @@ junitJupiterEngine = { group = "org.junit.jupiter", name = "junit-jupiter-engine assertkJvm = { group = "com.willowtreeapps.assertk", name = "assertk-jvm", version.ref = "assertk" } # Logging libraries -kotlinLogging = { group = "io.github.microutils", name = "kotlin-logging", version.ref = "kotlin-logging" } +kotlinLogging = { group = "io.github.oshai", name = "kotlin-logging", version.ref = "kotlin-logging" } slf4jApi = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" } # Utility libraries diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 41d9927..1b33c55 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3ae1e2f..37f78a6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..23d15a9 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +82,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -114,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -133,22 +133,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,18 +200,28 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd3..db3a6ac 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,8 +13,10 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +27,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,32 +59,34 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/modules/list/src/test/kotlin/org/javafreedom/list/LinkedListTest.kt b/modules/list/src/test/kotlin/org/javafreedom/list/LinkedListTest.kt index 7c20210..525826b 100644 --- a/modules/list/src/test/kotlin/org/javafreedom/list/LinkedListTest.kt +++ b/modules/list/src/test/kotlin/org/javafreedom/list/LinkedListTest.kt @@ -7,7 +7,7 @@ import assertk.assertThat import assertk.assertions.isEqualTo import assertk.assertions.isFalse import assertk.assertions.isTrue -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import kotlin.test.Test private val logger = KotlinLogging.logger {} diff --git a/settings.gradle.kts b/settings.gradle.kts index 3e7f88d..18b9af4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -9,6 +9,12 @@ pluginManagement { } } +dependencyResolutionManagement { + repositories { + mavenCentral() + } +} + fun includeProject(dir: File) { include(dir.name) val prj = project(":${dir.name}")