/******************************************************************************
 * Copyright (c) 2016 TypeFox and others.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0,
 * or the Eclipse Distribution License v. 1.0 which is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
 ******************************************************************************/

import java.time.format.DateTimeFormatter
import java.time.LocalDateTime

buildscript {
	repositories {
		mavenCentral()
		maven {
			url "https://plugins.gradle.org/m2/"
		}
	}
	dependencies {
		classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:6.4.0"
		classpath "org.xtext:xtext-gradle-plugin:4.0.0"
	}
}

ext.buildTime = DateTimeFormatter.ofPattern('yyyyMMdd-HHmm').format(LocalDateTime.now())

apply from: "${rootDir}/gradle/versions.gradle"

subprojects {
	repositories.mavenCentral()

	group = 'org.eclipse.lsp4j'
	version = rootProject.version

	apply plugin: 'eclipse'
	apply plugin: 'java-library'
	apply plugin: 'org.xtext.xtend'
	apply plugin: 'eclipse'
	apply plugin: 'maven-publish'

	apply from: "${rootDir}/gradle/java-compiler-settings.gradle"
	apply from: "${rootDir}/gradle/xtend-compiler-settings.gradle"
	apply from: "${rootDir}/gradle/maven-deployment.gradle"
	apply from: "${rootDir}/gradle/manifest-gen.gradle"

	configurations.all {
		if (name.contains("Tooling")) {
			dependencies {
				add(name, "org.eclipse.xtend:org.eclipse.xtend.core:${versions.xtend_lib}")
				add(name, platform("org.eclipse.xtext:xtext-dev-bom:${versions.xtend_lib}"))
			}
		}
	}

	eclipse {
		jdt.file.withProperties { properties ->
			properties['org.eclipse.jdt.core.compiler.release']='enabled'
			properties['org.eclipse.jdt.core.compiler.doc.comment.support']='enabled'
			properties['org.eclipse.jdt.core.compiler.problem.APILeak']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated']='info'
			properties['org.eclipse.jdt.core.compiler.problem.annotationSuperInterface']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.assertIdentifier']='error'
			properties['org.eclipse.jdt.core.compiler.problem.autoboxing']='ignore'
			properties['org.eclipse.jdt.core.compiler.problem.comparingIdentical']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.deadCode']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.deprecation']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.discouragedReference']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.emptyStatement']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.enumIdentifier']='error'
			properties['org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.fallthroughCase']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.fatalOptionalError']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.fieldHiding']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.finalParameterBound']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.forbiddenReference']='error'
			properties['org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts']='enabled'
			properties['org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.indirectStaticAccess']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.invalidJavadoc']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.invalidJavadocTags']='enabled'
			properties['org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef']='enabled'
			properties['org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef']='enabled'
			properties['org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility']='protected'
			properties['org.eclipse.jdt.core.compiler.problem.localVariableHiding']='ignore'
			properties['org.eclipse.jdt.core.compiler.problem.methodWithConstructorName']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.missingDefaultCase']='info'
			properties['org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.missingJavadocComments']='ignore'
			properties['org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility']='public'
			properties['org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription']='return_tag'
			properties['org.eclipse.jdt.core.compiler.problem.missingJavadocTags']='ignore'
			properties['org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility']='public'
			properties['org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation']='enabled'
			properties['org.eclipse.jdt.core.compiler.problem.missingSerialVersion']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.noEffectAssignment']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral']='ignore'
			properties['org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict']='error'
			properties['org.eclipse.jdt.core.compiler.problem.nullReference']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.nullSpecViolation']='error'
			properties['org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.parameterAssignment']='ignore'
			properties['org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.potentialNullReference']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.rawTypeReference']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.redundantNullCheck']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.redundantSuperinterface']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic']='ignore'
			properties['org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic']='ignore'
			properties['org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.specialParameterHidingField']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.staticAccessReceiver']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.suppressWarnings']='enabled'
			properties['org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed']='info'
			properties['org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation']='ignore'
			properties['org.eclipse.jdt.core.compiler.problem.terminalDeprecation']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.typeParameterHiding']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.unclosedCloseable']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock']='ignore'
			properties['org.eclipse.jdt.core.compiler.problem.unhandledWarningToken']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType']='info'
			properties['org.eclipse.jdt.core.compiler.problem.unnecessaryElse']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess']='ignore'
			properties['org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable']='enabled'
			properties['org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference']='enabled'
			properties['org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter']='ignore'
			properties['org.eclipse.jdt.core.compiler.problem.unusedImport']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.unusedLabel']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.unusedLocal']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.unusedParameter']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference']='enabled'
			properties['org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete']='disabled'
			properties['org.eclipse.jdt.core.compiler.problem.unusedPrivateMember']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.unusedTypeParameter']='ignore'
			properties['org.eclipse.jdt.core.compiler.problem.unusedWarningToken']='warning'
			properties['org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast']='warning'
		}
	}
}

task clean(type: Delete) {
	group 'Build'
	description 'Deletes the local repositories'
	delete 'build'
}
