buildscript {
	ext {
		portosProtocollazioneServiceName = 'portos-protocollazione-service'
		portosProtocollazioneServiceVersion = '2.0.0 SNAPSHOT'

		liquibaseVersion = '1.2.4'
		nodeVersion = '1.1.1'
		postgresSqlVersion = '42.0.0'
		springBootVersion = '1.5.2.RELEASE'
		sonarQubeVersion = '2.2'
		apacheCommonsCVS = '1.4'
	}
	
	repositories {
      	mavenCentral()
      	maven {
      		url "https://plugins.gradle.org/m2/"
    	} 
  	}

	dependencies {
		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
		classpath("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:${sonarQubeVersion}")
		classpath("com.moowork.gradle:gradle-node-plugin:${nodeVersion}")
		classpath("org.liquibase:liquibase-gradle-plugin:${liquibaseVersion}")
		classpath("org.postgresql:postgresql:${postgresSqlVersion}")
		classpath("org.apache.commons:commons-csv:${apacheCommonsCVS}")
	}
}

//apply from: "$rootDir/gradle/sonar.gradle"
apply from: "$rootDir/gradle/node.gradle"
//apply from: "$rootDir/gradle/jacoco.gradle"
apply from: "$rootDir/gradle/liquibase.gradle"

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
apply plugin: 'maven'

processResources {
	if (project.getProperties().containsKey('profile')) {
		println 'Profile: ' + project.property('profile')
	}
	
	filesMatching('application.properties') {
		filter org.apache.tools.ant.filters.ReplaceTokens, tokens: [                
			activeProfiles: project.getProperties().containsKey('profile') ? project.property('profile') : ''
      	]
   	}
}

clean {
	delete 'angular/dist'
	delete 'build'
}

war {
	archiveName = 'portos-protocollazione-service.war'
	baseName = portosProtocollazioneServiceName
	version = portosProtocollazioneServiceVersion
	webAppDirName = 'angular/dist'
}
war.dependsOn('appNpmBuild')

test {
	if (project.getProperties().containsKey('profile')) {
		systemProperties['spring.profiles.active'] = project.property('profile')
	}
	reports {
		junitXml.enabled = true
      	html.enabled = true
 	}             
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
	mavenCentral()
}

configurations {
	providedRuntime
}

dependencies {
	compile('org.springframework.boot:spring-boot-starter-web')
	compile('org.springframework.boot:spring-boot-starter-data-jpa')
	compile('org.springframework.boot:spring-boot-starter-security')
	compile("org.springframework.boot:spring-boot-devtools")
	compile('org.postgresql:postgresql')
	compile group: 'org.apache.cxf', name: 'cxf-rt-frontend-jaxws', version: '3.1.10'
	compile group: 'org.apache.cxf', name: 'cxf-rt-transports-http', version: '3.1.10'
	compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.2.12'
	compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.7.0'
	compile group: 'org.springframework.security', name: 'spring-security-test', version: '4.2.1.RELEASE'
	compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'
	compile group: 'com.querydsl', name: 'querydsl-core', version: '4.1.4'
	compile group: 'com.querydsl', name: 'querydsl-jpa', version: '4.1.4'
	compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.6.1'
	compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.6.1'
	compile group: 'org.apache.cxf', name: 'cxf-rt-frontend-jaxws', version: '3.1.10'
	compile group: 'org.apache.commons', name: 'commons-csv', version: '1.4'
	
	providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
		
	testCompile('org.springframework.boot:spring-boot-starter-test')
    testCompile("junit:junit")
    testCompile('org.springframework.security:spring-security-test');
}