Skip to content

Commit 81d19cd

Browse files
Konstantin PavlovKonstantin Pavlov
authored andcommitted
Add formatting and linting enhancements to the build process
1 parent bf9056a commit 81d19cd

File tree

2 files changed

+57
-13
lines changed

2 files changed

+57
-13
lines changed

Makefile

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
build:
2-
mvn clean verify site
2+
mvn clean verify site
33

4-
lint:
5-
# brew install ktlint
6-
ktlint --format
7-
# https://docs.openrewrite.org/recipes/maven/bestpractices
8-
mvn rewrite:run -P lint
4+
lint:prepare
5+
ktlint && \
6+
mvn spotless:check
7+
8+
# https://docs.openrewrite.org/recipes/maven/bestpractices
9+
format:prepare
10+
ktlint --format && \
11+
mvn spotless:apply && \
12+
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \
13+
-Drewrite.activeRecipes=org.openrewrite.maven.BestPractices \
14+
-Drewrite.exportDatatables=true
15+
16+
prepare:
17+
brew install ktlint --quiet
18+
19+
all: format lint build

pom.xml

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
<scm>
3737
<connection>scm:git:git://github.com/kpavlov/langchain4j-kotlin.git</connection>
3838
<developerConnection>scm:git:ssh://github.com/kpavlov/langchain4j-kotlin.git</developerConnection>
39-
<url>https://github.com/kpavlov/langchain4j-kotlin/tree/main</url>
4039
<tag>HEAD</tag>
40+
<url>https://github.com/kpavlov/langchain4j-kotlin/tree/main</url>
4141
</scm>
4242

4343
<properties>
44-
<argLine />
44+
<argLine/>
4545
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4646
<kotlin.code.style>official</kotlin.code.style>
4747
<java.version>17</java.version>
@@ -166,8 +166,6 @@
166166
</dependencies>
167167

168168
<build>
169-
<sourceDirectory>src/main/kotlin</sourceDirectory>
170-
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
171169
<pluginManagement>
172170
<plugins>
173171
<plugin>
@@ -229,6 +227,39 @@
229227
<artifactId>maven-project-info-reports-plugin</artifactId>
230228
<version>3.8.0</version>
231229
</plugin>
230+
<plugin>
231+
<!-- https://github.com/diffplug/spotless/blob/main/plugin-maven -->
232+
<groupId>com.diffplug.spotless</groupId>
233+
<artifactId>spotless-maven-plugin</artifactId>
234+
<version>2.43.0</version>
235+
<configuration>
236+
<!-- optional: limit format enforcement to just the files changed by this feature branch -->
237+
<ratchetFrom>origin/main</ratchetFrom>
238+
<java>
239+
<palantirJavaFormat/>
240+
</java>
241+
<kotlin>
242+
<ktlint/>
243+
</kotlin>
244+
<markdown>
245+
<includes>
246+
<!-- You have to set the target manually -->
247+
<include>**/*.md</include>
248+
</includes>
249+
<flexmark/>
250+
</markdown>
251+
<pom>
252+
<includes>
253+
<!-- You have to set the target manually -->
254+
<include>**/pom.xml</include>
255+
</includes>
256+
<sortPom>
257+
<nrOfIndentSpace>4</nrOfIndentSpace>
258+
<expandEmptyElements>false</expandEmptyElements>
259+
</sortPom>
260+
</pom>
261+
</configuration>
262+
</plugin>
232263
</plugins>
233264
</pluginManagement>
234265

@@ -308,10 +339,10 @@
308339
<artifactId>detekt-maven-plugin</artifactId>
309340
<executions>
310341
<execution>
311-
<phase>verify</phase>
312342
<goals>
313343
<goal>check</goal>
314344
</goals>
345+
<phase>verify</phase>
315346
</execution>
316347
</executions>
317348
</plugin>
@@ -320,10 +351,10 @@
320351
<artifactId>dokka-maven-plugin</artifactId>
321352
<executions>
322353
<execution>
323-
<phase>package</phase>
324354
<goals>
325355
<goal>javadocJar</goal>
326356
</goals>
357+
<phase>package</phase>
327358
<configuration>
328359
<attach>true</attach>
329360
</configuration>
@@ -344,6 +375,8 @@
344375
</configuration>
345376
</plugin>
346377
</plugins>
378+
<sourceDirectory>src/main/kotlin</sourceDirectory>
379+
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
347380
</build>
348381

349382
<profiles>
@@ -358,10 +391,10 @@
358391
<executions>
359392
<execution>
360393
<id>sign-artifacts</id>
361-
<phase>verify</phase>
362394
<goals>
363395
<goal>sign</goal>
364396
</goals>
397+
<phase>verify</phase>
365398
</execution>
366399
</executions>
367400
</plugin>

0 commit comments

Comments
 (0)