apply plugin: 'maven-publish'
apply plugin: 'com.gorylenko.gradle-git-properties'

gitProperties {
    dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
    keys = ['git.commit.id', 'git.commit.time']
}

bootRepackage {
    withJarTask = 'jar'
}

//Make sure that fat jar is built before uploading
project.tasks.findAll { it.name.startsWith('publish') || it.name == 'bintrayUpload' }*.dependsOn bootRepackage

publishing {
    repositories {
        maven {
            url getProperty('mavenRepoUrl')
            credentials {
                username getProperty('mavenUser')
                password getProperty('mavenPassword')
            }
        }
    }
    publications {
        mavenJava(MavenPublication) {
            artifactId project.name
            from components.java
            pom.withXml {
                //Remove dependencies - everything is embedded in JAR created by Spring Boot
                asNode().dependencyManagement.replaceNode { null }
                asNode().dependencies.replaceNode{ null }
            }
        }
    }
}
