/*
 * Configuration of Java compiler, Javadoc, additional archives, and additional dependency configurations.
 */

sourceCompatibility = '11'

tasks.withType(JavaCompile) {
	options.encoding = 'ISO-8859-1'
	options.compilerArgs << '-parameters'
}

tasks.withType(Javadoc) {
	options.encoding = 'ISO-8859-1'
	options.tags = [ 'noreference', 'noextend', 'noimplement', 'noinstantiate', 'nooverride', 'model', 'generated', 'ordered' ] 
	options.addStringOption('Xdoclint:none', '-quiet')
}

task sourcesJar(type: Jar, dependsOn: classes) {
	group 'Build'
	description 'Assembles a jar archive containing the sources.'
	classifier = 'sources'
	from sourceSets.main.allSource
	from ('.') {
		include 'schema/**', 'model/**'
	}
}
artifacts.archives sourcesJar

task javadocJar(type: Jar, dependsOn: javadoc) {
	group 'Build'
	description 'Assembles a jar archive containing the JavaDoc output.'
	classifier = 'javadoc'
	from javadoc.destinationDir
}

sourceSets {
	mwe2 {}
}

configurations {
	optional {
		description 'Dependencies required at build time, but not exported into meta data'
		extendsFrom api
	}
	mwe2Implementation.extendsFrom mainImplementation
	mwe2Runtime.extendsFrom mainRuntime
	
	// Put any unwanted transitive dependencies here, they will be excluded from all projects.
	all {
		exclude group: 'org.antlr', module: 'stringtemplate'
		exclude module: 'cglib'
	}
}

sourceSets.main.compileClasspath += configurations.optional
sourceSets.test.compileClasspath += configurations.optional
sourceSets.test.runtimeClasspath += configurations.optional
javadoc.classpath += configurations.optional

if (findProperty('ignoreTestFailures') == 'true') {
	tasks.withType(Test) {
		ignoreFailures = true
	}
}
