Skip to content

Commit

Permalink
Rework plugin (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcrawford-figure authored Jan 27, 2023
1 parent a8534d4 commit 8687e07
Show file tree
Hide file tree
Showing 37 changed files with 1,349 additions and 892 deletions.
11 changes: 8 additions & 3 deletions build-logic/build-conventions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ plugins {
}

repositories {
gradlePluginPortal() // so that external plugins can be resolved in dependencies section
gradlePluginPortal()
}

dependencies {
// note: this `libs` is from build-logic/settings.gradle.kts, technically different from the 'main' project
implementation(libs.gradle.plugin.publish)
listOf(
libs.gradle.plugin.publish,
libs.ktlint,
libs.detekt,
).forEach {
implementation(it)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import org.jlleitschuh.gradle.ktlint.KtlintExtension

plugins {
id("io.gitlab.arturbosch.detekt")
id("org.jlleitschuh.gradle.ktlint")
}

configure<DetektExtension> {
buildUponDefaultConfig = true
allRules = false
config = files("${rootDir.path}/detekt.yml")
source = files("**/kotlin/**")
}

tasks.withType<Detekt>().configureEach {
reports {
html.required.set(true)
xml.required.set(false)
txt.required.set(false)
sarif.required.set(false)
}
}

configure<KtlintExtension> {
debug.set(false)
verbose.set(true)
android.set(false)
outputToConsole.set(true)
ignoreFailures.set(false)
enableExperimentalRules.set(false)
filter {
exclude("**/generated/**")
include("**/kotlin/**")
}
}
45 changes: 27 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import java.util.Calendar
import org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION as KOTLIN_VERSION

Expand All @@ -7,12 +9,13 @@ plugins {
alias(libs.plugins.github.release)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.semver)
alias(libs.plugins.dependency.analysis)

id("local.figure.publishing") // maven and gradle publishing info - build-logic/publishing
id("local.analysis-conventions")

// https://github.com/CadixDev/licenser
id("org.cadixdev.licenser") version "0.6.1"

}

semver {
Expand All @@ -38,19 +41,23 @@ repositories {
}

dependencies {
api(gradleApi())
api(gradleKotlinDsl())
api(kotlin("stdlib-jdk8"))
api(libs.swiftzer.semver)

implementation(libs.arrow.core)
implementation(libs.eclipse.jgit.eclipseJgit)
listOf(
gradleApi(),
gradleKotlinDsl(),
libs.eclipse.jgit.eclipseJgit,
).forEach {
implementation(it)
}

runtimeOnly(libs.eclipse.jgit.ssh.apache)
// Leak semver library users of this plugin so that they can implement their own versionModifier strategy
api(libs.swiftzer.semver)

// tests
testImplementation(gradleTestKit())
testImplementation(libs.bundles.kotest)
listOf(
gradleTestKit(),
libs.bundles.kotest
).forEach {
testImplementation(it)
}
}

// Enforce Kotlin version coherence
Expand All @@ -70,16 +77,14 @@ kotlin {
freeCompilerArgs =
freeCompilerArgs + listOf("-version", "-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn")
jvmTarget = "11"
languageVersion = "1.7"
apiVersion = "1.7"
languageVersion = "1.8"
apiVersion = "1.8"
verbose = true
}
}
}
}



java {
withSourcesJar()
withJavadocJar()
Expand All @@ -96,8 +101,8 @@ tasks.withType<Test>().configureEach {
showStandardStreams = true
showCauses = true
showStackTraces = true
events(*org.gradle.api.tasks.testing.logging.TestLogEvent.values())
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
events(*TestLogEvent.values())
exceptionFormat = TestExceptionFormat.FULL
}
}

Expand Down Expand Up @@ -142,3 +147,7 @@ license {
tasks.named("assemble") {
dependsOn("updateLicenses")
}

tasks.wrapper {
distributionType = Wrapper.DistributionType.ALL
}
12 changes: 12 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
style:
ReturnCount:
active: false
MagicNumber:
active: false
ForbiddenComment:
active: false
ThrowsCount:
active: true
excludeGuardClauses: true
MaxLineLength:
excludeCommentStatements: true
45 changes: 26 additions & 19 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
[versions]
kotlin = "1.7.10"

arrow = "1.1.3"
jgit = "6.3.0.202209071007-r"
kotlin = "1.8.0"

# Library versions
detekt = "1.22.0"
gradle-plugin-publish = "1.1.0"
jgit = "6.4.0.202211300538-r"
kotest = "5.5.4"
kotest-extensions-arrow = "1.2.5"
logback-classic = "1.4.4"
ktlint-gradle = "11.0.0"
swiftzer-semver = "1.2.0"

gradle-plugin-publish = "1.1.0"
github-release = "2.4.+"
gradle-semver-plugin = "0.6.+"
# Plugin versions
dependency-analysis = "1.18.0"
github-release = "2.4.1"
gradle-semver-plugin = "0.9.1"

[libraries]
arrow-core = { module = "io.arrow-kt:arrow-core", version.ref = "arrow" }
eclipse-jgit-eclipseJgit = { module = "org.eclipse.jgit:org.eclipse.jgit", version.ref = "jgit" }
eclipse-jgit-ssh-apache = { module = "org.eclipse.jgit:org.eclipse.jgit.ssh.apache", version.ref = "jgit" }

kotest-junit5-jvm = { module = "io.kotest:kotest-runner-junit5-jvm", version.ref = "kotest" }
kotest-framework-datatest = { module = "io.kotest:kotest-framework-datatest", version.ref = "kotest" }
kotest-assertions-core-jvm = { module = "io.kotest:kotest-assertions-core-jvm", version.ref = "kotest" }
kotest-assertions-arrow = { module = "io.kotest.extensions:kotest-assertions-arrow", version.ref = "kotest-extensions-arrow" }

# Libraries
eclipse-jgit-eclipseJgit = { module = "org.eclipse.jgit:org.eclipse.jgit", version.ref = "jgit" }
swiftzer-semver = { module = "net.swiftzer.semver:semver", version.ref = "swiftzer-semver" }
logbackClassic = { module = "ch.qos.logback:logback-classic", version.ref = "logback-classic" }

# this is the library version of the gradle-plugin-publish so that it can be given to our convention plugin
# Plugins needed as libraries
gradle-plugin-publish = { module = "com.gradle.plugin-publish:com.gradle.plugin-publish.gradle.plugin", version.ref = "gradle-plugin-publish" }
detekt = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
ktlint = { module = "org.jlleitschuh.gradle.ktlint:org.jlleitschuh.gradle.ktlint.gradle.plugin", version.ref = "ktlint-gradle" }

# Test Libraries
kotest-assertions-core-jvm = { module = "io.kotest:kotest-assertions-core-jvm", version.ref = "kotest" }
kotest-framework-datatest = { module = "io.kotest:kotest-framework-datatest", version.ref = "kotest" }
kotest-junit5-jvm = { module = "io.kotest:kotest-runner-junit5-jvm", version.ref = "kotest" }

[bundles]
kotest = [ "kotest-junit5-jvm", "kotest-assertions-core-jvm", "kotest-assertions-arrow", "kotest-framework-datatest" ]

kotest = ["kotest-junit5-jvm", "kotest-assertions-core-jvm", "kotest-framework-datatest"]

[plugins]

dependency-analysis = { id = "com.autonomousapps.dependency-analysis", version.ref = "dependency-analysis" }
github-release = { id = "com.github.breadmoirai.github-release", version.ref = "github-release" }
gradle-plugin-publish = { id = "com.gradle.plugin-publish", version.ref = "gradle-plugin-publish" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
semver = { id = "com.figure.gradle.semver-plugin", version.ref = "gradle-semver-plugin" }

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 6 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,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.
Expand Down
14 changes: 8 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +40,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.
Expand Down Expand Up @@ -75,13 +75,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
Expand Down
Loading

0 comments on commit 8687e07

Please sign in to comment.