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

group = 'org.gradle.sample'
version = '1.0'

dependencies {
   compile 'commons-collections:commons-collections:3.2.2'
}

repositories {
    mavenCentral()
}

task sourceJar(type: Jar) {
    from sourceSets.main.allJava
}

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

            artifact sourceJar {
                classifier "sources"
            }
        }
    }
}

publishing {
    repositories {
        maven {
            def releasesRepoUrl = "$buildDir/repos/releases"
            def snapshotsRepoUrl = "$buildDir/repos/snapshots"
            url project.hasProperty("release") ? releasesRepoUrl : snapshotsRepoUrl
            url version.endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl
        }
    }
}
