/*
================================================================================
build2025.gradle
GENERATED ONLY ONCE
================================================================================
*/
plugins {
    // Apply the application plugin to add support for building a CLI application in Java.
    id 'application'
    id 'java'
    id 'eclipse'

    // Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
    id "org.jetbrains.kotlin.jvm" version "1.9.22"
    
    //Per poter usare qakfacadegui23-1.0 che usa Spring
    id 'org.springframework.boot' version '2.7.16'
    id 'io.spring.dependency-management' version '1.0.15.RELEASE'
    
    //Per poter usare javafx
    //id 'org.openjfx.javafxplugin' version '0.1.0'
}

version '1.0'
 

java {
    toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
kotlin {
  jvmToolchain {
    languageVersion.set(JavaLanguageVersion.of("17"))
  }
}

repositories {
    mavenCentral()
    flatDir {   dirs '../unibolibs'	 }
}

/*
javafx {
    version = "11"
    modules =  ["javafx.controls", "javafx.fxml", "javafx.web", "javafx.graphics"]
}
*/

dependencies {
    // Align versions of all Kotlin components
    implementation platform('org.jetbrains.kotlin:kotlin-bom')

    // Use the Kotlin JDK 8 standard library.
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'

    // This dependency is used by the application.
    implementation 'com.google.guava:guava:30.1.1-jre'

    // Use the Kotlin test library.
    testImplementation 'org.jetbrains.kotlin:kotlin-test'

    // Use the Kotlin JUnit integration.
    testImplementation "org.jetbrains.kotlin:kotlin-test-junit:1.9.22"

    /* COROUTINES ******************************************************************************* */
    // https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core
    implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: "$kotlinVersion"   //, ext: 'pom'
    // https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-jvm
    implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core-jvm', version: "$kotlinVersion"

	//SOCKET.IO  
    implementation group: 'javax.websocket', name: 'javax.websocket-api', version: '1.1'
    //javax.websocket api is only the specification
    implementation group: 'org.glassfish.tyrus.bundles', name: 'tyrus-standalone-client', version: '1.9'

	//HTTP
    implementation 'org.apache.httpcomponents:httpclient:4.5'

    /*  MQTT *******************************************************************************  */
    // https://mvnrepository.com/artifact/org.eclipse.paho/org.eclipse.paho.client.mqttv3
    implementation group: 'org.eclipse.paho', name: 'org.eclipse.paho.client.mqttv3', version: '1.2.5'

    /* JSON ********************************************************************************* */
    // https://mvnrepository.com/artifact/org.json/json
    //implementation group: 'org.json', name: 'json', version: '20220320'
    implementation 'com.googlecode.json-simple:json-simple:1.1.1'
    implementation group: 'org.json', name: 'json', version: '20180130'

    /* COAP ********************************************************************************* */
    // https://mvnrepository.com/artifact/org.eclipse.californium/californium-core
    implementation group: 'org.eclipse.californium', name: 'californium-core', version: '3.5.0'
    // https://mvnrepository.com/artifact/org.eclipse.californium/californium-proxy2
    implementation group: 'org.eclipse.californium', name: 'californium-proxy2', version: '3.5.0'

	//OkHttp library for websockets with Kotlin
	//implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.14.0'    
	implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.9.3' 
	// https://mvnrepository.com/artifact/com.squareup.okhttp3/mockwebserver
	testImplementation group: 'com.squareup.okhttp3', name: 'mockwebserver', version: '4.9.3'

    /* LOG4J ***************************************************************************** */    
   implementation 'ch.qos.logback:logback-classic:1.2.11'  //vs.1.5.7     1.2.11 (app1.log ok)     1.4.11

    /* HTTP ******************************************************************************** */
    // https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
    implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13'
    // https://mvnrepository.com/artifact/commons-io/commons-io
    implementation group: 'commons-io', name: 'commons-io', version: '2.11.0'

    //MONGODB
    // https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver
    implementation group: 'org.mongodb', name: 'mongo-java-driver', version: '3.12.14'

    /* AIMA ****************************************** */
 	//PLANNER  
    implementation name: 'unibo.planner23-1.0'
    // https://mvnrepository.com/artifact/com.googlecode.aima-java/aima-core
    implementation group: 'com.googlecode.aima-java', name: 'aima-core', version: '3.0.0'

    /* UNIBO *********************************************************************************/
    implementation name: 'uniboInterfaces'
    implementation name: '2p301'
	implementation name: 'unibo.qakactor23-5.0'
    implementation name: 'unibo.basicomm23-1.0'


    
    //USER libs for facades
    
}
	
sourceSets {
    main.java.srcDirs += 'src'
    main.java.srcDirs += 'src/main/java'
    main.java.srcDirs += 'src/main/kotlin'
    main.java.srcDirs += 'src/main/resources'
    test.java.srcDirs += 'src/main/java/test'		//test is specific
    test.java.srcDirs += 'src/main/kotlin/test'
}
  

eclipse {
    classpath {
        sourceSets -= [sourceSets.main, sourceSets.test]	
    }	
 }



application {
    //Define the main class for the application.
    mainClassName    = 'it.unibo.ctxcellonrasp.MainCtxcellonraspKt'
}
 
 jar {
    println("building jar")
    duplicatesStrategy(DuplicatesStrategy.EXCLUDE)  //per via di locgback.xml quando si usa spring
    from sourceSets.main.allSource
    from('./') {
      include '*.pl'
      include '*.json'
    }
    manifest {
        attributes 'Main-Class': "$mainClassName"
    }
}

task dovesiamo {
    println("projectDir= $projectDir")  
    println("buildDir  = $buildDir")    
}

distributions {
    main {
        distributionBaseName = 'cellonrasp'
        contents { 
             from './cellonrasp.pl'
             from './sysRules.pl'
             from './facadeConfig.json'
        }
    }
} 

task run0(type: JavaExec) {
    group = "Execution"
    description = "Run the main class with JavaExecTask"
    classpath = sourceSets.main.runtimeClasspath
    main = 'it.unibo.ctxcellonrasp.MainCtxcellonraspKt'
}

/*
//TODO
tasks.register('copyReport', Copy) {
	println("copyReport")
    from layout.buildDirectory.file("resources/logback.xml")
    into layout.buildDirectory.dir("toArchive")
}
*/
//gradlew run --warning-mode all
