plugins {
	id 'java-library'
	id 'idea'
	id 'maven-publish'
	id 'signing'
	id "com.github.ben-manes.versions" version "0.52.0"
}

java {
	sourceCompatibility = JavaVersion.VERSION_11
	targetCompatibility = JavaVersion.VERSION_11
}

sourceSets.main.java.srcDirs = ['src']
sourceSets.main.resources.srcDirs = ['resources']

base {
	group = "io.github.andrewauclair"
	archivesName = "modern-docking-multi-app"
}

// NOTE: do not add new dependencies here, Modern Docking is a zero-dependency library
dependencies {
	if (project.hasProperty("useMavenVersion")) {
		implementation 'io.github.andrewauclair:modern-docking-api:' + version
	}
	else {
		api project(':docking-api')
	}
}

java {
	withJavadocJar()
	withSourcesJar()
}

publishing {
	publications {
		mavenJava(MavenPublication) {
			artifactId = 'modern-docking-multi-app'
			from components.java
			versionMapping {
				usage('java-api') {
					fromResolutionOf('runtimeClasspath')
				}
				usage('java-runtime') {
					fromResolutionResult()
				}
			}
			pom {
				name = 'Java Modern Docking'
				description = 'Modern docking library for Java Swing'
				url = 'https://github.com/andrewauclair/ModernDocking'
				licenses {
					license {
						name = 'The MIT License'
						url = 'https://opensource.org/licenses/MIT'
					}
				}
				developers {
					developer {
						id = 'andrewauclair'
						name = 'Andrew Auclair'
						email = 'mightymalakai33@gmail.com'
					}
				}
				scm {
					connection = 'scm:git:git//github.com/andrewauclair/ModernDocking.git'
					developerConnection = 'scm:git:ssh//github.com/andrewauclair/ModernDocking.git'
					url = 'https://github.com/andrewauclair/ModernDocking'
				}
			}
		}
	}
}

signing {
	required = { gradle.taskGraph.hasTask("publish") }
	sign publishing.publications.mavenJava
}

javadoc {
	if(JavaVersion.current().isJava9Compatible()) {
		options.addBooleanOption('html5', true)
	}
}