/*
 * Copyright 2016 - 2021 Draco, https://github.com/draco1023
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

plugins {
    id 'java-library'
    id 'io.github.sgtsilvio.gradle.maven-central-publishing' version '0.4.0'
}

def getBranchName() {
    providers.exec {
        commandLine("git", "branch", "--show-current")
    }.standardOutput.asText.get().trim()
}

ext {
    VERSION_NAME = 'poi-5' == getBranchName()? "${project.V}-poi5" : project.V
}

group = GROUP
version = VERSION_NAME

repositories {
    mavenLocal()
    jcenter()
    mavenCentral()
}

dependencies {
    api 'com.deepoove:poi-tl:1.9.1'
    api 'org.apache.poi:ooxml-schemas:1.4'
    api 'org.apache.commons:commons-lang3:3.10'
    api 'commons-io:commons-io:2.11.0'
    implementation 'net.sourceforge.cssparser:cssparser:0.9.29'
    implementation 'org.jsoup:jsoup:1.15.3'
    implementation 'net.sf.saxon:Saxon-HE:11.4'
    implementation 'de.rototor.snuggletex:snuggletex-core:1.3.0'
    implementation 'com.drewnoakes:metadata-extractor:2.19.0'
    implementation 'com.twelvemonkeys.imageio:imageio-batik:3.10.1'
    implementation 'org.apache.xmlgraphics:batik-rasterizer-ext:1.17'
    implementation 'com.twelvemonkeys.imageio:imageio-webp:3.10.1'
    implementation 'com.twelvemonkeys.imageio:imageio-pict:3.10.1'
    implementation 'com.twelvemonkeys.imageio:imageio-tiff:3.10.1'
    implementation 'com.twelvemonkeys.imageio:imageio-jpeg:3.10.1'
    implementation 'com.twelvemonkeys.imageio:imageio-bmp:3.10.1'

    compileOnly 'com.google.code.findbugs:jsr305:3.0.2'

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.2'
    testRuntimeOnly 'org.slf4j:slf4j-simple:1.7.7'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

test {
    useJUnitPlatform()
}

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
    options.fork = true
}

javadoc {
    options {
        encoding 'UTF-8'
        charSet 'UTF-8'
    }
}
javadoc.options.addBooleanOption('Xdoclint:none', true)

java {
    withSourcesJar()
    withJavadocJar()
}

publishing {
    publications {
        maven(MavenPublication) {
            from components.java
            groupId = GROUP
            artifactId = POM_ARTIFACT_ID
            version = VERSION_NAME
            pom {
                name = POM_NAME
                description = POM_DESCRIPTION
                url = POM_URL
                licenses {
                    license {
                        name = POM_LICENCE_NAME
                        url = POM_LICENCE_URL
                    }
                }
                developers {
                    developer {
                        id = POM_DEVELOPER_ID
                        name = POM_DEVELOPER_NAME
                        url = POM_DEVELOPER_URL
                    }
                }
                scm {
                    connection = POM_SCM_CONNECTION
                    developerConnection = POM_SCM_DEV_CONNECTION
                    url = POM_SCM_URL
                }
            }
        }
    }
}

signing {
    sign publishing.publications.maven
}