plugins {
    id 'org.springframework.boot' version '2.6.7'
    id 'io.spring.dependency-management' version '1.0.14.RELEASE'
    id 'java'
    id 'com.github.node-gradle.node' version '3.3.0'
}

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

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-data-redis'
    implementation 'com.vladmihalcea:hibernate-types-52:2.17.3'
    implementation 'org.springframework.kafka:spring-kafka'

    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'org.postgresql:postgresql'

    implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
    runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
    runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'

    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'org.springframework.security:spring-security-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

node {
    nodeModulesDir = file("$projectDir/front-end")
    version = '18.3.0'
    download = true
}

task npmBuild(type: NpmTask) {
    args = ['run', "build"]
}

task copyFrontEnd(type: Copy) {
    from "$projectDir/front-end/static"
    into 'build/resources/main/static/.'
}

task cleanFrontEnd(type: Delete) {
    delete "$projectDir/front-end/static", "$projectDir/front-end/node_modules"
}

//npmBuild.dependsOn npmInstall
//copyFrontEnd.dependsOn npmBuild
//compileJava.dependsOn copyFrontEnd
//
//clean.dependsOn cleanFrontEnd