plugins {
    id 'java'
    id 'io.quarkus'
    id 'maven-publish'  // [Maven] Publish - https://docs.gradle.org/current/userguide/publishing_maven.html
}

repositories {
    maven { url='https://maven.doap.fr/repository/maven-all/' }
    mavenCentral()
    mavenLocal()
}

dependencies {
    implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
    implementation 'io.quarkus:quarkus-rest'
    implementation 'io.quarkus:quarkus-rest-jackson'
    implementation 'io.quarkus:quarkus-oidc'
    implementation 'io.quarkus:quarkus-oidc-client'
    implementation 'io.quarkus:quarkus-arc'

    implementation 'io.quarkus:quarkus-rest-client'
    implementation 'io.quarkus:quarkus-rest-client-oidc-token-propagation'
//    implementation 'io.quarkus:quarkus-rest-client-jackson'


    implementation 'org.eclipse.microprofile.rest.client:microprofile-rest-client-api:4.0'

    testImplementation 'io.quarkus:quarkus-junit5'
    testImplementation 'io.rest-assured:rest-assured'
}

group 'fr.doap.qodoclient'
version '1.0.0-SNAPSHOT'

java {
    sourceCompatibility = JavaVersion.VERSION_21
    targetCompatibility = JavaVersion.VERSION_21
}

test {
    systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager"
}
compileJava {
    options.encoding = 'UTF-8'
    options.compilerArgs << '-parameters'
}

compileTestJava {
    options.encoding = 'UTF-8'
}

// [Maven Publish] - https://docs.gradle.org/current/userguide/publishing_maven.html
publishing {
    publications {
        maven(MavenPublication) {
            from components.java
        }
    }
    repositories {
        maven {
            if ((System.getenv('MAVEN_USERNAME') == null) || (System.getenv('MAVEN_PASSWORD') == null)) {
                throw new GradleException("You must define the Windows Environment variables MAVEN_USERNAME and MAVEN_PASSWORD to publish to the repository")
            }

            def releasesRepoUrl = "https://maven.doap.fr/repository/maven-releases/"
            def snapshotsRepoUrl = "https://maven.doap.fr/repository/maven-snapshots/"
            url = version.endsWith('-SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl

            credentials {
                username System.getenv('MAVEN_USERNAME')
                password System.getenv('MAVEN_PASSWORD')
            }
        }
    }
}