import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {
	id 'org.springframework.boot' version '2.7.4'
	id 'io.spring.dependency-management' version '1.0.14.RELEASE'
	id 'java'
}

group = 'ca.umanitoba.dam.islandora'
sourceCompatibility = '11'
description = 'Set of three application to set up remote OCR/HOCR processing.'

repositories {
	mavenCentral()
}

ext {
	docURL = 'https://github.com/whikloj/islandora-1x-derivative-toolkit'
	versions = [
		camel: '3.18.1',
		logback: '1.2.6',
		springBoot: '2.7.4',
		springDM: '1.0.14.RELEASE'
	]
}

dependencies {
	implementation "javax.jms:javax.jms-api:2.0.1"
	implementation "org.apache.camel:camel-activemq:${versions.camel}"
	implementation "org.apache.camel:camel-bean:${versions.camel}"
	implementation "org.apache.camel:camel-direct:${versions.camel}"
	implementation "org.apache.camel:camel-exec:${versions.camel}"
	implementation "org.apache.camel:camel-http:${versions.camel}"
	implementation "org.apache.camel:camel-jetty:${versions.camel}"
	implementation "org.apache.camel:camel-jsonpath:${versions.camel}"
	implementation "org.apache.camel:camel-log:${versions.camel}"
	implementation "org.apache.camel:camel-main:${versions.camel}"
	implementation "org.apache.camel:camel-rest:${versions.camel}"
	implementation "org.apache.camel:camel-support:${versions.camel}"
	implementation "org.apache.camel.springboot:camel-spring-boot-starter:${versions.camel}"
	implementation "org.apache.camel.springboot:camel-activemq-starter:${versions.camel}"
	implementation "org.apache.camel.springboot:camel-rest-starter:${versions.camel}"

	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	testImplementation "org.apache.camel:camel-test-spring-junit5:${versions.camel}"
	testImplementation "org.apache.camel:camel-test-junit5:${versions.camel}"

	testRuntimeOnly "org.apache.activemq:apache-activemq:5.16.1"

	runtimeOnly "ch.qos.logback:logback-classic:${versions.logback}"
	runtimeOnly "com.jayway.jsonpath:json-path:2.7.0"
}

gradle.projectsEvaluated {
	tasks.withType(JavaCompile) {
		options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
	}
	tasks.withType(Test) {
		testLogging {
			// set options for log level LIFECYCLE
			events TestLogEvent.FAILED,
					TestLogEvent.PASSED,
					TestLogEvent.SKIPPED
			//TestLogEvent.STANDARD_OUT
			exceptionFormat TestExceptionFormat.FULL
			showExceptions true
			showCauses false
			showStackTraces false

			// set options for log level DEBUG and INFO
			debug {
				events TestLogEvent.STARTED,
						TestLogEvent.FAILED,
						TestLogEvent.PASSED,
						TestLogEvent.SKIPPED,
						TestLogEvent.STANDARD_ERROR,
						TestLogEvent.STANDARD_OUT
				exceptionFormat TestExceptionFormat.FULL
			}
			info.events = debug.events
			info.exceptionFormat = debug.exceptionFormat
		}
	}
}

jar {
	manifest {
		attributes (
				description: project.description,
				docURL: project.docURL,
				'Main-Class': 'ca.umanitoba.dam.islandora.derivativetoolkit.DerivativeToolkitApplication',
		)
	}
}
test {
	useJUnitPlatform()
	// To display normal application output during tests.
	//testLogging.showStandardStreams = true
	// To change testing log level
	//jvmArgs = ['-Dtoolkit.log.all=TRACE']
}