/*
 * This file was generated by the Gradle 'init' task.
 */

plugins {
    id 'java'
    id 'distribution'    
}

def localBuildVersion = project.hasProperty("buildVersion") ? buildVersion : "2.0.0.0"

group = 'com.amazon.redshift'
version = localBuildVersion
description = 'Redshift JDBC Driver - JDBC 4.2'
sourceCompatibility = '1.8'

repositories {
    flatDir {
        dirs 'lib'
    }
    mavenLocal()
    maven {
        url = uri('https://repo.maven.apache.org/maven2')
    }
}

dependencies {

    def withoutjmespathSupport = { 
        exclude group: 'com.amazonaws', module: 'jmespath-java' 
        exclude group: 'software.amazon.ion', module: 'ion-java'
    }
    def withoutslf4jSupport = { exclude group: 'org.slf4j', module: 'slf4j-api' }
    
    implementation 'com.amazonaws:aws-java-sdk-redshift:1.12.731', withoutjmespathSupport
    implementation 'com.amazonaws:aws-java-sdk-sts:1.12.731', withoutjmespathSupport
    implementation 'com.amazonaws:aws-java-sdk-redshiftserverless:1.12.731', withoutjmespathSupport
    implementation 'org.apache.httpcomponents:httpclient:4.5.14'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.16.0'
    implementation 'com.fasterxml.jackson.core:jackson-core:2.16.0'
    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.16.0'
    implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.16.0'
    implementation 'commons-codec:commons-codec:1.15'
    implementation 'com.amazonaws:aws-java-sdk-ssooidc:1.12.731', withoutjmespathSupport
    implementation 'org.jsoup:jsoup:1.16.1'

    compileOnly 'com.ongres.scram:client:2.1'
    compileOnly 'com.github.waffle:waffle-jna:1.9.1', withoutslf4jSupport
    compileOnly 'org.osgi:org.osgi.enterprise:4.2.0'
    compileOnly 'org.osgi:org.osgi.core:4.3.1'
    
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.2'
    testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.6.2'
    testImplementation 'org.junit.jupiter:junit-jupiter-params:5.6.2'
    testImplementation 'se.jiderhamn:classloader-leak-test-framework:1.1.1'
    testImplementation 'org.hamcrest:hamcrest-library:1.3'
    testImplementation 'com.amazonaws:aws-java-sdk-ssooidc:1.12.731', withoutjmespathSupport
    testImplementation 'org.mockito:mockito-core:4.6.1'
}


configurations.all {
}

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

processResources {
    filesMatching('redshift_jdbc_driver.properties') {
        expand project.properties
    }
}

jar {
    manifest {
        attributes("Automatic-Module-Name": 'com.amazon.redshift.jdbc')
        attributes("Main-Class": "com.amazon.redshift.util.RedshiftJDBCMain")
        attributes("Specification-Title": "JDBC")
        attributes("Specification-Version": "4.2")
        attributes("Specification-Vendor": "Oracle Corporation")
        attributes("Class-Path": configurations.runtimeClasspath.collect { it.getName() }.join(' '))
    }
}

distributions {
    main {
        distributionBaseName = project.name.toLowerCase()
        contents {
            into('/') { // Copy runnable jar into the distribution archive
                from jar
                from configurations.runtimeClasspath
            }
        }
    }
}

java {
	withJavadocJar()
}

javadoc {
    // Exclude internal public classes
    exclude 'com/amazon/redshift/core/**'
    exclude 'com/amazon/redshift/fastpath/**'
    exclude 'com/amazon/redshift/jre7/sasl/**'
    exclude 'com/amazon/redshift/largeobject/**'
    exclude 'com/amazon/redshift/osgi/**'
    exclude 'com/amazon/redshift/replication/**'
    exclude 'com/amazon/redshift/plugin/**'
    exclude 'com/amazon/redshift/geometric/**'
    exclude 'com/amazon/redshift/util/**'
    exclude 'com/amazon/redshift/translation/**'
    exclude 'com/amazon/redshift/ds/common/**'
    exclude 'com/amazon/redshift/gss/**'
    exclude 'com/amazon/redshift/hostchooser/**'
    exclude 'com/amazon/redshift/httpclient/log/**'
    exclude 'com/amazon/redshift/logger/**'
		exclude 'com/amazon/redshift/sspi/**'    
		exclude 'com/amazon/redshift/ssl/**'    
		exclude 'com/amazon/redshift/jdbc2/**'    
		exclude 'com/amazon/redshift/jdbc3/**'    
    
    // Exclude internal public interfaces/classes
    exclude 'com/amazon/redshift/CredentialsHolder*'
    exclude 'com/amazon/redshift/IPlugin*'
    exclude 'com/amazon/redshift/INativePlugin*'
		exclude 'com/amazon/redshift/jdbc/AbstractBlobClob*'
		exclude 'com/amazon/redshift/jdbc/BatchResultHandler*'    
		exclude 'com/amazon/redshift/jdbc/EscapedFunctions*'    
		exclude 'com/amazon/redshift/jdbc/EscapedFunctions2*'    
		exclude 'com/amazon/redshift/jdbc/FieldMetadata*'    
		exclude 'com/amazon/redshift/jdbc/RedshiftBlob*'    
		exclude 'com/amazon/redshift/jdbc/RedshiftClob*'    
		exclude 'com/amazon/redshift/jdbc/RedshiftArray*'    
		exclude 'com/amazon/redshift/jdbc/TypeInfoCache*'    
		exclude 'com/amazon/redshift/jdbc/UUIDArrayAssistant*'    
		exclude 'com/amazon/redshift/jdbc/RedshiftSQLXML*'    
    
    failOnError = false
    maxMemory = "2G"
    options.encoding = "UTF-8"
}





