plugins {
    id 'java-library'
    id 'signing'
    id 'maven-publish'
    id 'com.gradleup.shadow' version '8.3.5'
}

group = 'software.amazon.s3tables'
version = '0.1.8'

// Override main and test code location, as the Java plugin default
// project layout is 'src/main/java' and 'src/test/java'.
sourceSets {
    main {
        java {
            srcDir 'src'
        }
        resources {
            srcDir 'resources'
        }
    }
    test {
        java {
            srcDir 'src'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    testImplementation libs.junit.jupiter
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

    // Pin Caffeine to 2.9.3, as 3.0 dropped compatibility with JDK8
    implementation 'com.github.ben-manes.caffeine:caffeine:2.9.3'
    implementation 'org.apache.commons:commons-configuration2:2.11.0'
    // Pin Iceberg to 1.6.x, as 1.7.0 dropped compatibility with JDK8
    implementation 'org.apache.iceberg:iceberg-api:1.6.1'
    implementation 'org.apache.iceberg:iceberg-aws:1.6.1'
    implementation 'org.apache.iceberg:iceberg-bundled-guava:1.6.1'
    implementation 'org.apache.iceberg:iceberg-common:1.6.1'
    implementation 'org.apache.iceberg:iceberg-core:1.6.1'
    implementation 'software.amazon.awssdk:apache-client:2.29.26'
    implementation 'software.amazon.awssdk:aws-core:2.29.26'
    implementation 'software.amazon.awssdk:dynamodb:2.29.26'
    implementation 'software.amazon.awssdk:glue:2.29.26'
    implementation 'software.amazon.awssdk:http-client-spi:2.29.26'
    implementation 'software.amazon.awssdk:kms:2.29.26'
    implementation 'software.amazon.awssdk:s3:2.29.26'
    implementation 'software.amazon.awssdk:sdk-core:2.29.26'
    implementation 'software.amazon.awssdk:sts:2.29.26'
    implementation 'software.amazon.awssdk:url-connection-client:2.29.26'
    implementation 'software.amazon.awssdk:s3tables:2.29.26'

    testImplementation 'org.assertj:assertj-core:3.26.3'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.3'
    // Pin Mockito to 4.11.x, as 5.0 dropped compatibility with JDK8
    testImplementation 'org.mockito:mockito-core:4.11.0'
    testImplementation 'org.mockito:mockito-junit-jupiter:4.11.0'
    testImplementation 'org.mockito:mockito-inline:4.11.0'
}

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(8)
    }
    withSourcesJar()
    withJavadocJar()
}

test {
    useJUnitPlatform()
}

publishing {
    publications {
        maven(MavenPublication) {
            from components.java
            pom {
                name = 'Amazon S3 Tables Catalog for Apache Iceberg'
                description = 'Amazon S3 Tables Catalog for Apache Iceberg.'
                url = 'https://github.com/awslabs/s3-tables-catalog'
                inceptionYear = '2024'
                scm{
                    url = "https://github.com/awslabs/s3-tables-catalog/tree/main"
                    connection = "scm:git:ssh://git@github.com:awslabs/s3-tables-catalog.git"
                    developerConnection = "scm:git:ssh://git@github.com:awslabs/s3-tables-catalog.git"
                }

                licenses {
                    license {
                        name = 'The Apache License, Version 2.0'
                        url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
                        distribution = 'repo'
                    }
                }

                developers {
                    developer {
                        organization = "Amazon Web Services"
                        organizationUrl = "https://aws.amazon.com"
                    }
                }
            }
        }
    }
    repositories {
        maven {
            url = 'https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/'
            credentials(PasswordCredentials)
        }
    }
}

signing {
    sign publishing.publications.maven
}