<commit_before>package com.github.oehme.sobula

import com.jfrog.bintray.gradle.BintrayExtension
import com.jfrog.bintray.gradle.BintrayPlugin
import com.jfrog.bintray.gradle.BintrayUploadTask
import org.gradle.api.Plugin
import org.gradle.api.Project

import static extension com.github.oehme.sobula.ReleasePlugin.*

class BintrayReleasePlugin implements Plugin<Project> {

	override apply(Project project) {
		val it = project
		plugins.<ReleasePlugin>apply(ReleasePlugin)
		plugins.<BintrayPlugin>apply(BintrayPlugin)

		val bintrayUpload = bintrayUpload
		bintrayUpload.doFirst [ upload |
			if (project != rootProject) {
				val rootBintrayUpload = rootProject.bintrayUpload
				val isMultiProjectUpload = gradle.taskGraph.hasTask(rootBintrayUpload)
				if (isMultiProjectUpload) {
					bintrayUpload.syncToMavenCentral = false
					bintrayUpload.signVersion = false
				}
			}
		]
		
		tasks.getAt(ReleasePlugin.RELEASE_TASK_NAME).dependsOn(bintrayUpload)

		bintray => [
			if (project.hasProperty("bintrayUsername")) {
				user = project.properties.get("bintrayUsername").toString
			}
			if (project.hasProperty("bintrayApiKey")) {
				key = project.properties.get("bintrayApiKey").toString
			}
			publications = "mavenNebula"
			publish = true
			pkg => [
				repo = "maven"
				publicDownloadNumbers = true
				attributes = newHashMap
				version => [
					gpg.sign = true
					if (project.hasProperty("signingPassword")) {
						gpg.passphrase = project.property("signingPassword").toString
					}
					mavenCentralSync.sync = true
					if (project.hasProperty('sonatypeUsername')) {
						mavenCentralSync.user = project.property("sonatypeUsername").toString
					}
					if (project.hasProperty('sonatypePassword')) {
						mavenCentralSync.password = project.property("sonatypePassword").toString
					}
					attributes = newHashMap
				]
			]
		]
		afterEvaluate[
			bintray => [
				pkg => [
					name = name ?: project.name
					desc = desc ?: project.description ?: ""
					val gitHubUser = project.gitHubUser
					if (gitHubUser != null) {
						websiteUrl = websiteUrl ?: '''https://github.com/«gitHubUser»/«project.rootProject.name»'''
						issueTrackerUrl = issueTrackerUrl ?: '''https://github.com/«gitHubUser»/«project.rootProject.name»/issues'''
						vcsUrl = vcsUrl ?: '''https://github.com/«gitHubUser»/«project.rootProject.name».git'''
					}
					if (licenses == null || licenses.isEmpty) {
						val license = project.license
						if (license != null) {
							licenses = license.id
						}
					}
					version => [
						name = name ?: project.version.toString
                		vcsTag = vcsTag ?: project.version.toString
					]
				]
			]
		]
	}
	
	private def bintray(Project it) {
		extensions.getByType(BintrayExtension)
	}
	
	private def bintrayUpload(Project it) {
		tasks.getAt("bintrayUpload") as BintrayUploadTask
	}
}<commit_msg>don't fail on missing bintrayUpload in root project<commit_after>package com.github.oehme.sobula

import com.jfrog.bintray.gradle.BintrayExtension
import com.jfrog.bintray.gradle.BintrayPlugin
import com.jfrog.bintray.gradle.BintrayUploadTask
import org.gradle.api.Plugin
import org.gradle.api.Project

import static extension com.github.oehme.sobula.ReleasePlugin.*

class BintrayReleasePlugin implements Plugin<Project> {

	override apply(Project project) {
		val it = project
		plugins.<ReleasePlugin>apply(ReleasePlugin)
		plugins.<BintrayPlugin>apply(BintrayPlugin)

		val bintrayUpload = bintrayUpload
		bintrayUpload.doFirst [ upload |
			if (project != rootProject) {
				val rootBintrayUpload = rootProject.bintrayUpload
				val isMultiProjectUpload = gradle.taskGraph.hasTask(rootBintrayUpload)
				if (isMultiProjectUpload) {
					bintrayUpload.syncToMavenCentral = false
					bintrayUpload.signVersion = false
				}
			}
		]
		
		tasks.getAt(ReleasePlugin.RELEASE_TASK_NAME).dependsOn(bintrayUpload)

		bintray => [
			if (project.hasProperty("bintrayUsername")) {
				user = project.properties.get("bintrayUsername").toString
			}
			if (project.hasProperty("bintrayApiKey")) {
				key = project.properties.get("bintrayApiKey").toString
			}
			publications = "mavenNebula"
			publish = true
			pkg => [
				repo = "maven"
				publicDownloadNumbers = true
				attributes = newHashMap
				version => [
					gpg.sign = true
					if (project.hasProperty("signingPassword")) {
						gpg.passphrase = project.property("signingPassword").toString
					}
					mavenCentralSync.sync = true
					if (project.hasProperty('sonatypeUsername')) {
						mavenCentralSync.user = project.property("sonatypeUsername").toString
					}
					if (project.hasProperty('sonatypePassword')) {
						mavenCentralSync.password = project.property("sonatypePassword").toString
					}
					attributes = newHashMap
				]
			]
		]
		afterEvaluate[
			bintray => [
				pkg => [
					name = name ?: project.name
					desc = desc ?: project.description ?: ""
					val gitHubUser = project.gitHubUser
					if (gitHubUser != null) {
						websiteUrl = websiteUrl ?: '''https://github.com/«gitHubUser»/«project.rootProject.name»'''
						issueTrackerUrl = issueTrackerUrl ?: '''https://github.com/«gitHubUser»/«project.rootProject.name»/issues'''
						vcsUrl = vcsUrl ?: '''https://github.com/«gitHubUser»/«project.rootProject.name».git'''
					}
					if (licenses == null || licenses.isEmpty) {
						val license = project.license
						if (license != null) {
							licenses = license.id
						}
					}
					version => [
						name = name ?: project.version.toString
                		vcsTag = vcsTag ?: project.version.toString
					]
				]
			]
		]
	}
	
	private def bintray(Project it) {
		extensions.getByType(BintrayExtension)
	}
	
	private def bintrayUpload(Project it) {
		tasks.findByName("bintrayUpload") as BintrayUploadTask
	}
}
{'fraction_non_alphanumeric': 0.11651993785603314, 'fraction_numerical': 0.0, 'mean_word_length': 3.4500768049155144, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3834546', 'n_tokens_mistral': 2283, 'n_tokens_neox': 1803, 'n_words': 333}