Skip to content

Commit

Permalink
chore: use spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
kalinjul committed Aug 31, 2023
1 parent 5235fac commit dc5f07b
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Ktlint
name: Spotless

on:
pull_request:
Expand All @@ -10,8 +10,8 @@ on:
- main

jobs:
ktlint:
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]') && ! (contains(toJSON(github.event.commits.*.message), '[skip ') && contains(toJSON(github.event.commits.*.message), '#ktlint'))"
spotless:
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]') && ! (contains(toJSON(github.event.commits.*.message), '[skip ') && contains(toJSON(github.event.commits.*.message), '#spotless'))"
runs-on: ubuntu-latest

steps:
Expand All @@ -26,4 +26,4 @@ jobs:
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew ktlint
run: ./gradlew spotlessCheck
25 changes: 0 additions & 25 deletions _ktlint.gradle

This file was deleted.

30 changes: 20 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {

repositories {
google()
mavenCentral()
}
dependencies {
classpath libs.kotlin.pluginGradle
classpath libs.gradle
classpath libs.gradle.nexus.staging.plugin

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

apply plugin: 'io.codearte.nexus-staging'
plugins {
alias libs.plugins.spotless apply false
alias libs.plugins.nexus.staging apply true
}

subprojects {
project.afterEvaluate {
spotless {
kotlin {
target "/.kt"
ktlint(libs.versions.ktlint.get())
}

groovyGradle {
target '/.gradle'
greclipse().configFile(rootProject.file('spotless/greclipse.properties'))
}
}
}
}

tasks.register('clean', Delete) {
delete rootProject.layout.buildDir
Expand Down
11 changes: 8 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ compileSdk = "33"
gradleNexusStagingPlugin = "0.30.0"
minSdk = "21"
targetSdk = "33"
buildToolsVersion = "33.0.1"
ktlint = "0.42.1"

composeBom = "2023.04.00"
composeCompiler = '1.4.5'
Expand All @@ -13,6 +13,8 @@ kotlin = "1.8.20"
activityComposeVersion = "1.3.1"
lifecycleRuntimeKtxVersion = "2.3.1"

spotless = "6.21.0"

[libraries]
compose-bom = { module = "androidx.compose:compose-bom", version.ref = "composeBom" }
compose-foundation-foundation = { module = "androidx.compose.foundation:foundation" }
Expand All @@ -21,8 +23,11 @@ compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
compose-ui-ui = { module = "androidx.compose.ui:ui" }
compose-ui-util = { module = "androidx.compose.ui:ui-util" }
gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" }
gradle-nexus-staging-plugin = { module = "io.codearte.gradle.nexus:gradle-nexus-staging-plugin", version.ref = "gradleNexusStagingPlugin" }
kotlin-pluginGradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityComposeVersion" }
lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtxVersion" }
lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtxVersion" }

[plugins]
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
nexus-staging = { id = 'io.codearte.nexus-staging', version.ref = "gradleNexusStagingPlugin" }
3 changes: 1 addition & 2 deletions revealswipe/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
alias libs.plugins.spotless
}

apply from: '../_ktlint.gradle'
apply from: '../buildCompose.gradle'

ext {
Expand All @@ -17,7 +17,6 @@ apply from: '../_publish.gradle'
android {
namespace = "de.charlex.compose.revealswipe"
compileSdk libs.versions.compileSdk.get().toInteger()
buildToolsVersion libs.versions.buildToolsVersion.get()

defaultConfig {
minSdk libs.versions.minSdk.get().toInteger()
Expand Down
3 changes: 2 additions & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
alias libs.plugins.spotless
}

android {
namespace = "de.charlex.compose.revealswipe.sample"
compileSdk libs.versions.compileSdk.get().toInteger()
buildToolsVersion libs.versions.buildToolsVersion.get()

defaultConfig {
minSdk libs.versions.minSdk.get().toInteger()
Expand Down
9 changes: 9 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}

rootProject.name = "RevealSwipe"
include ':revealswipe'
include ':sample'
50 changes: 50 additions & 0 deletions spotless/greclipse.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#
# Copyright 2020 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#Whether to use 'space', 'tab' or 'mixed' (both) characters for indentation.
#The default value is 'tab'.
org.eclipse.jdt.core.formatter.tabulation.char=space

#Number of spaces used for indentation in case 'space' characters
#have been selected. The default value is 4.
org.eclipse.jdt.core.formatter.tabulation.size=4

#Number of spaces used for indentation in case 'mixed' characters
#have been selected. The default value is 4.
org.eclipse.jdt.core.formatter.indentation.size=4

#Whether or not indentation characters are inserted into empty lines.
#The default value is 'true'.
org.eclipse.jdt.core.formatter.indent_empty_lines=false

#Number of spaces used for multiline indentation.
#The default value is 2.
groovy.formatter.multiline.indentation=2

#Length after which list are considered too long. These will be wrapped.
#The default value is 30.
groovy.formatter.longListLength=30

#Whether opening braces position shall be the next line.
#The default value is 'same'.
groovy.formatter.braces.start=same

#Whether closing braces position shall be the next line.
#The default value is 'next'.
groovy.formatter.braces.end=next

#Remove unnecessary semicolons. The default value is 'false'.
groovy.formatter.remove.unnecessary.semicolons=false

0 comments on commit dc5f07b

Please sign in to comment.