apply plugin: 'war'
apply plugin: "maven-publish"
apply plugin: "signing"

repositories {
    mavenCentral()
}

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}


project.version "3.0.0-SNAPSHOT"
group "net.brutex.xservices"

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

publishing {
    publications {
        maven(MavenPublication) {
            from components.java
        }
    }
    repositories {

        maven {
            name = 'LocalRemote'
            def releasesRepoUrl = 'https://archiva.brutex.net/repository/internal/'
            def snapshotsRepoUrl = 'https://archiva.brutex.net/repository/snapshots/'
            url = project.version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
            allowInsecureProtocol = false
            credentials {
                username = mavenuser
                password = mavenpass
            }
        }

        maven {
                name = 'OSSRH'
                def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
                def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
                url = project.version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
                credentials {
                    username = ossrhUsername
                    password = ossrhPassword
                }
            }

        maven {
                    name = 'brutexGitea'
                    def releasesRepoUrl = 'https://source.brutex.net/api/packages/brutex/maven'
                    def snapshotsRepoUrl = 'https://source.brutex.net/api/packages/brutex/maven'
                    url = project.version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
                    allowInsecureProtocol = false
                    credentials {
                        username = mavenuser
                        password = mavenpass
                    }
                }
    }
}

tasks.register('createDist', Zip) {Zip t ->
    archiveBaseName = project.name
    archiveVersion = version
    archiveExtension = "zip"
    destinationDirectory = new File(project.buildDir, "/distribution/")
    from war.outputs.files
}

dependencies {
    compileOnly "jakarta.servlet:jakarta.servlet-api:6.0.0"

    implementation "jakarta.ws.rs:jakarta.ws.rs-api:4.0.0"
    //runtimeOnly "com.sun.ws.rs:"

    implementation "jakarta.xml.ws:jakarta.xml.ws-api:2.3.3"
    //runtimeOnly "com.sun.xml.ws:jaxws-rt:2.3.3"

    implementation "jakarta.xml.bind:jakarta.xml.bind-api:4.0.2"
    runtimeOnly "com.sun.xml.bind:jaxb-impl:4.0.2"

    implementation 'jakarta.jws:jakarta.jws-api:3.0.0'

    implementation 'org.apache.commons:commons-configuration2:2.10.1'
    implementation "org.apache.commons:commons-lang3:3.12.0"
    implementation "commons-net:commons-net:3.9.0"
    implementation "commons-beanutils:commons-beanutils:1.9.4"
    implementation "org.apache.httpcomponents:httpclient:4.5.14"
    implementation "org.apache.httpcomponents:fluent-hc:4.5.14"
    implementation "commons-io:commons-io:2.11.0"

    implementation "org.apache.ant:ant:1.10.13"
    implementation "org.apache.ant:ant-nodeps:1.8.1"
    implementation "org.apache.ant:ant-jsch:1.10.13"
    implementation "org.apache.ant:ant-commons-net:1.10.13"
    implementation "org.apache.ant:ant-javamail:1.10.13"
    implementation "org.apache.ant:ant-launcher:1.10.13"

    implementation "org.apache.commons:commons-jcs-core:2.2.1"

    implementation "org.quartz-scheduler:quartz:2.5.0-rc1"

    implementation "org.slf4j:slf4j-api:2.0.7"
    runtimeOnly "ch.qos.logback:logback-core:1.3.8"
    runtimeOnly "ch.qos.logback:logback-classic:1.3.8"
    //runtimeOnly "org.slf4j:slf4j-simple:2.0.7"

    implementation "org.apache.ws.commons.axiom:axiom:1.4.0"
    implementation "org.apache.ws.commons.axiom:axiom-impl:1.4.0"

    implementation 'org.apache.shiro:shiro-jakarta-ee:2.0.1'
    implementation "org.apache.shiro:shiro-web:2.0.1:jakarta"

    implementation "org.apache.cxf:cxf-rt-transports-http:4.0.4"
    implementation "org.apache.cxf:cxf-rt-databinding-aegis:4.0.4"

    runtimeOnly "org.apache.cxf:cxf-rt-transports-http:4.0.4"
    runtimeOnly "org.apache.cxf:cxf-rt-frontend-jaxrs:4.0.4"
    runtimeOnly "org.apache.cxf:cxf-rt-frontend-jaxws:4.0.4"
    runtimeOnly "org.apache.cxf:cxf-rt-security:4.0.4"

    implementation "rhino:js:1.7R2"

    implementation 'org.springframework:spring-core:6.1.10'
    implementation "org.springframework:spring-context:6.1.10"
    implementation "org.springframework:spring-web:6.1.10"

    implementation "com.h2database:h2:2.2.222"

    implementation fileTree(dir: "lib/", includes: ["*.jar"], excludes: ["serena.*.jar"])
    compileOnly fileTree(dir: "lib/", includes: ["serena.*.jar"])

    annotationProcessor "org.projectlombok:lombok:1.18.28"
    compileOnly "org.projectlombok:lombok:1.18.28"

}