plugins {
	id 'org.springframework.boot' version '2.3.0.RELEASE'
	id 'io.spring.dependency-management' version '1.0.9.RELEASE'
	id 'java'
	id 'war'
}

apply plugin: 'project-report'

group = 'com.gaia3d'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

// gradle build -Pprofile=product (develop, test, local)
final String DEFAULT_PROFILE = 'local'

configurations {
	developmentOnly
	runtimeClasspath {
		extendsFrom developmentOnly
	}
	compileOnly {
		extendsFrom annotationProcessor
	}
}

repositories {
    maven {
        url "https://repo.osgeo.org/repository/release/"
    }
    maven {
        url "https://repo.osgeo.org/repository/Geoserver-releases/"
    }
	mavenCentral()
}

sourceSets {
    main {
        resources {
            if (!project.hasProperty('profile') || !profile) {
                println " ========== > default profile is local. "
                ext.profile = DEFAULT_PROFILE
            }

            if (profile == 'product') {
                println " ===========> profile file is ${profile}"
                println " ===========> copy from src/main/resources/product to src/main/resources"

                copy {
                    from("src/main/resources/product") {
                        include 'application.properties'
                        include 'mago3d.properties'
                        include 'logback-spring.xml'
                    }
                    into "src/main/resources"
                }
                exclude "**/develop/*"
            } else if (profile == 'develop') {
                println " ===========> profile file is ${profile}"
                println " ===========> copy from src/main/resources/develop to src/main/resources"

                copy {
                    from("src/main/resources/develop") {
                        include 'application.properties'
                        include 'mago3d.properties'
                        include 'logback-spring.xml'
                    }
                    into "src/main/resources"
                }
                exclude "**/product/*"
            } else {
                println " ===========> profile file is ${profile}"
                //srcDir "src/main/resources"
                exclude "**/product/*"
                exclude "**/develop/*"
            }
        }
    }
}

dependencies {
	implementation project(':common')

	implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.2'
	implementation 'org.springframework.boot:spring-boot-starter-amqp'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.springframework.boot:spring-boot-starter-quartz'

	implementation 'org.springframework.security:spring-security-core:5.2.1.RELEASE'

	implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:2.4.1'

	implementation 'org.apache.httpcomponents:httpclient'
	implementation 'org.apache.commons:commons-exec:1.3'
    implementation 'org.geotools:gt-shapefile:22.2'

    implementation 'org.geotools.xsd:gt-xsd-core:22.2'
    implementation 'org.geotools.xsd:gt-xsd-sld:22.2'
    implementation 'org.apache.commons:commons-compress:1.18'

	implementation 'org.modelmapper:modelmapper:2.3.6'

	runtimeOnly 'org.postgresql:postgresql'
    implementation 'org.postgresql:postgresql:42.2.14'
	
	//providedRuntime 'org.apache.tomcat.embed:tomcat-embed-jasper'
    providedCompile 'javax:javaee-api:8.0.1'
	providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
	
	testImplementation('org.springframework.boot:spring-boot-starter-test') {
		exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
	}
	testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

    compileOnly 'org.projectlombok:lombok:1.18.12'
    annotationProcessor 'org.projectlombok:lombok:1.18.12'
    testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
	testCompileOnly 'org.projectlombok:lombok:1.18.12'

    developmentOnly 'org.springframework.boot:spring-boot-devtools'
}

test {
	useJUnitPlatform()
	ignoreFailures = true
	exclude '**/*'
}

task wrapper(type: Wrapper) {
    gradleVersion = '6.5'
}
