plugins {
    id 'org.springframework.boot' version '3.3.1'
    id 'io.spring.dependency-management' version '1.1.5'
    id 'java'
    id 'org.flywaydb.flyway' version '10.15.2'
    id 'io.freefair.aspectj.post-compile-weaving' version '8.6'
    id 'com.github.ben-manes.versions' version '0.51.0'
}

group = 'cz.forgottenempire'
version = '1.4.1'
sourceCompatibility = '17'

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

tasks.register('copyWebApp', Copy) {
    dependsOn(':frontend:appNpmBuild')

    from "$rootDir/frontend/build"
    into "$rootDir/backend/build/resources/main/static/."
}

compileJava.dependsOn copyWebApp
bootJar.dependsOn copyWebApp
resolveMainClassName.dependsOn copyWebApp
jar.dependsOn copyWebApp

dependencies {
    runtimeOnly project(':frontend')

    implementation group: 'org.aspectj', name: 'aspectjrt', version: '1.9.22.1'
    implementation group: 'org.springframework', name: 'spring-aspects', version: '6.1.10'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop', version: '3.3.1'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '3.3.1'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '3.3.1'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '3.3.1'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation', version: '3.3.1'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-cache', version: '3.3.1'
    implementation group: 'commons-io', name: 'commons-io', version: '2.16.1'
    implementation group: 'com.auth0', name: 'java-jwt', version: '4.4.0'
    implementation group: 'com.ibasco.agql', name: 'agql-source-query', version: '1.2.2'
    implementation group: 'org.freemarker', name: 'freemarker', version: '2.3.33'
    implementation group: 'org.springframework', name: 'spring-context-support', version: '6.1.10'
    implementation group: 'com.google.guava', name: 'guava', version: '33.2.1-jre'
    implementation group: 'org.mapstruct', name: 'mapstruct', version: '1.6.0.Beta2'
    implementation group: 'org.flywaydb', name: 'flyway-core', version: '10.15.2'
    implementation group: 'org.jsoup', name: 'jsoup', version: '1.17.2'
    implementation group: 'org.flywaydb', name: 'flyway-mysql', version: '10.15.2'

    compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.34'

    runtimeOnly group: 'com.mysql', name: 'mysql-connector-j', version: '9.0.0'

    aspect group: 'org.springframework', name: 'spring-aspects', version: '6.1.10'

    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
    annotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.34'
    annotationProcessor 'org.mapstruct:mapstruct-processor:1.6.0.Beta2'

    testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.26.0'
    testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '3.3.1'
    testImplementation group: 'org.springframework.security', name: 'spring-security-test', version: '6.3.1'
}

test {
    useJUnitPlatform()
}
