plugins {
	id "java"
	id "org.asciidoctor.jvm.convert" version "3.3.2"
}

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

group = 'com.example'

sourceCompatibility = 17
targetCompatibility = 17

ext {
	snippetsDir = file('build/generated-snippets')
	restdocsVersion = '3.0.0-SNAPSHOT'
}

configurations {
	asciidoctorExtensions
}

dependencies {
	asciidoctorExtensions "org.springframework.restdocs:spring-restdocs-asciidoctor:$restdocsVersion"

	implementation "com.fasterxml.jackson.core:jackson-databind:2.12.5"
	implementation "jakarta.servlet:jakarta.servlet-api:5.0.0"
	implementation "org.hibernate.validator:hibernate-validator:7.0.0.Final"
	implementation "org.hibernate:hibernate-core-jakarta:5.5.7.Final"
	implementation "org.springframework:spring-webmvc:6.0.0-SNAPSHOT"
	implementation "org.springframework.data:spring-data-jpa:3.0.0-SNAPSHOT"
	implementation "org.springframework.hateoas:spring-hateoas:2.0.0-SNAPSHOT"

	runtimeOnly 'com.h2database:h2:1.4.200'
	runtimeOnly 'org.atteo:evo-inflector:1.2.1'

	testImplementation 'com.jayway.jsonpath:json-path:2.6.0'
	testImplementation 'junit:junit:4.12'
	testImplementation 'org.assertj:assertj-core:3.21.0'
	testImplementation 'org.hamcrest:hamcrest-library:2.2'
	testImplementation "org.springframework.restdocs:spring-restdocs-mockmvc:$restdocsVersion"

	testRuntimeOnly 'org.glassfish:jakarta.el:4.0.2'
}

test {
	outputs.dir snippetsDir
}

asciidoctor {
	configurations "asciidoctorExtensions"
	inputs.dir snippetsDir
	dependsOn test
}

jar {
	dependsOn asciidoctor
	from ("${asciidoctor.outputDir}/html5") {
		into 'static/docs'
	}
}

