Skip to content

Commit

Permalink
Migrate to version catalog and bump all dependency versions (#20)
Browse files Browse the repository at this point in the history
This also resolves issue #19 and bumps ktlint to the latest version
  • Loading branch information
tlusk committed Jan 23, 2024
1 parent 40c8fa8 commit 6a3f8ec
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 38 deletions.
6 changes: 1 addition & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ trim_trailing_whitespace = true
insert_final_newline = true

[*.{kt,kts}]
ktlint_experimental = enabled
ktlint_code_style = intellij_idea
ktlint_standard_filename = disabled
ktlint_standard_no-wildcard-imports = disabled
ktlint_standard_string-template = disabled

# Don't use property naming rules until they are stable
ktlint_experimental_property-naming = disabled
ktlint_standard_property-naming = disabled

ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
44 changes: 28 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.jetbrains.grammarkit.tasks.GenerateLexerTask
import org.jetbrains.grammarkit.tasks.GenerateParserTask
import org.jetbrains.intellij.tasks.RunIdeTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("com.diffplug.spotless") version "6.20.0"
id("io.gitlab.arturbosch.detekt") version "1.23.1"
id("org.gradle.test-retry") version "1.5.4"
id("org.jetbrains.grammarkit") version "2022.3.1"
id("org.jetbrains.intellij") version "1.15.0"
// See: https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library
kotlin("jvm") version "1.8.20"
alias(libs.plugins.com.diffplug.spotless)
alias(libs.plugins.com.github.ben.manes.versions)
alias(libs.plugins.io.gitlab.arturbosch.detekt)
alias(libs.plugins.nl.littlerobots.version.catalog.update)
alias(libs.plugins.org.gradle.test.retry)
alias(libs.plugins.org.jetbrains.grammarkit)
alias(libs.plugins.org.jetbrains.intellij)
alias(libs.plugins.org.jetbrains.kotlin.jvm)
java
}

spotless {
val ktlintVersion = "0.50.0"

kotlin {
ktlint(ktlintVersion)
.editorConfigOverride(mapOf("ktlint_experimentasl" to "enabled"))
ktlint(libs.versions.com.pinterest.ktlint.get())
}

kotlinGradle {
target("*.gradle.kts")
ktlint(ktlintVersion)
ktlint(libs.versions.com.pinterest.ktlint.get())
}
}

Expand All @@ -34,7 +33,7 @@ detekt {
}

group = "com.carbonblack"
version = "2.2.0"
version = "2.2.1"

tasks.compileJava {
options.release.set(17)
Expand Down Expand Up @@ -78,14 +77,14 @@ repositories {
}

dependencies {
testImplementation("io.mockk", "mockk", "1.13.5")
testImplementation("io.strikt", "strikt-core", "0.34.1")
testImplementation(libs.io.mockk.mockk)
testImplementation(libs.io.strikt.strikt.core)
}

// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
type.set("IC")
version.set("2023.2") // IntelliJ version and Kotlin version must match
version.set(libs.versions.com.jetbrains.ideaIC)
updateSinceUntilBuild.set(false)

plugins.set(listOf("com.jetbrains.sh")) // , "au.com.glassechidna.luanalysis:1.2.2-IDEA203"))
Expand Down Expand Up @@ -138,3 +137,16 @@ val generateGrammars: TaskProvider<Task> = tasks.register("generateGrammars") {
tasks.withType<KotlinCompile> {
dependsOn(generateGrammars)
}

tasks.withType<DependencyUpdatesTask> {
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}

rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
}
31 changes: 31 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[versions]
com-diffplug-spotless = "6.25.0"
com-github-ben-manes-versions = "0.51.0"
# @keep this version, it's used by the intellij plugin
com-jetbrains-ideaIC = "2023.3.2"
# @keep this version, it's used by the spotless plugin
com-pinterest-ktlint = "1.1.1"
io-gitlab-arturbosch-detekt = "1.23.4"
io-mockk = "1.13.9"
io-strikt-strikt-core = "0.34.1"
nl-littlerobots-version-catalog-update = "0.8.3"
org-gradle-test-retry = "1.5.8"
# @pin grammarkit 2022.3.2 introduces breaking changes with our use of idea-flex.skeleton
org-jetbrains-grammarkit = "2022.3.1"
org-jetbrains-intellij = "1.17.0"
# @pin kotlin to the same version shipped with intellij, See: https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library
org-jetbrains-kotlin-jvm = "1.9.10"

[libraries]
io-mockk-mockk = { module = "io.mockk:mockk", version.ref = "io-mockk" }
io-strikt-strikt-core = { module = "io.strikt:strikt-core", version.ref = "io-strikt-strikt-core" }

[plugins]
com-diffplug-spotless = { id = "com.diffplug.spotless", version.ref = "com-diffplug-spotless" }
com-github-ben-manes-versions = { id = "com.github.ben-manes.versions", version.ref = "com-github-ben-manes-versions" }
io-gitlab-arturbosch-detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "io-gitlab-arturbosch-detekt" }
nl-littlerobots-version-catalog-update = { id = "nl.littlerobots.version-catalog-update", version.ref = "nl-littlerobots-version-catalog-update" }
org-gradle-test-retry = { id = "org.gradle.test-retry", version.ref = "org-gradle-test-retry" }
org-jetbrains-grammarkit = { id = "org.jetbrains.grammarkit", version.ref = "org-jetbrains-grammarkit" }
org-jetbrains-intellij = { id = "org.jetbrains.intellij", version.ref = "org-jetbrains-intellij" }
org-jetbrains-kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "org-jetbrains-kotlin-jvm" }
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,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
17 changes: 9 additions & 8 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -144,15 +145,15 @@ 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
# 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=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -201,11 +202,11 @@ fi
# 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 $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.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_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" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import com.intellij.psi.PsiManager
import com.intellij.psi.search.FileTypeIndex
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.util.io.isDirectory
import com.intellij.util.io.isFile
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
Expand All @@ -25,6 +23,8 @@ import java.nio.file.Files
import java.nio.file.Paths
import java.util.concurrent.TimeUnit
import kotlin.io.path.exists
import kotlin.io.path.isDirectory
import kotlin.io.path.isRegularFile
import kotlin.streams.asSequence

private val log = Logger.getInstance(RpmMacroUtil::class.java)
Expand Down Expand Up @@ -77,7 +77,7 @@ object RpmMacroUtil {

if (startPath.exists() && startPath.isDirectory()) {
Files.walk(startPath).asSequence()
.filter { it?.isFile() == true && matcher.matches(it.fileName) }
.filter { it?.isRegularFile() == true && matcher.matches(it.fileName) }
.mapNotNull { LocalFileSystem.getInstance().findFileByPath(it.toString()) }
.toList()
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@

<change-notes><![CDATA[
<html>
<b>Changes in version 2.2.0:</b>
<b>Changes in version 2.2.1:</b>
<ul>
<li>Build against IntelliJ 2023.2</li>
<li>Fix section headers sometimes not being highlighted</li>
<li>Build against IntelliJ 2023.3</li>
<li>Update build dependencies</li>
</ul><br>
</html>
]]>
</change-notes>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="232"/>
<idea-version since-build="233"/>

<depends>com.intellij.modules.lang</depends>
<depends optional="true" config-file="rpmSpecFile-withSh.xml">com.jetbrains.sh</depends>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RpmSpecShellLexerTest : LexerTestCase() {
override fun createLexer(): Lexer = RpmSpecShellLexerAdapter()
override fun getDirPath(): String = "src/test/resources/macros/shell"

override fun getPathToTestDataFile(extension: String?): String {
override fun getPathToTestDataFile(extension: String): String {
val filename = "/spec/shell/${getTestName(true)}$extension"
return checkNotNull(javaClass.getResource(filename)?.path) { "Missing file $filename" }
}
Expand Down

0 comments on commit 6a3f8ec

Please sign in to comment.