////////////////////////////////////////////////////////////////////////
//
//  find platform-specific SWT implementations
//

def osgi_platform

switch (System.getProperty('os.name')) {
	case ~/Mac OS X/:
		osgi_platform = 'cocoa.macosx.x86_64'
		break
	case ~/Windows.*/:
		osgi_platform = 'win32.win32.x86_64'
		break
	case ~/Linux/:
		osgi_platform = 'gtk.linux.x86_64'
		break
}

System.setProperty('osgi.platform', osgi_platform)

subprojects { subproject ->
	// skip generic Java setup for the few projects that have no Java code whatsoever
	switch (subproject.name) {
		case 'com.ibm.wala-repository':
		case 'com.ibm.wala.cast.js.test.data':
		case ~/.*_feature/:
			return
	}

	apply plugin: 'java'

	repositories {
		mavenCentral()
		maven {
			url 'https://artifacts.alfresco.com/nexus/content/repositories/public/'
		}
		maven {
			url 'https://repo.eclipse.org/content/groups/releases/'
		}
	}

	configurations.all {
		resolutionStrategy {
			// failOnVersionConflict()
			dependencySubstitution {
				substitute module('org.eclipse.platform:org.eclipse.swt.${osgi.platform}') with module("org.eclipse.platform:org.eclipse.swt.${System.getProperty('osgi.platform')}:3.+")
			}
		}
	}
}


////////////////////////////////////////////////////////////////////////
//
//  optional lint checking of Gradle scripts
//

buildscript {
	repositories.jcenter()
	dependencies {
		classpath 'com.netflix.nebula:gradle-lint-plugin:latest.release'
	}
}

allprojects {
	apply plugin: 'nebula.lint'
	gradleLint.alwaysRun = false
	gradleLint.rules = ['all-dependency']
}


////////////////////////////////////////////////////////////////////////
//
//  disable Javadoc linter until documentation is in better shape
//

allprojects {
	tasks.withType(Javadoc) {
		options.addStringOption('Xdoclint:none', '-quiet')
	}
}
