plugins {
	id 'com.axelor.app'
}

apply from: "../libs.gradle"
apply from: "../version.gradle"

apply {
	version = openSuiteVersion
}

axelor {
	title "Axelor Bank Payment"
	description "Axelor Bank Payment Module"
}

configurations {
	jaxb
}

dependencies {
	api project(":modules:axelor-account")

    jaxb libs.jaxb_xjc

	implementation libs.bcprov_jdk18on
	implementation libs.bcpkix_jdk18on

	implementation libs.commons_codec
	implementation libs.commons_httpclient

	implementation libs.xmlsec
	implementation libs.xalan
	implementation libs.jdom

	implementation libs.iban4j

	implementation libs.jaxb_bind_api
}

license {
	// Don't generate license header on java classes generated from xsd
	// exclude "**/xsd/pain_001_001_*/**"
	exclude "**/xsd/sepa/**"
}

task xjc () {
	def source = "${projectDir}/src/main/resources/xsd/sepa"
	def target = "${buildDir}/src-gen/xjc"

	inputs.dir(source)
	outputs.dir(target)

	def xsdToGenerate = [
		['package': 'com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02', 'destdir': "$target", 'schema': "$source/pain.001.001.02.xsd"],
		['package': 'com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03', 'destdir': "$target", 'schema': "$source/pain.001.001.03.xsd"],
		['package': 'com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_01', 'destdir': "$target", 'schema': "$source/pain.008.001.01.xsd"], // SEPA Direct Debit v01
		['package': 'com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_02', 'destdir': "$target", 'schema': "$source/pain.008.001.02.xsd"]  // SEPA Direct Debit v02
	]

	doLast {
		ant.taskdef(name: 'xjc', classname: 'com.sun.tools.xjc.XJCTask', classpath: configurations.jaxb.asPath)

		xsdToGenerate.each { argsin ->
			ant.xjc	( argsin )
		}
	}

	sourceSets {
		main {
			java {
				srcDirs target
			}
		}
	}
}

compileJava.dependsOn xjc
generateCode.finalizedBy xjc
