import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'spring-boot'<% if(!skipClient) { %>
apply plugin: 'com.moowork.node'
apply plugin: 'com.moowork.gulp'
<% } %>

ext {
    logbackLoglevel = "INFO"
}

dependencies {

}

def profiles = 'prod'
if (project.hasProperty('no-liquibase')) {
    profiles += ',no-liquibase'
}

if (project.hasProperty('swagger')) {
    profiles += ',swagger'
}

bootRun {
    args = []
}
<% if (!skipClient) { %>
task gulpBuildWithOpts(type: GulpTask) {
    args = ["build", "--no-notification"]
}

war {
    webAppDirName = '<%= CLIENT_DIST_DIR %>'
}<% } %>

processResources {
    filesMatching('**/logback-spring.xml') {
        filter {
            it.replace('#logback.loglevel#', logbackLoglevel)
        }
    }
    <%_ if (applicationType === 'monolith') { _%>
    filesMatching('**/application.yml') {
    <%_ } _%>
    <%_ if (applicationType === 'microservice' || applicationType === 'gateway' || applicationType === 'uaa') { _%>
    filesMatching('**/bootstrap.yml') {
    <%_ } _%>
        filter {
            it.replace('#spring.profiles.active#', profiles)
        }
    }
}

<% if (!skipClient) { %>
gulpBuildWithOpts.dependsOn 'npmInstall'
gulpBuildWithOpts.dependsOn 'bower'
processResources.dependsOn gulpBuildWithOpts
test.dependsOn gulp_test
bootRun.dependsOn gulp_test<% } %>
