plugins {
    id 'java-library'
}

final String projectDir = "${project.rootDir}/${project.parent.parent.parent.name}/" + \
        "${project.parent.parent.name}/" + \
        "${project.parent.name}"
final String buildDirectory="${projectDir}/${project.name}/build/classes/java/main/lib"
final String nativeObjects="${projectDir}/${project.name}/build/lib"
final String jarOutput="${projectDir}/${project.name}/build/libs"
final String examples="${projectDir}/${project.parent.name}-examples/libs"

tasks.register("copyBinaries", Copy) {
    from "${nativeObjects}"
    into "${buildDirectory}"
}

tasks.register("copyToExamples", Copy) {
    from "${jarOutput}"
    into "${examples}"
}

jar { // assemble jar options [java -jar]
    archiveFileName = "${project.name}-${system}.jar"
    manifest {
        attributes 'Project': "${project.name}-${system}",
                'Implementation-Version': "${version}",
                'Automatic-Module-Name': "${project.name.replace("-", ".")}",
                'Created-by': JavaVersion.current()
    }
}