diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 4b404b2..0000000 --- a/build.gradle +++ /dev/null @@ -1,53 +0,0 @@ -plugins { - id "com.github.ben-manes.versions" version "0.43.0" - - id "java" - id "java-gradle-plugin" - id 'com.adarshr.test-logger' version '3.2.0' - - id "com.gradle.plugin-publish" version "1.0.0" - id "maven-publish" // for local testing only - - id "idea" -} - -group 'me.qoomon' -version '6.3.7' -sourceCompatibility = JavaVersion.VERSION_11 -targetCompatibility = JavaVersion.VERSION_11 - -repositories { - mavenCentral() -} - -dependencies { - implementation 'org.eclipse.jgit:org.eclipse.jgit:6.3.0.202209071007-r' - implementation 'org.apache.maven:maven-artifact:3.8.6' - implementation 'org.apache.commons:commons-configuration2:2.8.0' - - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1' - testImplementation 'org.assertj:assertj-core:3.23.1' -} - -test { - useJUnitPlatform() -} - -gradlePlugin { - plugins { - gitVersioning { - id = 'me.qoomon.git-versioning' - displayName= 'Git Versioning Plugin' - description = 'This extension will adjust the project version, based on current git branch or tag.' - implementationClass = 'me.qoomon.gradle.gitversioning.GitVersioningPlugin' - } - } -} - - -pluginBundle { - website = 'https://github.com/qoomon/gradle-git-versioning-plugin' - vcsUrl = 'https://github.com/qoomon/gradle-git-versioning-plugin.git' - tags = ['git', 'versioning', 'version', 'commit', 'branch', 'tag', 'generated'] -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..4d188e0 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,66 @@ +plugins { + `kotlin-dsl` + + buildsrc.conventions.`kotlin-jvm` + buildsrc.conventions.publishing + buildsrc.conventions.`gradle-plugin` + + id("com.github.ben-manes.versions") version "0.43.0" + id("com.adarshr.test-logger") version "3.2.0" + + idea +} + +group = "me.qoomon" +version = "6.3.7" + +dependencies { + implementation("org.eclipse.jgit:org.eclipse.jgit:6.3.0.202209071007-r") + implementation("org.apache.maven:maven-artifact:3.8.6") + implementation("org.apache.commons:commons-configuration2:2.8.0") + + // test dependencies are declared in the test suites config +} + +gradlePlugin { + plugins.create("gitVersioning") { + id = "me.qoomon.git-versioning" + displayName = "Git Versioning Plugin" + description = "This extension will adjust the project version, based on current git branch or tag." + implementationClass = "me.qoomon.gradle.gitversioning.GitVersioningPlugin" + } +} + +@Suppress("UNUSED_VARIABLE", "UnstableApiUsage") // jvm test suites are incubating +testing.suites { + + // configure the existing unit-test suite + val test by getting(JvmTestSuite::class) { + dependencies { + implementation(project.dependencies.platform("org.junit:junit-bom:5.9.1")) + implementation("org.junit.jupiter:junit-jupiter-api") + implementation("org.junit.jupiter:junit-jupiter-engine") + + implementation("org.assertj:assertj-core:3.23.1") + } + } + + // configure the functional-test suite (created in buildSrc convention plugin) + val testFunctional by getting(JvmTestSuite::class) { + dependencies { + implementation(project) + implementation(project.dependencies.gradleTestKit()) + + implementation(project.dependencies.platform("org.junit:junit-bom:5.9.1")) + implementation("org.junit.jupiter:junit-jupiter-api") + implementation("org.junit.jupiter:junit-jupiter-engine") + } + } +} + +idea { + module { + isDownloadSources = true + isDownloadJavadoc = false + } +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..4add48a --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,32 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + `kotlin-dsl` + kotlin("jvm") version embeddedKotlinVersion +} + +dependencies { + implementation(platform(kotlin("bom", embeddedKotlinVersion))) + + // define the Maven GAV coordinates of Gradle plugins that are used in the buildSrc convention plugins + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$embeddedKotlinVersion") + implementation("com.gradle.publish:plugin-publish-plugin:1.0.0") +} + +val projectJvmTarget = "11" + +kotlin { + jvmToolchain { + (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(projectJvmTarget)) + } +} + +kotlinDslPluginOptions { + jvmTarget.set(projectJvmTarget) +} + +tasks.withType().configureEach { + kotlinOptions { + jvmTarget = projectJvmTarget + } +} diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 0000000..2d39312 --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1,16 @@ +rootProject.name = "buildSrc" + +@Suppress("UnstableApiUsage") // Central declaration of repositories is an incubating feature +dependencyResolutionManagement { + repositories { + mavenCentral() + gradlePluginPortal() + } + + pluginManagement { + repositories { + gradlePluginPortal() + mavenCentral() + } + } +} diff --git a/buildSrc/src/main/kotlin/buildsrc/conventions/gradle-plugin.gradle.kts b/buildSrc/src/main/kotlin/buildsrc/conventions/gradle-plugin.gradle.kts new file mode 100644 index 0000000..6c05357 --- /dev/null +++ b/buildSrc/src/main/kotlin/buildsrc/conventions/gradle-plugin.gradle.kts @@ -0,0 +1,44 @@ +package buildsrc.conventions + +import org.gradle.kotlin.dsl.* + +/* Gradle plugin configuration */ + +plugins { + `java-gradle-plugin` + `jvm-test-suite` +} + +@Suppress("UnstableApiUsage") // jvm test suites are incubating +testing.suites { + + // configure all test suites + withType().configureEach { + useJUnitJupiter() + } + + // get the existing unit-test suite + val test by getting(JvmTestSuite::class) + + // register a new functional-test suite + val testFunctional by registering(JvmTestSuite::class) { + + // functional tests should run after unit tests + targets.configureEach { + testTask.configure { shouldRunAfter(test) } + } + + sources { + java { + resources { + // fix issue with missing Gradle property file + srcDir(tasks.pluginUnderTestMetadata.map { it.outputDirectory }) + } + } + } + + gradlePlugin.testSourceSet(sources) + } + + tasks.check { dependsOn(testFunctional) } +} diff --git a/buildSrc/src/main/kotlin/buildsrc/conventions/kotlin-jvm.gradle.kts b/buildSrc/src/main/kotlin/buildsrc/conventions/kotlin-jvm.gradle.kts new file mode 100644 index 0000000..fcd289f --- /dev/null +++ b/buildSrc/src/main/kotlin/buildsrc/conventions/kotlin-jvm.gradle.kts @@ -0,0 +1,23 @@ +package buildsrc.conventions + +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +/* Kotlin JVM configuration */ + +plugins { + kotlin("jvm") +} + +val projectJvmTarget = "11" + +kotlin { + jvmToolchain { + (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(projectJvmTarget)) + } +} + +tasks.withType().configureEach { + kotlinOptions { + jvmTarget = projectJvmTarget + } +} diff --git a/buildSrc/src/main/kotlin/buildsrc/conventions/publishing.gradle.kts b/buildSrc/src/main/kotlin/buildsrc/conventions/publishing.gradle.kts new file mode 100644 index 0000000..8851d42 --- /dev/null +++ b/buildSrc/src/main/kotlin/buildsrc/conventions/publishing.gradle.kts @@ -0,0 +1,24 @@ +package buildsrc.conventions + +/* Publishing configuration */ + +plugins { + id("com.gradle.plugin-publish") + `maven-publish` // for local testing only +} + +pluginBundle { + website = "https://github.com/qoomon/gradle-git-versioning-plugin" + vcsUrl = "https://github.com/qoomon/gradle-git-versioning-plugin.git" + tags = listOf("git", "versioning", "version", "commit", "branch", "tag", "generated") +} + +publishing { + repositories { + // publish to a project-local directory, for testing. + // ./gradlew publishAllPublicationsToProjectLocalRepository + maven(rootProject.layout.buildDirectory.dir("maven-project-local")) { + name = "ProjectLocal" + } + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..6e2e651 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,8 @@ +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 + +org.gradle.caching=true +# https://github.com/gradle/gradle/issues/20416 +systemProp.org.gradle.kotlin.dsl.precompiled.accessors.strict=true + +org.gradle.unsafe.configuration-cache=true +org.gradle.unsafe.configuration-cache-problems=warn diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..943f0cb 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 2e6e589..f398c33 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..65dcd68 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,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/subprojects/plugins/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,10 +80,10 @@ 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##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # 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"' @@ -143,12 +143,16 @@ fi 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=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=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -205,6 +209,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# 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..93e3f59 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,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,7 +41,7 @@ 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. @@ -75,13 +76,15 @@ set CLASSPATH=%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/settings.gradle b/settings.gradle deleted file mode 100644 index 2f75c38..0000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'gradle-git-versioning-plugin' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..48c0f98 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,17 @@ +rootProject.name = "gradle-git-versioning-plugin" + +enableFeaturePreview("STABLE_CONFIGURATION_CACHE") // https://docs.gradle.org/7.5.1/userguide/configuration_cache.html#config_cache:stable + +@Suppress("UnstableApiUsage") // Central declaration of repositories is an incubating feature +dependencyResolutionManagement { + repositories { + mavenCentral() + } + + pluginManagement { + repositories { + gradlePluginPortal() + mavenCentral() + } + } +}