plugins {
    id 'java'
    id 'maven-publish'
    id 'application'
}

base.archivesName = 'gadgetbridge-daogenerator'

dependencies {
    // https://codeberg.org/Freeyourgadget/greenDao
    //implementation 'com.github.Freeyourgadget:greendao:1998d7cd2d21f662c6044f6ccf3b3a251bbad341'
    // As of 2025-06-19, this is bundled directly in the repository due to jitpack build issues

    implementation 'org.freemarker:freemarker:2.3.23'
}

sourceSets {
    main {
        java {
            srcDir 'src'
        }
        resources {
            srcDir 'src-template'
        }
    }
}

application.mainClass = "nodomain.freeyourgadget.gadgetbridge.daogen.GBDaoGenerator"

tasks.register('genSources', JavaExec) {
    inputs.dir(file("src"))
    outputs.dir(project.rootProject.file("app/build/generated/sources/gbdao"))

    mainClass = application.mainClass
    classpath = sourceSets.main.runtimeClasspath
    workingDir = '../'
}

artifacts {
    archives jar
}

java {
    // setting sourceCompatibility and targetCompatibility isn't required because this module
    // ships no complied code
    toolchain.languageVersion = JavaLanguageVersion.of(21)
}

tasks.named("distTar") {
    duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

tasks.named("distZip") {
    duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
