group 'nl.astraeus'
version '1.5.9'

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'findbugs'
apply plugin: 'maven-publish'

sourceSets {
    main.java.srcDirs += 'src'
    main.resources.srcDirs += 'src'

    test.java.srcDirs += 'test'
    test.resources.srcDirs += 'test'
}

sourceCompatibility = 1.5
targetCompatibility = 1.5

repositories {
    maven {
        url "http://nexus.astraeus.nl/nexus/content/groups/public"
    }
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'

    testCompile "org.slf4j:slf4j-simple:1.7.21"
    testCompile "com.h2database:h2:1.4.+"

    compile "nl.astraeus.template:very-simple-templates:1.3"
    compile "nl.astraeus.web:simple-web:0.3"
    compile "org.slf4j:slf4j-api:1.7.21"

    configurations.compile.exclude module: 'javax.servlet-api'
    configurations.compile.exclude module: 'slf4j-simple'
}

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "http://nexus.astraeus.nl/nexus/content/repositories/releases") {
                authentication(userName: nexusUsername, password: nexusPassword)
            }
            snapshotRepository(url: "http://nexus.astraeus.nl/nexus/content/repositories/snapshots") {
                authentication(userName: nexusUsername, password: nexusPassword)
            }
        }
    }
}

findbugs {
    ignoreFailures = true
}

javadoc {
    failOnError = false
}

task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives sourcesJar
    archives javadocJar
}

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

jar {
    from {
        configurations.compile.collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }
}

task fatJar(type: Jar) {
    manifest {
        attributes 'Implementation-Title': 'simple-jdbc-statistics',
                'Implementation-Version': version
    }
    baseName = project.name + '-nodep'
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
}

