plugins {
	// Apply the java-library plugin to add support for Java Library
	id 'java-library'
	id 'org.openjfx.javafxplugin' version '0.0.10'
	id 'maven-publish'
	id 'signing'
	id 'org.javamodularity.moduleplugin' version '1.8.10'
}

version = '0.6.1'

repositories {
	// Use jcenter for resolving dependencies.
	// You can declare any Maven/Ivy/file repository here.
	mavenCentral()
}

dependencies {
	testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
	testImplementation "org.testfx:testfx-junit5:4.0.18"
	testImplementation "org.testfx:openjfx-monocle:jdk-12.0.1+2"
	testImplementation "org.hamcrest:hamcrest:2.1" 

	testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.1'
	
	testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.1'
}

compileTestJava {
	moduleOptions {
		compileOnClasspath = true
	}
}

test {
    useJUnitPlatform()
    jvmArgs '-Djava.awt.headless=true', '-Dtestfx.robot=glass', '-Dtestfx.headless=true', '-Dprism.order=sw'

	moduleOptions {
		runOnClasspath = true
	}
}


jar {
	manifest {
		attributes('Implementation-Title': project.name,
				   'Implementation-Version': project.version)
	}
}

javafx {
	version = "11"
	modules = [ 'javafx.controls', 'javafx.graphics', 'javafx.base' ]
	// configuration = 'compileOnly'
}

sourceCompatibility = 11
targetCompatibility = 11

group = 'net.synedra'

task sourcesJar(type: Jar) {
	classifier = 'sources'
	from sourceSets.main.allJava
}

task javadocJar(type: Jar) {
	classifier = 'javadoc'
	from javadoc.destinationDir
}

publishing {
	publications {
		mavenJava(MavenPublication) {
			groupId = 'net.synedra'
			artifactId = 'validatorfx'
			from components.java
			
			artifact sourcesJar
			artifact javadocJar
			pom {
				name = 'ValidatorFX'
				description = 'A form validation library for JavaFX'
				url = 'https://github.com/effad/ValidatorFX'
				licenses {
					license {
						name = 'BSD 3-Clause License'
						url = 'https://raw.githubusercontent.com/effad/ValidatorFX/master/LICENSE'
					}
				}
				developers {
					developer {
						id = 'effad'
						name = 'Robert Lichtenberger'
						email = 'r.lichtenberger@synedra.com'
					}
				}
				scm {
					connection = 'scm:git:https://github.com/effad/ValidatorFX.git'
					developerConnection = 'scm:git:ssh://git@github.com:effad/ValidatorFX.git'
					url = 'https://github.com/effad/ValidatorFX'
				}
			}			
		}
	}

	repositories {
		maven {
			name = 'myRepo'
			url = "file://${buildDir}/repo"
		}
		maven {
			name = 'ossrh'
			def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
			def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
			url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
			credentials {
				username = ossrhUsername
				password = ossrhPassword
			}
		}
	}
}

signing {
    sign publishing.publications.mavenJava
}
