plugins {
    id 'brouter.application-conventions'
}

application {
    mainClass.set('btools.server.BRouter')

    jar {
        manifest {
            attributes "Main-Class": getMainClass(), "Implementation-Version": project.version
        }
    }

    task fatJar(type: Jar) {
        archiveFileName = 'brouter-' + project.version + '-all.jar'

        manifest {
            attributes "Main-Class": getMainClass(), "Implementation-Version": project.version
        }
        archiveClassifier = 'all'
        dependsOn configurations.runtimeClasspath
        from {
            configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
        } {
            exclude "META-INF/*.SF"
            exclude "META-INF/*.DSA"
            exclude "META-INF/*.RSA"
        }
        with jar
    }
}

distZip {
    dependsOn fatJar
    if (file('../local.properties').exists()) dependsOn (':brouter-routing-app:assemble')
    archiveFileName = 'brouter-' + project.version + '.zip'
}

distributions {
    main {

        contents {
            exclude('**/brouter-codec*.jar')
            exclude('**/brouter-core*.jar')
            exclude('**/brouter-expressions*.jar')
            exclude('**/brouter-map-creator*.jar')
            exclude('**/brouter-mapaccess*.jar')
            exclude('**/brouter-server*.jar')
            exclude('**/brouter-util*.jar')
            exclude('**/brouter-server')
            exclude('**/brouter-server.bat')
            exclude('**/all.brf')
            exclude('**/dummy.brf')
            exclude('**/softaccess.brf')
            from ('../misc') {
                include 'readmes/*'
                include 'readmes/osmand/*'
                include 'profiles2/*'
            }
            from ('../brouter-routing-app/build/outputs/apk/release') {
                include '*.apk'
            }
             from ('../brouter-server/build/libs') {
                include 'brouter-*-all.jar'
            }
        }
    }
}

dependencies {
    implementation project(':brouter-codec')
    implementation project(':brouter-core')
    implementation project(':brouter-expressions')
    implementation project(':brouter-map-creator')
    implementation project(':brouter-mapaccess')
    implementation project(':brouter-util')

    testImplementation 'org.json:json:20180813'
}
