plugins {
    id("maven")
    id 'org.jetbrains.kotlin.jvm'
    id 'maven-publish'
    id("org.jetbrains.dokka")
    id "com.vanniktech.maven.publish"
    id "com.github.johnrengelman.shadow" version "6.1.0"
}

def pluginVersion = "1.0.4"

apply plugin: "kotlin-kapt"


group = "de.jensklingenberg.cabret"
archivesBaseName = "cabret-compiler-plugin-native"
version = pluginVersion


install {
    repositories.mavenInstaller {
        pom.artifactId = archivesBaseName
    }
}

install{
    dependsOn(shadowJar)
}
repositories {
    mavenLocal()
}
compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib"
    compileOnly "org.jetbrains.kotlin:kotlin-compiler"
    compileOnly "com.google.auto.service:auto-service:1.0-rc7"
    kapt "com.google.auto.service:auto-service:1.0-rc7"
    implementation project(':cabret-compiler-runtime')
}


task fatJar(type: Jar) {
    manifest {
        attributes 'Implementation-Title': 'Gradle Jar File Example',
                'Implementation-Version': version,
                'Main-Class': 'de.jensklingenberg.cabret.NativeComponentRegistrar'
    }
    baseName = "cabret-compiler-plugin-native"
    version = pluginVersion

    from {
        configurations.compileOnly.collect { it.isDirectory() ? it : zipTree(it) }
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
    with jar
}


shadowJar {
    manifest {
        inheritFrom project.tasks.fatJar.manifest
    }
    baseName = "cabret-compiler-plugin-native"
    version = pluginVersion
    classifier = ""
}

//Install uploadarchives


build{
    dependsOn ':cabret-compiler-runtime:install'
    dependsOn(shadowJar)
    finalizedBy(publishToMavenLocal)
}



task JavadocsJar(type: Jar) {
    classifier = 'javadoc'
    from "$buildDir/javadoc"
}
