buildscript {
	ext.repos = {
		mavenCentral()
		mavenLocal()
		jcenter()
		maven { url 'https://plugins.gradle.org/m2/' }
		maven { url 'https://repository.axelor.com/nexus/public/' }
	}
	ext.openPlatformVersion = '5.2.2'
	ext.appVersion = '5.2.1'
	repositories repos
	dependencies {
		classpath "com.axelor:axelor-gradle:${openPlatformVersion}"
	}
}

allprojects { repositories repos }

apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: "com.axelor.app"

apply from: './gradle/style.gradle'

allprojects {

	configurations {
   		runtime.exclude group:"org.eclipse.birt.runtime.3_7_1", module:"org.apache.commons.codec"
	}

	apply plugin: 'idea'
	apply plugin: 'eclipse'

	group = "com.axelor"
	version = "${appVersion}"

	sourceCompatibility = 1.8
	targetCompatibility = 1.8

}

subprojects {
  group = "com.axelor.apps"
}

axelor {
	title "Sophal"
	description "Sophal Entreprise"
}

dependencies {
	gradle.appModules.each { dir ->
		compile project(":modules:$dir.name")
	}
}

wrapper {
    gradleVersion = "4.4.1"
}

task("dataImport", type: JavaExec) {
	main = "com.axelor.apps.erp.Main"
	classpath = sourceSets.main.runtimeClasspath
	if(System.getProperty("exec.args") != null) {
		args System.getProperty("exec.args").split()
	}
}

task archiveReports(type: Zip) {
	file("modules").traverse(type: groovy.io.FileType.DIRECTORIES, maxDepth: 1) { dir ->
		if(new File(dir, "build.gradle").exists() && new File(dir, "/src/main/resources/reports").exists()) {
			new File(dir, "/src/main/resources/reports/").listFiles().each { report ->
				from report.getPath()
			}
		}
	}

	classifier 'reports'
	includeEmptyDirs = false
	destinationDir = file("$buildDir/libs")
}

build.finalizedBy archiveReports
