/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

plugins {
    alias(libs.plugins.versions)
	alias(libs.plugins.version.catalog.update)
	id 'pulsar-client-reactive.codestyle-conventions'
}

allprojects {
    group = 'org.apache.pulsar'
    apply plugin: 'io.spring.javaformat'
	apply plugin: 'org.nosphere.apache.rat'

	repositories {
		mavenCentral()
	}

	tasks.named('rat') {
		inputDir = projectDir
		excludes = ['.asf.yaml', // ASF metadata for github integration excluded from src zip
					'**/.gradle/**', '**/wrapper/**', 'gradlew*',  // gradle wrapper files excluded from src zip
					'gradle.properties',  // artifactory release plugin removes header when bumping version
					'**/build/**', '**/target/**', 'licenses/**', 'notices/**',
					'**/META-INF/services/*',
					'out/**', '*.ipr', '**/*.iml', '*.iws', '.idea/**', // Intellij files
					'.classpath', '.project', '.settings/**', 'bin/**', // Eclipse files
		]
	}
}

task sourceTar(type: Tar) {
	destinationDirectory = buildDir
	archiveBaseName = "pulsar-client-reactive-${rootProject.version}"
	archiveClassifier = "src"
	archiveExtension = "tar.gz"
 	compression = Compression.GZIP
	duplicatesStrategy = DuplicatesStrategy.EXCLUDE
	includeEmptyDirs = false
	into(archiveBaseName) {
		from(rootDir) {
			excludes = [
					'.github/**', '.asf.yaml',
					'**/build/**', '**/target/**',
					'out/**', '*.ipr', '**/*.iml', '*.iws', '.idea/**', // Intellij files
					'.classpath', '.project', '.settings/**', 'bin/**', // Eclipse files
					'**/.gradle/**', '**/wrapper/**', 'gradlew*',  // gradle wrapper files excluded from src zip
			]
		}
	}
}

license {
	tasks {
		rootProjectExtraFiles {
			files.from('checkstyle', 'idea', 'shared-test-resources', 'buildSrc/src', 'buildSrc/build.gradle', '.github')
		}
	}
}

tasks.named("dependencyUpdates").configure {
	rejectVersionIf {
		it.candidate.version.contains("alpha") || it.candidate.version.contains("beta") || it.candidate.version.contains("rc")
	}
}

versionCatalogUpdate {
	keep {
		keepUnusedLibraries = true
		keepUnusedVersions = true
	}
}