Skip to content

Commit

Permalink
Refactor Makefile and integrate Spotless plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Pavlov authored and Konstantin Pavlov committed Nov 22, 2024
1 parent a81e629 commit 9a3300d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 17 deletions.
5 changes: 2 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]
# Change these settings to your own preference
indent_style = space
Expand All @@ -22,7 +20,8 @@ trim_trailing_whitespace = false
[pom.xml]
indent_size = 4

[*.kt]
# noinspection EditorConfigKeyCorrectness
[*.{kt,kts}]
indent_size = 4
max_line_length = 100
ij_kotlin_name_count_to_use_star_import = 999
Expand Down
25 changes: 17 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
build:
mvn clean verify site
lint:
# brew install ktlint
ktlint --format
# https://docs.openrewrite.org/recipes/maven/bestpractices
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \
-Drewrite.activeRecipes=org.openrewrite.maven.BestPractices \
-Drewrite.exportDatatables=true
mvn clean verify site

lint:prepare
ktlint

format:prepare
ktlint --format \
mvn spotless:apply \
# https://docs.openrewrite.org/recipes/maven/bestpractices
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \
-Drewrite.activeRecipes=org.openrewrite.maven.BestPractices \
-Drewrite.exportDatatables=true

prepare:
brew install ktlint --quiet

all: format lint build
40 changes: 34 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
<scm>
<connection>scm:git:git://github.com/kpavlov/awesome-kotlin-maven-template.git</connection>
<developerConnection>scm:git:ssh://github.com/kpavlov/awesome-kotlin-maven-template.git</developerConnection>
<url>https://github.com/kpavlov/awesome-kotlin-maven-template/tree/main</url>
<tag>HEAD</tag>
<url>https://github.com/kpavlov/awesome-kotlin-maven-template/tree/main</url>
</scm>

<properties>
Expand Down Expand Up @@ -146,8 +146,6 @@
</dependencies>

<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<pluginManagement>
<plugins>
<plugin>
Expand Down Expand Up @@ -201,6 +199,34 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.11.1</version>
</plugin>
<plugin>
<!-- https://github.com/diffplug/spotless/blob/main/plugin-maven -->
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.43.0</version>
<configuration>
<!-- optional: limit format enforcement to just the files changed by this feature branch -->
<ratchetFrom>origin/main</ratchetFrom>
<java>
<palantirJavaFormat/>
</java>
<kotlin>
<ktlint/>
</kotlin>
<markdown>
<includes> <!-- You have to set the target manually -->
<include>**/*.md</include>
</includes>
<flexmark/>
</markdown>
<pom>
<sortPom>
<nrOfIndentSpace>4</nrOfIndentSpace>
<expandEmptyElements>false</expandEmptyElements>
</sortPom>
</pom>
</configuration>
</plugin>
</plugins>
</pluginManagement>

Expand Down Expand Up @@ -276,10 +302,10 @@
<artifactId>detekt-maven-plugin</artifactId>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
Expand All @@ -288,10 +314,10 @@
<artifactId>dokka-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>javadocJar</goal>
</goals>
<phase>package</phase>
<configuration>
<attach>true</attach>
</configuration>
Expand All @@ -312,6 +338,8 @@
</configuration>
</plugin>
</plugins>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
</build>

<profiles>
Expand All @@ -326,10 +354,10 @@
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
Expand Down

0 comments on commit 9a3300d

Please sign in to comment.