Skip to content

Commit

Permalink
updating to java 17, gradle 8.5, ktlint 12.0.3 (#164)
Browse files Browse the repository at this point in the history
* updating to java 17, gradle 8.5, ktlint 12.0.3
  • Loading branch information
venkatttwenty1 authored Jan 9, 2024
1 parent 8968ad4 commit 3854616
Show file tree
Hide file tree
Showing 117 changed files with 6,281 additions and 5,181 deletions.
2 changes: 0 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ insert_final_newline=true
# possible values: number (e.g. 120) (package name, imports & comments are ignored), "off"
# it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide)
max_line_length=off

disabled_rules=no-wildcard-imports,filename
3 changes: 2 additions & 1 deletion .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ jobs:
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
- name: Run Postgres
run: |
docker-compose -f docker-compose.yml up -d pg
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: '8.5'
arguments: build
- name: Upload JaCoCo coverage report as a workflow artifact
uses: actions/upload-artifact@v3
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ jobs:
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
- name: Run Postgres
run: |
docker-compose -f docker-compose.yml up -d pg
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: '8.5'
arguments: build
- name: Upload JaCoCo coverage report as a workflow artifact
- name: Upload build reports as a workflow artifact on failure
uses: actions/upload-artifact@v3
with:
name: build-reports
path: build/reports
- name: Upload JaCoCo coverage report as a workflow artifact on failure
uses: actions/upload-artifact@v3
with:
name: jacoco-report
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/clients.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ jobs:
- name: Move the spec file
run: |
mv iam/iam_openapi_spec.yml client/iam_openapi_spec.yml
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
- name: Generate Files
working-directory: client
Expand Down
65 changes: 24 additions & 41 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ buildscript {
ext.kotlin_version = '1.8.10'
ext.ktor_version = '2.2.4'
ext.koin_version = '3.4.3'
ext.shadow_version = '5.2.0'
ext.shadow_version = '8.1.1'
ext.exposed_version = "0.37.3"
ext.jooq_version = '3.16.15'
ext.hikari_cp_version = "5.0.1"
ext.junit_version = '5.9.2'
ext.flyway_version = '9.16.0'
ext.casbin_version = '1.32.2'
ext.postgres_jdbc_driver = '42.5.4'
ext.detekt_version = '1.22.0'
ext.detekt_version = '1.19.0'
ext.cohort_version = '1.7.3'

repositories {
Expand All @@ -23,7 +23,7 @@ buildscript {

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.github.jengelman.gradle.plugins:shadow:$shadow_version"
classpath "com.github.johnrengelman:shadow:$shadow_version"
}

configurations['classpath'].resolutionStrategy.eachDependency {
Expand All @@ -37,7 +37,7 @@ plugins {
id 'org.flywaydb.flyway' version "$flyway_version"
id 'nu.studer.jooq' version '7.1'
id "io.gitlab.arturbosch.detekt" version "$detekt_version"
id "org.jlleitschuh.gradle.ktlint" version "10.3.0"
id "org.jlleitschuh.gradle.ktlint" version "12.0.3"
id "jacoco"
id "org.openapi.generator" version "5.3.0"
id "com.osacky.doctor" version "0.8.0"
Expand All @@ -47,7 +47,7 @@ group 'com.hypto'
version '1.0.0'

wrapper {
gradleVersion = '7.4.1'
gradleVersion = '8.5'
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}

Expand All @@ -59,7 +59,8 @@ apply plugin: 'org.jlleitschuh.gradle.ktlint'
apply from: "./buildscripts/rootOrganization.gradle"

mainClassName = "com.hypto.iam.server.ApplicationKt"
sourceCompatibility = 11
sourceCompatibility = 17
apply plugin: "com.github.johnrengelman.shadow"

sourceSets {
main.java.srcDirs += "$rootDir/main/kotlin"
Expand All @@ -70,22 +71,23 @@ sourceSets {
}

compileKotlin {
kotlinOptions.jvmTarget = "11"
kotlinOptions.jvmTarget = "17"
}

compileTestKotlin {
kotlinOptions.jvmTarget = "11"
kotlinOptions.jvmTarget = "17"
}

test {
jvmArgs("--add-opens", "java.base/java.time=ALL-UNNAMED")
useJUnitPlatform()
testLogging.showStandardStreams(true)
finalizedBy jacocoTestReport // report is always generated after tests run
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
csv.enabled = true
csv.required = true
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
Expand All @@ -100,12 +102,12 @@ jacocoTestReport {
}
jacoco {
toolVersion = "0.8.7"
reportsDir = file("$buildDir/jacoco")
reportsDirectory = file("$buildDir/jacoco")
}

shadowJar {
baseName = 'hypto-iam-server'
version = '1.0.0'
archiveBaseName.set('hypto-iam-server')
archiveVersion.set('1.0.0')
}

repositories {
Expand Down Expand Up @@ -172,6 +174,7 @@ jooq {
fluentSetters = true
relations = true
// embeddablePrimaryKeys = true // Available only in paid version :(
daos = false
daos = false
routines = false
indexes = false
Expand Down Expand Up @@ -308,40 +311,19 @@ detekt {
//}

ktlint {
version = "0.45.2"
debug = false
verbose = false
android = false
outputToConsole = true
outputColorName = "RED"
ignoreFailures = false
enableExperimentalRules = false
additionalEditorconfigFile = file(".editorconfig")
disabledRules = ["import-ordering"]
// baseline = file("my-project-ktlint-baseline.xml")
// reporters {
// reporter "plain"
// reporter "checkstyle"
// reporter "sarif"
// }
// kotlinScriptAdditionalPaths {
// include fileTree("scripts/")
// }
verbose.set(true)
outputToConsole.set(true)
coloredOutput.set(true)
filter {
// Workaround to exclude directory from KtLint
// https://github.com/JLLeitschuh/ktlint-gradle/issues/579
exclude {
it.file.toString().contains("generated/")
exclude { entry ->
entry.file.toString().contains("generated")
entry.file.toString().contains("generated-src")
}
exclude {
it.file.toString().contains("generated-src/")
}
include("**/kotlin/**")
}
}

dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:$detekt_version")
// detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:$detekt_version")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
implementation("io.ktor:ktor-server-cio:$ktor_version")
implementation("io.ktor:ktor-server-metrics:$ktor_version")
Expand Down Expand Up @@ -457,7 +439,8 @@ dependencies {
tasks.named('generateJooq').configure {
// ensure database schema has been prepared by Flyway before generating the jOOQ sources
dependsOn tasks.named('flywayMigrate')

mustRunAfter tasks.named('runKtlintFormatOverMainSourceSet'), tasks.named('runKtlintFormatOverTestSourceSet'),
tasks.named('runKtlintCheckOverMainSourceSet'), tasks.named('runKtlintCheckOverTestSourceSet')
// declare Flyway migration scripts as inputs on the jOOQ task
inputs.files(fileTree('src/main/resources/db/migration'))
.withPropertyName('migrations')
Expand Down
4 changes: 3 additions & 1 deletion detekt_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ formatting:
style:
ForbiddenComment:
allowedPatterns: 'TODO:'
MaxLineLength:
maxLineLength: 200

complexity:
LongMethod:
active: false
LongParameterList:
functionThreshold : 10
functionThreshold : 15
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
51 changes: 33 additions & 18 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

#
# Copyright ? 2015-2021 the original authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions ?$var?, ?${var}?, ?${var:-default}?, ?${var+SET}?,
# ?${var#prefix}?, ?${var%suffix}?, and ?$( cmd )?;
# * compound commands having a testable exit status, especially ?case?;
# * various built-in commands including ?command?, ?set?, and ?ulimit?.
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
Expand All @@ -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,13 +80,11 @@ 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##*/}

# 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"'
# 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 @@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
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=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=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,18 +198,28 @@ if "$cygwin" || "$msys" ; then
done
fi

# 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.

# 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, 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" \
-classpath "$CLASSPATH" \
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
Loading

0 comments on commit 3854616

Please sign in to comment.