spring-projects / spring-statemachine

Spring Statemachine is a framework for application developers to use state machine concepts with Spring.
1.52k stars 598 forks source link

The Gradle build file in the reference documentation seems ancient #1078

Open dtonhofer opened 1 year ago

dtonhofer commented 1 year ago

The Gradle build file shown here is old-school. It still uses apply plugin instead of the more recent plugins block for one and the version numbers are behind the curve.

https://docs.spring.io/spring-statemachine/docs/3.2.0/reference/#using-gradle

I have made it work thusly, though I'm not 100% sure

// See: https://docs.gradle.org/current/userguide/userguide.html
// See: https://docs.gradle.org/current/userguide/plugins.html#sec:applying_plugins_buildscript
// See: https://docs.spring.io/spring-statemachine/docs/3.2.0/reference/#using-gradle

buildscript {
    ext {
        // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot
        springBootVersion = '2.7.6'
    }
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

// See: https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block

plugins {
    id 'java'
    id 'eclipse'
    id 'org.springframework.boot' version '2.7.6'
    // https://plugins.gradle.org/plugin/io.spring.dependency-management
    id 'io.spring.dependency-management' version '1.1.0'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

repositories {
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}

ext {
    springStatemachineVersion = '3.2.0'
    springBootVersion = '2.7.6'
    springVersion = '5.3.24'
    logbackVersion = '1.4.5'
    sl4jVersion = '2.0.5'
}

java {
    sourceCompatibility = "16"
    targetCompatibility = "16"
}

dependencies {

    // ---
    // Logging and its implementation
    // ---

    // https://mvnrepository.com/artifact/org.slf4j/slf4j-api
    implementation group: 'org.slf4j', name: 'slf4j-api', version: "${sl4jVersion}"

    // https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
    // without this, there is no logging output
    runtimeOnly group: 'ch.qos.logback', name: 'logback-classic', version: "${logbackVersion}"

    // https://mvnrepository.com/artifact/ch.qos.logback/logback-core
    // without this, there are NoSuchMethod errors
    runtimeOnly group: 'ch.qos.logback', name: 'logback-core', version: "${logbackVersion}"

    // https://mvnrepository.com/artifact/org.springframework/spring-context
    implementation group: 'org.springframework', name: 'spring-context', version: "${springVersion}"

    // https://mvnrepository.com/artifact/org.springframework/spring-beans
    implementation group: 'org.springframework', name: 'spring-beans', version: "${springVersion}"

    // https://mvnrepository.com/artifact/org.springframework.statemachine/spring-statemachine-core
    implementation group: 'org.springframework.statemachine', name: 'spring-statemachine-core', version: "${springStatemachineVersion}"

    // https://mvnrepository.com/artifact/org.springframework.statemachine/spring-statemachine-autoconfigure
    implementation group: 'org.springframework.statemachine', name: 'spring-statemachine-autoconfigure', version: "${springStatemachineVersion}"

    // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter', version: "${springBootVersion}"

    // --- and testing ---

    // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test
    testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: "${springBootVersion}"

    // https://mvnrepository.com/artifact/org.springframework.statemachine/spring-statemachine-test
    testImplementation group: 'org.springframework.statemachine', name: 'spring-statemachine-test', version: "${springStatemachineVersion}"

}

dependencyManagement {
    imports {
        mavenBom "org.springframework.statemachine:spring-statemachine-bom:${springStatemachineVersion}"
    }
}