apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'javadocHotfix'
apply plugin: 'eclipse-wtp'
apply plugin: 'propdeps'
apply plugin: 'propdeps-idea'
apply plugin: 'propdeps-eclipse'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'checkstyle'
apply from: IDE_GRADLE

group = 'org.springframework.session'

sourceCompatibility = 1.5
targetCompatibility = 1.5

ext.springIoVersion = project.hasProperty('platformVersion') ? platformVersion : 'Brussels-BUILD-SNAPSHOT'

ext.spockDependencies = [
		dependencies.create("org.spockframework:spock-core:$spockVersion") {
			exclude group: 'junit', module: 'junit-dep'
		}
]

ext.gebDependencies = spockDependencies + [
		"org.seleniumhq.selenium:selenium-htmlunit-driver:$seleniumVersion",
		"org.gebish:geb-spock:$gebVersion",
		"org.codehaus.groovy:groovy:$groovyVersion"
]

ext.jstlDependencies = [
		"javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:$jstlVersion",
		"org.apache.taglibs:taglibs-standard-jstlel:1.2.1"
]

repositories {
	mavenCentral()
	maven { url 'https://repo.spring.io/libs-snapshot' }
}

configurations.all {
	resolutionStrategy.eachDependency { DependencyResolveDetails details ->
			if (details.requested.group == 'org.springframework') {
				details.useVersion springVersion
			}
	}
}
// Integration test setup
configurations {
	integrationTestCompile {
		extendsFrom testCompile, optional, provided
	}
	integrationTestRuntime {
		extendsFrom integrationTestCompile, testRuntime
	}
}

sourceSets {
	integrationTest {
		java.srcDir file('src/integration-test/java')
		groovy.srcDirs file('src/integration-test/groovy')
		resources.srcDir file('src/integration-test/resources')
		compileClasspath = sourceSets.main.output + sourceSets.test.output + configurations.integrationTestCompile
		runtimeClasspath = output + compileClasspath + configurations.integrationTestRuntime
	}
}

task integrationTest(type: Test, dependsOn: jar) {
	testClassesDir = sourceSets.integrationTest.output.classesDir
	logging.captureStandardOutput(LogLevel.INFO)
	classpath = sourceSets.integrationTest.runtimeClasspath
	maxParallelForks = 1
	reports {
		html.destination = project.file("$project.buildDir/reports/integration-tests/")
		junitXml.destination = project.file("$project.buildDir/integration-test-results/")
	}
}
check.dependsOn integrationTest

checkstyle {
	configFile = rootProject.file('config/checkstyle/checkstyle.xml')
	configProperties.configDir = configFile.parentFile
	toolVersion = '6.16.1'
}

task checkstyle {
	dependsOn project.tasks.findAll { task -> task.name.matches('checkstyle\\w+') }
}

eclipse {
	classpath {
		plusConfigurations += [ configurations.integrationTestCompile ]
	}
}

project.idea.module {
	scopes.TEST.plus += [project.configurations.integrationTestRuntime]
}
