diff --git a/build.gradle.kts b/build.gradle.kts index 67da0da..ade87cd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -61,7 +61,7 @@ configurations["functionalTestImplementation"].extendsFrom(configurations["testI configurations["functionalTestRuntimeOnly"].extendsFrom(configurations["testRuntimeOnly"]) // Add a task to run the functional tests -val functionalTest by tasks.registering(Test::class) { +tasks.register("functionalTest") { testClassesDirs = functionalTestSourceSet.output.classesDirs classpath = functionalTestSourceSet.runtimeClasspath useJUnitPlatform() @@ -88,7 +88,7 @@ tasks.named("compileKotlin") { tasks.named("check") { // Run the functional tests as part of `check` - dependsOn(functionalTest) + dependsOn("functionalTest") } tasks.named("test") { @@ -97,7 +97,7 @@ tasks.named("test") { } tasks.jacocoTestReport { - dependsOn(functionalTest) + dependsOn("functionalTest") // Aggregate all execution data into a single XML report. executionData(fileTree(project.layout.buildDirectory).include("/jacoco/*.exec")) reports { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index f8e1ee3..b1b8ef5 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 23449a2..a9db115 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,9 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip networkTimeout=10000 +retries=0 +retryBackOffMs=500 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index adff685..249efbb 100755 --- a/gradlew +++ b/gradlew @@ -20,7 +20,7 @@ ############################################################################## # -# Gradle start up script for POSIX generated by Gradle. +# gradlew start up script for POSIX generated by Gradle. # # Important for running: # @@ -29,7 +29,7 @@ # bash, then to run this script, type that shell name before the whole # command line, like: # -# ksh Gradle +# ksh gradlew # # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: @@ -57,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/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/. diff --git a/gradlew.bat b/gradlew.bat index c4bdd3a..a51ec4f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -19,12 +19,12 @@ @if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem -@rem Gradle startup script for Windows +@rem gradlew startup script for Windows @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -51,7 +51,7 @@ 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 +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -65,29 +65,18 @@ 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 +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* +@rem Execute gradlew +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:end -@rem End local scope for the variables with windows NT shell -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! -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 - -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/src/functionalTest/kotlin/git/semver/plugin/gradle/GitSemverPluginFunctionalTest.kt b/src/functionalTest/kotlin/git/semver/plugin/gradle/GitSemverPluginFunctionalTest.kt index 0313f9f..1c75e3e 100644 --- a/src/functionalTest/kotlin/git/semver/plugin/gradle/GitSemverPluginFunctionalTest.kt +++ b/src/functionalTest/kotlin/git/semver/plugin/gradle/GitSemverPluginFunctionalTest.kt @@ -93,12 +93,12 @@ class GitSemverPluginFunctionalTest { fun `can run print task`(printTask: String, pattern: String) { val projectDir = setupTestProject() - val result = run(projectDir, null, printTask, "--configuration-cache", "-q") + val result = run(projectDir, null, printTask, "--configuration-cache", "-q") assertThat(result.output).containsPattern(pattern) - //Run it again to make sure configuration cache don't break it - val result2 = run(projectDir, null, printTask, "--configuration-cache", "-q") + // Run it again to make sure the configuration cache does not break it. + val result2 = run(projectDir, null, printTask, "--configuration-cache", "-q", "--rerun") assertThat(result2.output).containsPattern(pattern) } diff --git a/src/main/kotlin/git/semver/plugin/gradle/PrintTask.kt b/src/main/kotlin/git/semver/plugin/gradle/PrintTask.kt index f51ff94..2a19161 100644 --- a/src/main/kotlin/git/semver/plugin/gradle/PrintTask.kt +++ b/src/main/kotlin/git/semver/plugin/gradle/PrintTask.kt @@ -1,17 +1,26 @@ package git.semver.plugin.gradle import org.gradle.api.DefaultTask +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.tasks.CacheableTask +import org.gradle.api.tasks.Optional +import org.gradle.api.tasks.OutputFile import org.gradle.api.tasks.TaskAction import org.gradle.api.tasks.options.Option import org.slf4j.LoggerFactory +import java.io.File import java.nio.charset.StandardCharsets import java.nio.file.Paths import javax.inject.Inject import kotlin.io.path.createDirectories import kotlin.io.path.writeText -open class PrintTask @Inject constructor(private val printout: () -> Any, desc: String, reason: String) : DefaultTask() { - private var file:String? = null +@CacheableTask +abstract class PrintTask @Inject constructor(private val printout: () -> Any, desc: String, reason: String) : DefaultTask() { + @get:OutputFile + @get:Optional + val file: RegularFileProperty = project.objects.fileProperty() + private val logger = LoggerFactory.getLogger(PrintTask::class.java) init { @@ -24,16 +33,14 @@ open class PrintTask @Inject constructor(private val printout: () -> Any, desc: @Option(option = "file", description = "Print to a file ") fun setFile(file: String) { - this.file = file + this.file.set(File(file).absoluteFile) } @TaskAction fun print() { - val fileName = this.file - if (fileName != null) { - writeFile(fileName) - } - else { + if (file.isPresent) { + writeFile(file.get().asFile.absolutePath) + } else { println(printout()) } } diff --git a/src/main/kotlin/git/semver/plugin/gradle/ReleaseTask.kt b/src/main/kotlin/git/semver/plugin/gradle/ReleaseTask.kt index 5b9ad05..08414c5 100644 --- a/src/main/kotlin/git/semver/plugin/gradle/ReleaseTask.kt +++ b/src/main/kotlin/git/semver/plugin/gradle/ReleaseTask.kt @@ -2,12 +2,13 @@ package git.semver.plugin.gradle import git.semver.plugin.scm.GitProvider import org.gradle.api.DefaultTask +import org.gradle.api.tasks.CacheableTask import org.gradle.api.tasks.Internal import org.gradle.api.tasks.TaskAction import org.gradle.api.tasks.options.Option import javax.inject.Inject - +@CacheableTask open class ReleaseTask @Inject constructor(private val settings: GitSemverPluginExtension) : DefaultTask() { private var preRelease: String? = null private var message: String? = null