apply from: rootProject.file('gradle/changelog.gradle')
ext.artifactId = project.artifactIdGradle
version = spotlessChangelog.versionNext
apply plugin: 'java-library'
apply plugin: 'com.gradle.plugin-publish'
apply plugin: 'java-gradle-plugin'
apply from: rootProject.file('gradle/java-setup.gradle')
apply from: rootProject.file('gradle/spotless-freshmark.gradle')


dependencies {
	if (version.endsWith('-SNAPSHOT') || (rootProject.spotlessChangelog.versionNext == rootProject.spotlessChangelog.versionLast)) {
		api projects.lib
		api projects.libExtra
	} else {
		api "com.diffplug.spotless:spotless-lib:${rootProject.spotlessChangelog.versionLast}"
		api "com.diffplug.spotless:spotless-lib-extra:${rootProject.spotlessChangelog.versionLast}"
	}
	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.eclipse.jgit:org.eclipse.jgit:${VER_JGIT}"

	testImplementation projects.testlib
	testImplementation "org.junit.jupiter:junit-jupiter:${VER_JUNIT}"
	testImplementation "org.assertj:assertj-core:${VER_ASSERTJ}"
	testImplementation "com.diffplug.durian:durian-testlib:${VER_DURIAN}"
	testImplementation 'org.owasp.encoder:encoder:1.3.1'
	testRuntimeOnly "org.junit.platform:junit-platform-launcher"
}

apply from: rootProject.file('gradle/special-tests.gradle')
tasks.withType(Test).configureEach {
	testLogging.showStandardStreams = true
}
tasks.validatePlugins {
	// TODO: https://github.com/gradle/gradle/issues/22600
	enableStricterValidation = true
}

//////////////////////////
// GRADLE PLUGIN PORTAL //
//////////////////////////
gradlePlugin {
	website = "https://github.com/diffplug/spotless"
	vcsUrl = "https://github.com/diffplug/spotless"
	plugins {
		spotlessPlugin {
			id = 'com.diffplug.spotless'
			implementationClass = 'com.diffplug.gradle.spotless.SpotlessPlugin'
			displayName = 'Spotless formatting plugin'
			description = project.description
			tags.set([
				'format',
				'style',
				'license',
				'header',
				'google-java-format',
				'eclipse',
				'ktlint',
				'ktfmt',
				'diktat',
				'tsfmt',
				'prettier',
				'scalafmt',
				'scalafix',
				'black',
				'clang-format'
			])
		}
		spotlessPluginLegacy {
			id = 'com.diffplug.gradle.spotless'
			implementationClass = 'com.diffplug.gradle.spotless.SpotlessPluginRedirect'
			displayName = 'Spotless formatting plugin (legacy)'
			description = project.description
			tags.set([
				'format'
			])
		}
	}
}

tasks.named("publishPlugins") {
	enabled = !version.endsWith('-SNAPSHOT')
}

// have to apply java-publish after setting up the pluginBundle
apply from: rootProject.file('gradle/java-publish.gradle')
