/*
 *
 * Copyright (c) 2014-2020 Embedded Systems and Applications, TU Darmstadt.
 *
 * This file is part of TaPaSCo
 * (see https://github.com/esa-tu-darmstadt/tapasco).
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */

import com.netflix.gradle.plugins.deb.control.MultiArch

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Scala library project to get you started.
 * For more details take a look at the Scala plugin chapter in the Gradle
 * User Manual available at https://docs.gradle.org/5.2/userguide/scala_plugin.html
 */

plugins {
    // Apply the scala plugin to add support for Scala
    id 'scala'
    id 'application'
    // Netflix provided plug-in for OS packaging
    id "nebula.ospackage" version "8.3.0"
}

repositories {
    // Use mavenCentral for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    mavenCentral()
}

dependencies {
    // Use Scala 2.12 in our library project
    implementation 'org.scala-lang:scala-library:2.12.8'
    implementation 'org.scala-lang:scala-reflect:2.12.8'
    implementation 'org.scala-lang:scala-compiler:2.12.8'
    implementation 'com.typesafe.play:play-json_2.12:2.7.3'
    implementation 'org.slf4j:slf4j-api:1.7.26'
    implementation 'ch.qos.logback:logback-classic:1.2.3'
    implementation 'com.lihaoyi:fastparse_2.12:1.0.0'

    // Use Scalatest for testing our library
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.scalatest:scalatest_2.12:3.0.5'
    testImplementation 'org.scalacheck:scalacheck_2.12:1.14.0'

    // Need scala-xml at test runtime
    testRuntimeOnly 'org.scala-lang.modules:scala-xml_2.12:1.1.1'
}

application {
    mainClass.set('tapasco.Tapasco')
    applicationDefaultJvmArgs = ['-Xms512M', '-Xmx1536M', '-Xss1M']
}

ospackage {
    packageName = "tapasco"
    version = "2024"
    release = "01"
    license = "GNU Lesser General Public License v3.0"
    vendor = "Embedded Systems and Applications Group, TU Darmstadt"
    url = "https://github.com/esa-tu-darmstadt/tapasco"
    os = LINUX
    maintainer = "Embedded Systems and Applications Group, TU Darmstadt"

    into "/opt/tapasco"

    from("build/install/tapasco/bin"){
        into "bin"
        exclude "tapasco.bat"
    }

    from("build/install/tapasco/lib"){
        into "lib"
    }

    from("../vivado"){
        into "vivado"
    }

    from("../examples"){
        into "examples"
    }

    from("../boot"){
        into "boot"
    }

    from("../bin"){
        into "bin"
    }

    from("../os-package")

    from("../../runtime/platform/include"){
        into "runtime/platform/include"
        include "platform_caps.h"
        include "platform_global.h"
        include "platform_components.h"
    }

}

buildDeb {
    arch = "amd64"
    multiArch = MultiArch.FOREIGN
    requires("default-jre")
}

buildRpm {
    arch = X86_64
    requires("java-openjdk", "8.0", GREATER | EQUAL)
    requires("which")
}
