plugins {
	id 'application'
	id 'org.openjfx.javafxplugin' version '0.0.9'
	id 'com.github.johnrengelman.shadow' version '5.2.0'
	id "com.diffplug.spotless" version "5.1.2"
	id "org.sonarqube" version "3.0"
}

apply plugin: 'java'
apply from: "gradle/git.gradle"
apply plugin: 'checkstyle'
apply plugin: "com.diffplug.spotless"
apply plugin: 'jacoco'

sourceCompatibility = '11'
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'

ext.mainClass = 'moviescraper.doctord.Main'
version = getVersionCode()

repositories {
	mavenCentral()
	maven { url "https://clojars.org/repo/" }
}

application {
	mainClassName = project.ext.mainClass
}

javafx {
	modules = [ 'javafx.swing' ]
}

sourceSets {
	main {
		java {
			srcDirs = ['src/main/java']
		}
		resources {
			srcDirs = ['src/main/resources']
		}
	}
}
dependencies {
	compile (
                'commons-io:commons-io:2.7',
		'org.apache.commons:commons-lang3:3.11',
		'commons-cli:commons-cli:1.4',
		'commons-codec:commons-codec:1.14',
		'org.apache.commons:commons-csv:1.8',
		'com.jgoodies:jgoodies-common:1.8.1',
		'com.jgoodies:jgoodies-forms:1.9.0',
		'org.imgscalr:imgscalr-lib:4.2',
		'com.cedarsoftware:json-io:4.12.0',
		'org.jsoup:jsoup:1.7.3',
		'com.thoughtworks.xstream:xstream:1.4.12',
		'org.json:json:20200518',
		'org.hamcrest:hamcrest-core:2.2',
		'xpp3:xpp3_min:1.1.4c',
		'xmlpull:xmlpull:1.1.3.1',
		'com.jgoodies:forms:1.3.0',
		'org.apache.httpcomponents:httpclient:4.5.12',
		'io.jsondb:jsondb-core:1.0.115-j11'
	)
	runtimeOnly "org.openjfx:javafx-graphics:$javafx.version:win"
	runtimeOnly "org.openjfx:javafx-graphics:$javafx.version:linux"
	runtimeOnly "org.openjfx:javafx-graphics:$javafx.version:mac"
	testCompile('junit:junit:4.+')
}

jar {
	into 'resources', {
		from 'resources'
	}
	manifest {
		attributes(
			"Implementation-Title": "Gradle",
			"Implementation-Version": version,
			"Description": "JAV Movies scraper",
			"Main-Class" : mainClass
		)
	}
}

shadowJar {
	baseName = project.name
}

spotless {
	java {
		eclipse().configFile 'config/format/eclipseformat.xml'
	}
}

jacocoTestReport {
	reports {
		xml.enabled = true
		html.enabled = true
	}
}
check.dependsOn jacocoTestReport

apply from: "gradle/codacy_coverage.gradle"
