diff --git a/.github/workflows/javaci.yml b/.github/workflows/javaci.yml
index 640b471..6e85dc7 100644
--- a/.github/workflows/javaci.yml
+++ b/.github/workflows/javaci.yml
@@ -9,10 +9,10 @@ jobs:
steps:
- uses: actions/checkout@v7
- - name: Set up openJDK 21
+ - name: Set up openJDK 25
uses: actions/setup-java@v5.6.0
with:
- java-version: '21'
+ java-version: '25'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
diff --git a/Makefile b/Makefile
index 6429df5..eade488 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,10 @@ test:
./gradlew test
lint:
- ./gradlew checkstyleMain checkstyleTest
+ ./gradlew spotlessCheck
+
+lint-fix:
+ ./gradlew spotlessApply
report:
./gradlew jacocoTestReport
diff --git a/build.gradle.kts b/build.gradle.kts
index 5ef9e4a..cbf2b4a 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -4,33 +4,53 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
java
jacoco
- id("checkstyle")
- id("com.github.ben-manes.versions") version "0.56.0"
+ alias(libs.plugins.spotless)
+ alias(libs.plugins.versions)
+ alias(libs.plugins.version.catalog.update)
}
group = "io.hexlet"
version = "1.0-SNAPSHOT"
+java {
+ toolchain { languageVersion = JavaLanguageVersion.of(25) }
+}
+
repositories { mavenCentral() }
dependencies {
- testImplementation(platform("org.junit:junit-bom:6.1.2"))
- testImplementation("org.junit.jupiter:junit-jupiter")
- testImplementation("org.assertj:assertj-core:3.27.7")
- testRuntimeOnly("org.junit.platform:junit-platform-launcher")
+ testImplementation(platform(libs.junitBom))
+ testImplementation(libs.junitJupiter)
+ testImplementation(libs.assertjCore)
+ testRuntimeOnly(libs.junitPlatformLauncher)
}
tasks.test {
useJUnitPlatform()
- // https://technology.lastminute.com/junit5-kotlin-and-gradle-dsl/
testLogging {
exceptionFormat = TestExceptionFormat.FULL
events = mutableSetOf(TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED)
- // showStackTraces = true
- // showCauses = true
showStandardStreams = true
}
}
tasks.jacocoTestReport { reports { xml.required.set(true) } }
+
+spotless {
+ java {
+ importOrder()
+ removeUnusedImports()
+ googleJavaFormat().aosp()
+ formatAnnotations()
+ leadingTabsToSpaces(4)
+ endWithNewline()
+ }
+}
+
+// versionCatalogUpdate пишет свежие версии прямо в gradle/libs.versions.toml,
+// поэтому руками их сверять не нужно. Ключи не сортируются: порядок в каталоге
+// смысловой, по группам зависимостей.
+versionCatalogUpdate {
+ sortByKey = false
+}
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
deleted file mode 100644
index cab909b..0000000
--- a/config/checkstyle/checkstyle.xml
+++ /dev/null
@@ -1,208 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 4ac3234..1094ec1 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,2 +1,19 @@
-# This file was generated by the Gradle 'init' task.
-# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
+[plugins]
+spotless = { id = "com.diffplug.spotless", version.ref = "spotless-plugin" }
+versions = { id = "io.github.ben-manes.versions", version.ref = "versions-plugin" }
+version-catalog-update = { id = "nl.littlerobots.version-catalog-update", version.ref = "catalog-update-plugin" }
+
+[versions]
+spotless-plugin = "8.9.0"
+versions-plugin = "0.61.0"
+catalog-update-plugin = "1.1.1"
+junit-bom = "6.1.3"
+assertj = "3.27.7"
+
+[libraries]
+# JUnit
+junitBom = { module = "org.junit:junit-bom", version.ref = "junit-bom" }
+junitJupiter = { module = "org.junit.jupiter:junit-jupiter" }
+junitPlatformLauncher = { module = "org.junit.platform:junit-platform-launcher" }
+# Assertions
+assertjCore = { module = "org.assertj:assertj-core", version.ref = "assertj" }
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index a9db115..69dd0d0 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.0-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
diff --git a/gradlew.bat b/gradlew.bat
index 8508ef6..a51ec4f 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,82 +1,82 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-@rem SPDX-License-Identifier: Apache-2.0
-@rem
-
-@if "%DEBUG%"=="" @echo off
-@rem ##########################################################################
-@rem
-@rem gradlew startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables, and ensure extensions are enabled
-setlocal EnableExtensions
-
-set DIRNAME=%~dp0
-if "%DIRNAME%"=="" set DIRNAME=.
-@rem This is normally unused
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if %ERRORLEVEL% equ 0 goto execute
-
-echo. 1>&2
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
-
-"%COMSPEC%" /c exit 1
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto execute
-
-echo. 1>&2
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
-
-"%COMSPEC%" /c exit 1
-
-:execute
-@rem Setup the command line
-
-
-
-@rem Execute gradlew
-@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
-@rem which allows us to clear the local environment before executing the java command
-endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
-
-:exitWithErrorLevel
-@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
-"%COMSPEC%" /c exit %ERRORLEVEL%
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem gradlew startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables, and ensure extensions are enabled
+setlocal EnableExtensions
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+"%COMSPEC%" /c exit 1
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+"%COMSPEC%" /c exit 1
+
+:execute
+@rem Setup the command line
+
+
+
+@rem Execute gradlew
+@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
+@rem which allows us to clear the local environment before executing the java command
+endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
+
+:exitWithErrorLevel
+@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
+"%COMSPEC%" /c exit %ERRORLEVEL%
diff --git a/src/main/java/io/hexlet/pairs/Pair.java b/src/main/java/io/hexlet/pairs/Pair.java
index c4eea0a..5b79098 100644
--- a/src/main/java/io/hexlet/pairs/Pair.java
+++ b/src/main/java/io/hexlet/pairs/Pair.java
@@ -2,8 +2,7 @@
import java.util.function.Function;
-public interface Pair
- extends Function>, T> {
+public interface Pair extends Function>, T> {
static Pair cons(L left, R right) {
return f -> f.apply(left).apply(right);
diff --git a/src/test/java/io/hexlet/pairs/PairsTest.java b/src/test/java/io/hexlet/pairs/PairsTest.java
index c48e2d8..af0a2b4 100644
--- a/src/test/java/io/hexlet/pairs/PairsTest.java
+++ b/src/test/java/io/hexlet/pairs/PairsTest.java
@@ -1,6 +1,7 @@
package io.hexlet.pairs;
import static org.assertj.core.api.Assertions.assertThat;
+
import org.junit.jupiter.api.Test;
class PairsTest {