plugins {
    id 'org.jdrupes.vmoperator.java-library-conventions'
}

dependencies {
    implementation project(':org.jdrupes.vmoperator.manager.events')
    
    implementation 'org.jgrapes:org.jgrapes.webconsole.base:[2.1.0,3)'
    implementation 'org.jgrapes:org.jgrapes.webconsole.provider.vue:[1,2)'
    implementation 'org.jgrapes:org.jgrapes.webconsole.provider.jgwcvuecomponents:[1.2,2)'
    implementation 'org.jgrapes:org.jgrapes.webconsole.provider.chartjs:[1.2,2)'
    
}

apply plugin: 'com.github.node-gradle.node'

node {
    download = true
}

task extractDependencies(type: Copy) {
    from configurations.compileClasspath
        .findAll{ it.name.contains('.provider.')
            || it.name.contains('org.jgrapes.webconsole.base')
        }
        .collect{ zipTree (it) }
    exclude '*.class'
    into 'build/unpacked'
    duplicatesStrategy 'include'
  }

task compileTs(type: NodeTask) {
    dependsOn ':npmInstall'
    dependsOn extractDependencies
    inputs.dir project.file('src')
    inputs.file project.file('tsconfig.json')
    inputs.file project.file('rollup.config.mjs')
    outputs.dir project.file('build/generated/resources')
    script = file("${rootProject.rootDir}/node_modules/rollup/dist/bin/rollup")
    args = ["-c"]
}

sourceSets {
    main {
        resources {
            srcDir project.file('build/generated/resources')
        }
    }
}

processResources {
    dependsOn compileTs
}

eclipse {
    autoBuildTasks compileTs
}
