Skip to content

Commit

Permalink
Merge pull request #306 from ftsrg/spotless
Browse files Browse the repository at this point in the history
`Spotless` instead of intellij formatting
  • Loading branch information
leventeBajczi authored Oct 21, 2024
2 parents 55c828b + 5323d7f commit 1d6d1ea
Show file tree
Hide file tree
Showing 133 changed files with 2,066 additions and 4,067 deletions.
11 changes: 4 additions & 7 deletions .github/actions/cache-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ inputs:
runs:
using: "composite"
steps:
# - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
# if: runner.os == 'Linux'
# id: cache
# with:
# path: .
# key: ${{ runner.os }}-${{github.sha}}

- name: fetch
shell: bash
run: |
git fetch origin
- name: build gradle
uses: gradle/gradle-build-action@40b6781dcdec2762ad36556682ac74e31030cfe2 # v2.5.1
with:
Expand Down
6 changes: 2 additions & 4 deletions .github/actions/check-formatting/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ runs:
- name: Checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Check for formatting
uses: leventeBajczi/[email protected]
uses: ./.github/actions/cache-build
with:
settings-file: "./.idea/codeStyles/Project.xml"
file-mask: "*.java,*.kt"
additional-options: "-dry"
arguments: spotlessCheck
77 changes: 0 additions & 77 deletions .github/workflows/reapply_copyright.yml

This file was deleted.

9 changes: 2 additions & 7 deletions .github/workflows/reformat-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name: Reformat code
on:
workflow_dispatch:
inputs:
file_mask:
description: 'File mask to reformat'
required: true
default: '*.java,*.kts,*.kt'
direct-commit:
type: boolean
default: false
Expand All @@ -28,10 +24,9 @@ jobs:
token: ${{ steps.generate-token.outputs.token }}

- name: Do reformat
uses: leventeBajczi/[email protected]
uses: ./.github/actions/cache-build
with:
settings-file: "./.idea/codeStyles/Project.xml"
file-mask: ${{ inputs.file_mask }}
arguments: spotlessApply

- name: Create Pull Request
if: ${{ !inputs.direct-commit }}
Expand Down
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

plugins {
base
id("jacoco-common")
Expand All @@ -28,7 +29,7 @@ buildscript {

allprojects {
group = "hu.bme.mit.theta"
version = "6.6.1"
version = "6.6.2"

apply(from = rootDir.resolve("gradle/shared-with-buildSrc/mirrors.gradle.kts"))
}
Expand Down
7 changes: 4 additions & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ apply(from = rootDir.resolve("../gradle/shared-with-buildSrc/mirrors.gradle.kts"

val kotlinVersion: String by project
val shadowVersion: String by project
val spotlessVersion: String by project

// https://github.com/gradle/kotlin-dsl/issues/430#issuecomment-414768887
fun gradlePlugin(id: String, version: String): String = "$id:$id.gradle.plugin:$version"
Expand All @@ -38,14 +39,14 @@ dependencies {
compileOnly(gradleKotlinDsl())
implementation(kotlin("gradle-plugin", kotlinVersion))
implementation(gradlePlugin("com.github.johnrengelman.shadow", shadowVersion))
implementation(gradlePlugin("com.diffplug.spotless", spotlessVersion))
}

// Force the embeddable Kotlin compiler version to be the selected kotlinVersion.
// https://github.com/gradle/kotlin-dsl/issues/1207
configurations.all {
val isKotlinCompiler = name == "embeddedKotlin" || name.startsWith("kotlin") || name.startsWith(
"kapt"
)
"kapt")
if (!isKotlinCompiler) {
resolutionStrategy.eachDependency {
if (requested.group == "org.jetbrains.kotlin" && requested.module.name == "kotlin-compiler-embeddable") {
Expand Down Expand Up @@ -104,4 +105,4 @@ tasks {
named("compileKotlin", KotlinCompile::class) {
dependsOn(generateVersions)
}
}
}
3 changes: 2 additions & 1 deletion buildSrc/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ deltaCollectionsVersion=0.0.1
gsonVersion=2.9.1
javasmtVersion=4.1.1
sosylabVersion=0.3000-569-g89796f98
cliktVersion=4.4.0
cliktVersion=4.4.0
spotlessVersion=6.25.0
44 changes: 44 additions & 0 deletions buildSrc/src/main/kotlin/java-common.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ plugins {
java
id("jacoco-common")
id("maven-artifact")
id("com.diffplug.spotless")
}

dependencies {
Expand Down Expand Up @@ -65,3 +66,46 @@ tasks {
jvmArgs("-Xss5m", "-Xms512m", "-Xmx1g")
}
}

spotless {
ratchetFrom("origin/master")

isEnforceCheck = false

val year = "\$YEAR" // you can't escape $ in raw strings..
val licenseHeader = """ /*
* Copyright $year Budapest University of Technology and Economics
*
* 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
*
* http://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.
*/""".trimIndent()


java {
importOrder("java|javax", "hu.bme.", "")
removeUnusedImports()
googleJavaFormat("1.24.0").aosp().reflowLongStrings()
formatAnnotations()

licenseHeader(licenseHeader)
}
kotlin {
ktfmt("0.51").googleStyle()

licenseHeader(licenseHeader)
}
kotlinGradle {
target("*.gradle.kts") // default target for kotlinGradle

ktlint()
}
}
9 changes: 3 additions & 6 deletions buildSrc/src/main/kotlin/maven-artifact.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,11 @@ tasks {
repositories {
maven {
val releasesRepoUrl = uri(
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
)
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri(
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
)
"https://s01.oss.sonatype.org/content/repositories/snapshots/")
url = if (version.toString()
.endsWith("SNAPSHOT")
) snapshotsRepoUrl else releasesRepoUrl
.endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
Expand Down
Loading

0 comments on commit 1d6d1ea

Please sign in to comment.