Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEG-4936 migrate to pleo gradle plugin #232

Merged
merged 21 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 5 additions & 103 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,17 @@ buildscript {

dependencies {
classpath(libs.kotlin.gradle.plugin)
classpath(libs.kotlinter.gradle)
}
}

plugins {
alias(libs.plugins.kotlin.jvm) apply false
id 'jacoco'
alias(libs.plugins.coveralls.jacoco) apply false
alias(libs.plugins.jacocolog) apply false
alias(libs.plugins.pleo.gradle.plugin)
}

allprojects {
group = 'io.pleo'

apply plugin: libs.plugins.coveralls.jacoco.get().pluginId
apply plugin: libs.plugins.jacocolog.get().pluginId

jacoco {
toolVersion = "0.8.7"
}

tasks.named("jacocoLogAggregatedCoverage") {
enabled = false
}

repositories {
mavenCentral()
}
Expand All @@ -47,7 +33,6 @@ subprojects {
apply plugin: libs.plugins.java.library.get().pluginId
apply plugin: libs.plugins.kotlin.library.get().pluginId
apply plugin: libs.plugins.maven.publish.get().pluginId
apply plugin: libs.plugins.jmailen.kotlinter.get().pluginId

sourceCompatibility = 17
targetCompatibility = 17
Expand Down Expand Up @@ -77,16 +62,6 @@ subprojects {
testRuntimeOnly(libs.junit.jupiter.engine)
}

task sourcesJar(type: Jar) {
from sourceSets.main.allJava
classifier = 'sources'
}

task javadocJar(type: Jar) {
from javadoc
classifier = 'javadoc'
}

javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
Expand All @@ -102,85 +77,12 @@ subprojects {
useJUnitPlatform()
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar

pom {
name = project.name
description = "Dynamic properties for your Java/Kotlin app"
url = 'http://github.com/pleo-io/prop'
licenses {
license {
name = 'MIT License'
url = 'http://www.opensource.org/licenses/mit-license.php'
}
}
developers {
developer {
name = 'Pleo'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:[email protected]:pleo-io/prop.git'
developerConnection = 'scm:git:[email protected]:pleo-io/prop.git'
url = 'https://github.com/pleo-io/prop'
}
}
}
}

repositories {
mavenLocal()
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/pleo-io/prop")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
}

ext.generateVersion = { ->
def updateMode = properties.get("mode") ?: "internal"
def splitVersionStrings = version.toString().split("[.]")
def (major, minor, patch) = splitVersionStrings.collect{Integer.parseInt(it)}
switch (updateMode) {
case "major": major++; minor = 0; patch = 0; break
case "minor": minor++; patch = 0; break
case "patch": patch++; break
}
"$major.$minor.$patch"
}

tasks.register("incrementVersion") {
group = "release"
description = "Increments the version in this build file everywhere it is used."

doLast {
def propertiesReference = new Properties()
def propertiesFile = file("gradle.properties")

def newVersion = properties.get("overrideVersion") ?: generateVersion()
propertiesReference.load(propertiesFile.newDataInputStream())
propertiesReference.setProperty("version", newVersion)
propertiesReference.store(propertiesFile.newWriter(), null)
}
}

// Executed only at root level so code coverage is only reported once to Coveralls
coverallsJacoco {
reportPath = "build/reports/jacoco/jacocoAggregatedReport/jacocoAggregatedReport.xml"
reportSourceSets += subprojects.sourceSets.main.allSource.srcDirs.flatten()
tasks.check {
finalizedBy("formatKotlin")
}

tasks.named('coverallsJacoco') {
dependsOn jacocoAggregatedReport
pleoRepositoryExtension {
publish.set(subprojects.toSet())
}
19 changes: 19 additions & 0 deletions detekt-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues></ManuallySuppressedIssues>
<CurrentIssues>
<ID>FunctionParameterNaming:InlineProviderModule.kt$InlineProviderModule$@Named("io.pleo.test.prop3") u_u: Prop&lt;String&gt;</ID>
<ID>FunctionParameterNaming:InlineProviderModule.kt$InlineProviderModule$@Named("io.pleo.test.prop3") w_w: Prop&lt;String&gt;</ID>
<ID>FunctionParameterNaming:InlineProviderModule.kt$InlineProviderModule$@Named("io.pleo.test.prop4") w_w: Prop&lt;String&gt;</ID>
<ID>SwallowedException:PropTest.kt$PropTest$ex: CreationException</ID>
<ID>ThrowsCount:ParsingProperty.kt$ParsingProperty$private fun parseProperty(): T</ID>
<ID>TooGenericExceptionCaught:JacksonParserFactory.kt$JacksonParserFactory$ex: RuntimeException</ID>
<ID>TooGenericExceptionCaught:ParsingProperty.kt$ParsingProperty$ex: Exception</ID>
<ID>TooGenericExceptionCaught:ParsingProperty.kt$ParsingProperty$ex: RuntimeException</ID>
<ID>TooGenericExceptionCaught:PropMappingVisitor.kt$PropMappingVisitor$ex: RuntimeException</ID>
<ID>TooManyFunctions:CompositeConfigurationBuilder.kt$CompositeConfigurationBuilder : ConfigurationBuilder</ID>
<ID>TooManyFunctions:PropMappingVisitor.kt$PropMappingVisitor : DefaultElementVisitor</ID>
<ID>UnusedPrivateProperty:NullValue.kt$NullValue$@Named("io.pleo.undefined.property") thisThrows: Prop&lt;String&gt;</ID>
<ID>UnusedPrivateProperty:UnnamedProp.kt$UnnamedProp$unnamedProp: Prop&lt;String&gt;</ID>
</CurrentIssues>
</SmellBaseline>
18 changes: 18 additions & 0 deletions detekt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# File: detekt.yaml

style:
ForbiddenComment:
active: true
values:
- "STOPSHIP:"
- "TODO:"
allowedPatterns: ""
customMessage: ""
MaxLineLength:
maxLineLength: 160

naming:
FunctionNaming:
excludes: &TestClasses
- '**/*Tests.kt'
- '**/*Test.kt'
6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
#Thu Feb 02 09:01:06 UTC 2023
#Some properties were automatically set by the Pleo Gradle plugin.
#Thu Dec 21 10:26:54 EET 2023
org.gradle.configuration-cache=true
org.gradle.configuration-cache.problems=warn
org.gradle.jvmargs=-Xmx4096m "-XX\:MaxMetaspaceSize\=1024m"
version=6.0.28
7 changes: 1 addition & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ jacksonVersion = "2.14.2"
junitVersion = "5.9.3"
kotlinGuiceVersion = "1.6.0"
kotlinVersion = "1.8.0"
kotlinterGradleVersion = "3.13.0"
logbackClassicVersion = "1.4.5"
mockkVersion = "1.13.4"
monetaVersion = "1.4.2"
Expand All @@ -28,18 +27,14 @@ junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", vers
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinVersion" }
kotlin-guice = { module = "dev.misfitlabs.kotlinguice4:kotlin-guice", version.ref = "kotlinGuiceVersion" }
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlinVersion" }
kotlinter-gradle = { module = "org.jmailen.gradle:kotlinter-gradle", version.ref = "kotlinterGradleVersion" }
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logbackClassicVersion" }
mockk = { module = "io.mockk:mockk", version.ref = "mockkVersion" }
moneta = { module = "org.javamoney:moneta", version.ref = "monetaVersion" }
slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf4jVersion" }

[plugins]
java-library = { id = "java-library" }
jmailen-kotlinter = { id = "org.jmailen.kotlinter" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlinVersion" }
kotlin-library = { id = "kotlin" }
maven-publish = { id = "maven-publish" }
coveralls-jacoco = { id = "com.github.nbaztec.coveralls-jacoco", version = "1.2.15" }
jacocolog = { id = "org.barfuin.gradle.jacocolog", version = "3.0.0" }

pleo-gradle-plugin = { id = "io.pleo.gradle.plugin", version = "5.12.0" }
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.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
35 changes: 22 additions & 13 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,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,11 +198,15 @@ 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" \
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
Loading