Skip to content

Commit

Permalink
Merge pull request #458 from fwcd/convention-plugins
Browse files Browse the repository at this point in the history
Update to Gradle 8 and migrate to convention plugins
  • Loading branch information
fwcd committed Apr 13, 2023
2 parents a10c947 + 4395b76 commit 0600f96
Show file tree
Hide file tree
Showing 21 changed files with 76 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
- name: Build
run: ./gradlew :server:build :shared:build -PjavaVersion=${{ matrix.java }}
- name: Detekt
run: ./gradlew detekt
run: ./gradlew detekt -PjavaVersion=${{ matrix.java }}
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ tasks.register<DetektCreateBaselineTask>("createDetektBaseline") {
baseline.set(file("$rootDir/detekt_baseline.xml"))
include("**/*.kt")
include("**/*.kts")
exclude("shared/build/**/*.*")
exclude("server/build/**/*.*")
exclude("gradle/plugins/build/**/*.*")
exclude("**/build/**")
}

tasks.withType<Detekt>().configureEach {
jvmTarget = JavaVersion.VERSION_11.toString()
exclude("**/build/**")
reports {
html.required.set(true)
md.required.set(true)
Expand Down
34 changes: 34 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import java.util.Properties
import groovy.lang.MissingPropertyException

plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
gradlePluginPortal()
}

// Use the same Java version for compiling the convention plugins as for the main project
// For this we need to manually load the gradle.properties, since variables from the main
// project are generally not visible from buildSrc.

val javaVersionProperty = "javaVersion"
val javaVersion = try {
project.property(javaVersionProperty) as String
} catch (e: MissingPropertyException) {
Properties().also { properties ->
File("$rootDir/../gradle.properties").inputStream().use { stream ->
properties.load(stream)
}
}[javaVersionProperty] as String
}

kotlin {
jvmToolchain(javaVersion.toInt())
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
1 change: 1 addition & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "build-conventions"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
kotlin("jvm")
}

val javaVersion = property("javaVersion") as String

kotlin {
jvmToolchain(javaVersion.toInt())
}
9 changes: 9 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
config:
validation: true # verifies that this config file is valid
warningsAsErrors: false

exceptions:
SwallowedException:
ignoredExceptionTypes:
- InterruptedException
- MalformedURLException
- NumberFormatException
- ParseException
- MissingPropertyException
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version=1.3.2
javaVersion=11
7 changes: 0 additions & 7 deletions gradle/plugins/kotlin-plugins/build.gradle.kts

This file was deleted.

7 changes: 0 additions & 7 deletions gradle/plugins/settings.gradle.kts

This file was deleted.

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

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
2 changes: 1 addition & 1 deletion scripts/release_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def git_working_dir_is_clean(repo_path):
}
EDITOR = os.environ.get("EDITOR", "vim") # https://stackoverflow.com/questions/6309587/call-up-an-editor-vim-from-a-python-script
PROJECT_DIR = Path(__file__).parent.parent
PROJECT_VERSION_KEY = "projectVersion"
PROJECT_VERSION_KEY = "version"

def main():
parser = argparse.ArgumentParser(description="A small utility for updating the project's version and creating tags.")
Expand Down
21 changes: 3 additions & 18 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
import groovy.lang.MissingPropertyException

plugins {
kotlin("jvm")
id("maven-publish")
id("application")
id("com.github.jk1.tcdeps")
id("com.jaredsburrows.license")
id("configure-publishing")
id("kotlin-language-server.publishing-conventions")
id("kotlin-language-server.kotlin-conventions")
}

val projectVersion = "1.3.2"
val debugPort = 8000
val debugArgs = "-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n,quiet=y"
val javaVersion = try {
project.property("javaVersion").toString()
} catch (_: MissingPropertyException) {
"11"
}

version = projectVersion

val serverMainClassName = "org.javacs.kt.MainKt"
val applicationName = "kotlin-language-server"

application {
mainClass.set(serverMainClassName)
description = "Code completions, diagnostics and more for Kotlin"
applicationDefaultJvmArgs = listOf("-DkotlinLanguageServer.version=$projectVersion")
applicationDefaultJvmArgs = listOf("-DkotlinLanguageServer.version=$version")
applicationDistribution.into("bin") {
fileMode = 755
}
Expand Down Expand Up @@ -84,12 +75,6 @@ tasks.startScripts {
applicationName = "kotlin-language-server"
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
jvmTarget = javaVersion
}
}

tasks.register<Exec>("fixFilePermissions") {
// When running on macOS or Linux the start script
// needs executable permissions to run.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
projectVersion=1.3.2
kotlinVersion=1.8.10
exposedVersion=0.37.3
lsp4jVersion=0.15.0
javaVersion=11
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
// TODO: Currently not possible, see https://github.com/gradle/gradle/issues/9830
// kotlin("jvm") version "$kotlinVersion"
kotlin("jvm") version "1.3.50"
kotlin("jvm") version "1.8.10"
}

repositories {
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ pluginManagement {
id("com.github.jk1.tcdeps") version "1.2" apply false
id("com.jaredsburrows.license") version "0.8.42" apply false
}

includeBuild("gradle/plugins")
}

dependencyResolutionManagement {
Expand Down
20 changes: 2 additions & 18 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,30 +1,14 @@
import groovy.lang.MissingPropertyException

plugins {
id("maven-publish")
kotlin("jvm")
id("configure-publishing")
id("kotlin-language-server.publishing-conventions")
id("kotlin-language-server.kotlin-conventions")
}

repositories {
mavenCentral()
}

version = project.version
val javaVersion = try {
project.property("javaVersion").toString()
} catch (_: MissingPropertyException) {
"11"
}

java {
toolchain {
languageVersion.set(
JavaLanguageVersion.of(javaVersion)
)
}
}

dependencies {
// dependencies are constrained to versions defined
// in /gradle/platform/build.gradle.kts
Expand Down

0 comments on commit 0600f96

Please sign in to comment.