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

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 {
	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-web'
	//implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.1'
	implementation 'org.springframework.boot:spring-boot-starter-amqp'
	implementation 'commons-codec:commons-codec'
	implementation 'org.apache.commons:commons-exec:1.3'
	
	//runtimeOnly 'org.postgresql:postgresql'
	
	//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
}

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