plugins {
	id 'org.springframework.shell.docs'
	id 'org.antora' version '1.0.0'
	id 'io.spring.antora.generate-antora-yml' version '0.0.1'
}

description = 'Spring Shell Documentation'

dependencies {
	management platform(project(":spring-shell-management"))
	implementation project(':spring-shell-starters:spring-shell-starter')
	implementation project(':spring-shell-starters:spring-shell-starter-test')
	implementation project(':spring-shell-samples:spring-shell-sample-catalog')
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	testImplementation 'org.awaitility:awaitility'
}

node {
	version = '16.15.0'
}

antora {
	version = '3.2.0-alpha.2'
	if (project.hasProperty('antoraLocalBarePlaybook') && antoraLocalBarePlaybook.toBoolean()) {
		playbook = 'local-bare-antora-playbook.yml'
	}
	options = [clean: true, fetch: !project.gradle.startParameter.offline, stacktrace: true]
	dependencies = [
			'@antora/atlas-extension': '1.0.0-alpha.1',
			'@antora/collector-extension': '1.0.0-alpha.3',
			'@asciidoctor/tabs': '1.0.0-beta.3',
			'@springio/antora-extensions': '1.8.1',
			'@springio/asciidoctor-extensions': '1.0.0-alpha.8',
	]
}

tasks.named("generateAntoraYml") {
	asciidocAttributes = project.provider( {
		def dependencies = resolvedVersions(project.configurations.testRuntimeClasspath)
		return ['project-version' : project.version,
			'spring-boot-version' : dependencies['spring-boot-starter-version'],
			'spring-version': dependencies['spring-core-version']
		]
	} )
}



def resolvedVersions(Configuration configuration) {
	return configuration.resolvedConfiguration
			.resolvedArtifacts
			.collectEntries { [(it.name + '-version'): it.moduleVersion.id.version] }
}
