Updated to gradle 7.2

This commit is contained in:
Robinson 2021-09-22 02:57:26 +02:00
parent b4c7e3da55
commit cdeea35666
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
3 changed files with 51 additions and 5 deletions

View File

@ -445,10 +445,10 @@ enum class License constructor(internal val names: Collection<String>, internal
return UNKNOWN return UNKNOWN
} }
val normalizedLicenseName = licenseName.toLowerCase(Locale.US) val normalizedLicenseName = licenseName.lowercase(Locale.US)
values().forEach { license -> values().forEach { license ->
val found = license.names.firstOrNull { it.toLowerCase(Locale.US) == normalizedLicenseName } val found = license.names.firstOrNull { it.lowercase(Locale.US) == normalizedLicenseName }
if (found != null) { if (found != null) {
return license return license
} }

View File

@ -20,6 +20,7 @@ import java.io.IOException
import java.io.ObjectInputStream import java.io.ObjectInputStream
import java.io.ObjectOutputStream import java.io.ObjectOutputStream
import java.time.LocalDate import java.time.LocalDate
import java.util.*
open class LicenseData(var name: String, var license: License) : java.io.Serializable, Comparable<LicenseData> { open class LicenseData(var name: String, var license: License) : java.io.Serializable, Comparable<LicenseData> {
@ -122,7 +123,7 @@ open class LicenseData(var name: String, var license: License) : java.io.Seriali
* ignore case when sorting these * ignore case when sorting these
*/ */
override operator fun compareTo(other: LicenseData): Int { override operator fun compareTo(other: LicenseData): Int {
return this.name.toLowerCase().compareTo(other.name.toLowerCase()) return this.name.lowercase(Locale.US).compareTo(other.name.lowercase(Locale.US))
} }
override fun toString(): String { override fun toString(): String {

View File

@ -16,10 +16,10 @@
package dorkbox.license package dorkbox.license
import License import License
import org.gradle.api.Action
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.api.tasks.SourceSet import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.SourceSetContainer
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.File import java.io.File
open class Licensing(private val project: Project) { open class Licensing(private val project: Project) {
@ -32,6 +32,51 @@ open class Licensing(private val project: Project) {
} }
internal const val NAME = "licensing" internal const val NAME = "licensing"
/**
* If the kotlin plugin is applied, and there is a compileKotlin task.. Then kotlin is enabled
* NOTE: This can ONLY be called from a task, it cannot be called globally!
*/
fun hasKotlin(project: Project, debug: Boolean = false): Boolean {
try {
// check if plugin is available
project.plugins.findPlugin("org.jetbrains.kotlin.jvm") ?: return false
if (debug) println("\tHas kotlin plugin")
// this will check if the task exists, and throw an exception if it does not or return false
project.tasks.named("compileKotlin", KotlinCompile::class.java).orNull ?: return false
if (debug) println("\tHas compile kotlin task")
// check to see if we have any kotlin file
val sourceSets = project.extensions.getByName("sourceSets") as SourceSetContainer
val main = sourceSets.getByName("main")
val kotlin = project.extensions.getByType(org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension::class.java).sourceSets.getByName("main").kotlin
if (debug) {
println("\tmain dirs: ${main.java.srcDirs}")
println("\tkotlin dirs: ${kotlin.srcDirs}")
project.buildFile.parentFile.walkTopDown().filter { it.extension == "kt" }.forEach {
println("\t\t$it")
}
}
val files = main.java.srcDirs + kotlin.srcDirs
files.forEach { srcDir ->
val kotlinFile = srcDir.walkTopDown().find { it.extension == "kt" }
if (kotlinFile?.exists() == true) {
if (debug) println("\t Has kotlin file: $kotlinFile")
return true
}
}
} catch (e: Exception) {
if (debug) e.printStackTrace()
}
return false
}
} }
private val projectName = project.name private val projectName = project.name