plugins {
    id 'java-library'
}

java {
    ext.javaSourceVer = project.hasProperty('javaSourceVer') ? JavaVersion.toVersion(project.getProperty('javaSourceVer')) : JavaVersion.VERSION_1_8
    ext.javaTargetVer = project.hasProperty('javaTargetVer') ? JavaVersion.toVersion(project.getProperty('javaTargetVer')) : JavaVersion.VERSION_1_8

    sourceCompatibility = ext.javaSourceVer
    targetCompatibility = ext.javaTargetVer
}

repositories {
    maven { url 'https://maven.google.com' }
    mavenCentral()
    maven { url 'https://kotlin.bintray.com/kotlinx' }
    jcenter()
}

dependencies {
    // https://mvnrepository.com/artifact/com.android.tools.build/manifest-merger
    implementation 'com.android.tools.build:manifest-merger:31.12.2'
}

sourceSets {
    main {
        java {
            srcDirs = ["src"]
        }
    }
}

jar {
    duplicatesStrategy = 'exclude'
    manifest {
        attributes 'Main-Class': 'com.xamarin.manifestmerger.Main'
    }
    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    } {
        // Exclude native jnidispatch content to simplify installer signing and notarization
        exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA', 'com/sun/jna/**/*jnidispatch*'
    }
    archiveFileName.set('manifestmerger.jar')
}