plugins {
    id 'eclipse'
    id 'idea'
    id 'java-library'
    id 'maven-publish'
    id 'signing'
}

description="${project.name} build script"
group="io.github.fastily"
version="1.11.0"

repositories {
    mavenCentral()
}

dependencies {
    api "com.google.code.gson:gson:2.10.1"
    api "com.squareup.okhttp3:okhttp:4.11.0"
    api "com.squareup.okhttp3:okhttp-urlconnection:4.11.0"
    api 'org.slf4j:slf4j-api:2.0.7'

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.+'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.+'
    
    testImplementation "com.squareup.okhttp3:mockwebserver:4.11.0"
    testImplementation 'org.slf4j:slf4j-reload4j:2.0.7'
    testImplementation 'org.apache.logging.log4j:log4j-api:2.20.0'
}


tasks.named('test') {
    useJUnitPlatform()
}


java {
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11

    withJavadocJar()
    withSourcesJar()
}


javadoc {
    source = sourceSets.main.allJava
    classpath = configurations.compileClasspath

    options {
        jFlags '-Dhttp.agent=gradle-javadoc'
        setMemberLevel JavadocMemberLevel.PUBLIC
        setAuthor true

        links "https://docs.oracle.com/en/java/javase/17/docs/api/"
        //links "https://square.github.io/okio/1.x/okio/"
        //links "https://square.github.io/okhttp/3.x/okhttp/"
        links "https://www.javadoc.io/doc/com.google.code.gson/gson/2.10.1/"
        
        // setOutputLevel JavadocOutputLevel.VERBOSE
    }
}

wrapper {
    gradleVersion = '8.1.1'
}


publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java

            pom {
                name = 'jwiki'
                description = 'A library for effortlessly interacting with Wikipedia/MediaWiki'
                inceptionYear = '2014'
                url = 'https://github.com/fastily/jwiki'
                licenses {
                    license {
                        name = 'GNU General Public License, Version 3.0'
                        url = 'https://www.gnu.org/licenses/gpl-3.0.txt'
                    }
                }
                developers {
                    developer {
                        id = 'fastily'
                        name = 'Fastily'
                        email = 'fastily@users.noreply.github.com'
                    }
                }
                scm {
                    connection = 'scm:git:https://github.com/fastily/jwiki.git'
                    developerConnection = 'scm:git:ssh://github.com/fastily/jwiki.git'
                    url = 'https://github.com/fastily/jwiki'
                }
            }
        }
    }

    repositories {
        maven {
            url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"

            credentials {
                username project.hasProperty("ossrhUsername") ? project.properties["ossrhUsername"] : System.getenv('ossrhUsername')
                password project.hasProperty("ossrhPassword") ? project.properties["ossrhPassword"] : System.getenv('ossrhPassword')
            }
        }
    }
}


signing {
    sign publishing.publications.mavenJava
}