apply plugin: 'findbugs'
apply plugin: 'checkstyle'
apply plugin: 'application'

sourceCompatibility = 1.8

mainClassName = "hirs.provisioner.ProvisionerApplication"

dependencies {
    compile project(':TPM_Utils')
    compile project(':HIRS_Structs')
    compile project(':HIRS_Utils')
    compile libs.spring_web
    compile libs.log_bridge
    compile libs.commons_lang

    compileOnly libs.checkstyle
    compileOnly libs.findbugs

    testCompile libs.testng
    testCompile libs.mockito
    testCompile libs.powermock
    testCompile libs.spring_test
    testCompile libs.checkstyle
    testCompile libs.findbugs
    testCompile libs.commons_lang
}

copyVersion.dependsOn compileJava
jar.dependsOn copyVersion

ext.configDir = new File(projectDir, 'config')
ext.checkstyleConfigDir = "$configDir/checkstyle"
checkstyle {
    toolVersion = '5.7'
    configFile = checkstyleConfigFile
    configProperties.put('basedir', checkstyleConfigDir)
    ignoreFailures = false
    showViolations = true
}

ext.findbugsConfigDir = "$configDir/findbugs"

findbugs {
    toolVersion = '3.0.0'
    ignoreFailures = false
    effort = 'max'
}

publishing {
    publications {
        maven(MavenPublication) {
            artifactId 'hirs-provisioner'
            artifact jar
            pom.withXml {
                def dependenciesNode = asNode().appendNode('dependencies')

                configurations.runtime.allDependencies.each {
                    if (it.group != null && it.name != null) {
                        def dependencyNode = dependenciesNode.appendNode('dependency')
                        dependencyNode.appendNode('groupId', it.group)
                        dependencyNode.appendNode('artifactId', it.name)
                        dependencyNode.appendNode('version', it.version)

                        if (it.excludeRules.size() > 0) {
                            def exclusionsNode = dependencyNode.appendNode('exclusions')
                            it.excludeRules.each { rule ->
                                def exclusionNode = exclusionsNode.appendNode('exclusion')
                                exclusionNode.appendNode('groupId', rule.group)
                                exclusionNode.appendNode('artifactId', rule.module)
                            }
                        }
                    }
                }
            }
        }
    }
}
