import org.gradlex.maven.plugin.development.task.GenerateHelpMojoSourcesTask
import org.gradlex.maven.plugin.development.task.GenerateMavenPluginDescriptorTask

plugins {
	// https://github.com/gradlex-org/maven-plugin-development
	id 'org.gradlex.maven-plugin-development' version '1.0.3'
}

apply from: rootProject.file('gradle/changelog.gradle')
ext.artifactId = project.artifactIdMaven
version = spotlessChangelog.versionNext

apply from: rootProject.file("gradle/java-setup.gradle")
apply from: rootProject.file('gradle/spotless-freshmark.gradle')

mavenPlugin {
	name = 'Spotless Maven Plugin'
	artifactId = project.artifactIdMaven
	description = project.description
}

String VER_MAVEN_API = '3.0'
String VER_ECLIPSE_AETHER = '1.1.0'
String VER_PLEXUS_RESOURCES = '1.3.1'
dependencies {
	implementation projects.lib
	implementation projects.libExtra

	compileOnly "org.apache.maven:maven-plugin-api:${VER_MAVEN_API}"
	compileOnly "org.apache.maven.plugin-tools:maven-plugin-annotations:${VER_MAVEN_API}"
	compileOnly "org.apache.maven:maven-core:${VER_MAVEN_API}"
	compileOnly "org.eclipse.aether:aether-api:${VER_ECLIPSE_AETHER}"

	compileOnly "jakarta.annotation:jakarta.annotation-api:3.0.0"

	implementation "com.diffplug.durian:durian-core:${VER_DURIAN}"
	implementation "com.diffplug.durian:durian-io:${VER_DURIAN}"
	implementation "com.diffplug.durian:durian-collect:${VER_DURIAN}"
	implementation("org.codehaus.plexus:plexus-resources:${VER_PLEXUS_RESOURCES}")
	implementation "org.eclipse.jgit:org.eclipse.jgit:${VER_JGIT}"
	implementation 'org.sonatype.plexus:plexus-build-api:0.0.7'

	testImplementation project(":testlib")
	testImplementation "org.junit.jupiter:junit-jupiter:${VER_JUNIT}"
	testImplementation "org.assertj:assertj-core:${VER_ASSERTJ}"
	testImplementation "org.mockito:mockito-core:${VER_MOCKITO}"
	testImplementation "com.diffplug.durian:durian-io:${VER_DURIAN}"
	testImplementation 'com.github.spullara.mustache.java:compiler:0.9.14'
	testImplementation 'org.owasp.encoder:encoder:1.3.1'
	testImplementation "org.apache.maven:maven-plugin-api:${VER_MAVEN_API}"
	testImplementation "org.eclipse.aether:aether-api:${VER_ECLIPSE_AETHER}"
	testImplementation "org.codehaus.plexus:plexus-resources:${VER_PLEXUS_RESOURCES}"
	testImplementation "org.apache.maven:maven-core:${VER_MAVEN_API}"
	testRuntimeOnly "org.junit.platform:junit-platform-launcher"
}

apply from: rootProject.file('gradle/special-tests.gradle')
tasks.withType(Test).configureEach {
	systemProperty 'spotlessMavenPluginVersion', project.version
	systemProperty 'spotlessProjectDir', "${project.rootProject.projectDir}".toString()
	dependsOn 'publishToMavenLocal'
	dependsOn ':lib:publishToMavenLocal'
	dependsOn ':lib-extra:publishToMavenLocal'
}

apply from: rootProject.file("gradle/java-publish.gradle")
