//
// This file is to be applied to every subproject.
//

apply plugin: 'java'
apply plugin: 'maven'

//String jmeVersion = '3.0.10'
//String jmeVersion = rootProject.version;

String mavenGroupId = 'com.jme3'
String mavenVersion = jmeVersion + '-SNAPSHOT'

sourceCompatibility = '1.5'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

repositories {
    mavenCentral();
    maven{
        url "http://nifty-gui.sourceforge.net/nifty-maven-repo"
    }
    // You may define additional repositories, or even remove "mavenCentral()".
    // Read more about repositories here:
    //   http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}

dependencies {
    // Adding dependencies here will add the dependencies to each subproject.
    testCompile group: 'junit', name: 'junit', version: '4.10'
}

String mavenArtifactId = name

group = mavenGroupId
version = mavenVersion

//jar.doFirst{
//    manifest {
//        attributes('Manifest-Version'       : '1.0',
//                'Created-By'             : vendor,
//                'Specification-Title'    : appName,
//                'Specification-Version'  : version,
//                'Specification-Vendor'   : vendor,
//                'Implementation-Title'   : appName,
//                'Implementation-Version' : version,
//                'Implementation-Vendor'  : vendor,
//                'Main-Class'             : getProperty('mainClass'),
//                'Class-Path'             : configurations.compile.collect { 'lib/' + it.getName() }.join(' ') 
//        )
//    }
//}

task sourcesJar(type: Jar, dependsOn: classes, description: 'Creates a jar from the source files.') {
    classifier = 'sources'
    from sourceSets*.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc, description: 'Creates a jar from the javadoc files.') {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives jar
    archives sourcesJar
//    archives javadocJar
}

configure(install.repositories.mavenInstaller) {
    pom.project {
        groupId = mavenGroupId
        artifactId = mavenArtifactId
        version = mavenVersion
    }
}

task createFolders(description: 'Creates the source folders if they do not exist.') doLast {
//    sourceSets*.allSource*.srcDirs*.each { File srcDir ->
//        if (!srcDir.isDirectory()) {
//            println "Creating source folder: ${srcDir}"
//            srcDir.mkdirs()
//        }
//    }
}
