apply plugin: 'osgi'
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'

sourceSets {
    acceptanceTest {
        java {
            srcDir 'java'
        }
        resources {
            srcDir 'resources'
        }
    }
    test {
        java {
            srcDirs = ['src/test/java', 'src/acceptanceTest/java']
        }
    }
}

dependencies {
    compile "it.unimi.dsi:fastutil:$fastutilVersion"
    compile "com.lmax:disruptor:$disruptorVersion"
    compile "io.protostuff:protostuff-uberjar:$protostuffVersion"
    compile "io.netty:netty-buffer:$nettyVersion"
    compile "net.bytebuddy:byte-buddy:$byteBuddyVersion"
    compile "com.github.stephenc.high-scale-lib:high-scale-lib:$highScaleLibVersion"

    testCompile project(":reveno-test-model")

    acceptanceTestCompile project(":reveno-test-model")
    acceptanceTestCompile "com.google.guava:guava:$guavaVersion"
    acceptanceTestCompile "junit:junit:$junitVersion"
    acceptanceTestCompile "org.easymock:easymock:$easymockVersion"
}

jar {
    manifest {
        name = 'org.reveno.reveno-core'
        instruction 'Bundle-Vendor', 'Reveno'
        instruction 'Bundle-Description', 'Reveno: high-performance event-sourcing framework'
        instruction 'Bundle-DocURL', 'https://reveno.org'
    }
}

task fooJar(type: Jar) {
    manifest = osgiManifest {
        instruction 'Bundle-Vendor', 'Reveno'
    }
}

task sourcesJar(type: Jar) {
    archiveClassifier = 'sources'
    from sourceSets.main.allJava
}

task javadocJar(type: Jar) {
    archiveClassifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives sourcesJar, javadocJar
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            groupId 'org.reveno'
            artifactId 'reveno-core'
            from components.java

            artifact sourcesJar
            artifact javadocJar

            pom {
                name = 'Reveno Core'
                packaging = 'jar'
                description = 'Reveno framework core engine.'
                url = 'https://reveno.org'

                scm {
                    connection = 'scm:git:https://github.com/dmart28/reveno.git'
                    developerConnection = 'scm:git:git@github.com:dmart28/reveno.git'
                    url = 'https://github.com/dmart28/reveno'
                }

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

                developers {
                    developer {
                        id = 'dmart28'
                        name = 'Artem Dmitriev'
                        email = 'me@tema.im'
                    }
                }
            }
        }
    }
    repositories {
        maven {
            def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
            def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
            url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
            credentials {
                username = "$ossrhUsername"
                password = "$ossrhPassword"
            }
        }
    }
}

signing {
    sign publishing.publications.mavenJava
}