Skip to content

Commit

Permalink
build: Bring buildscript back to groovy
Browse files Browse the repository at this point in the history
  • Loading branch information
zml2008 committed Aug 15, 2021
1 parent c0a8a02 commit 980090b
Showing 1 changed file with 40 additions and 52 deletions.
92 changes: 40 additions & 52 deletions build.gradle.kts → build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import java.io.StringWriter
import java.util.stream.Collectors

plugins {
jacoco
id("org.spongepowered.gradle.sponge.dev") version "1.1.0"
id("math-templates")
id("net.kyori.indra.publishing.sonatype") version "2.0.2"
id("net.ltgt.errorprone") version "2.0.1"
id 'jacoco'
id "org.spongepowered.gradle.sponge.dev" version "1.1.0"
id "math-templates"
id "net.kyori.indra.publishing.sonatype" version "2.0.2"
id "net.ltgt.errorprone" version "2.0.1"
}

// -- General setup -- //
Expand All @@ -16,7 +16,8 @@ version = "2.0.1-SNAPSHOT"
description = "Immutable math library for Java with a focus on games and computer graphics."

repositories {
maven("https://repo.spongepowered.org/repository/maven-public/") {
maven {
url = "https://repo.spongepowered.org/repository/maven-public/"
name = "sponge"
}
}
Expand All @@ -31,33 +32,26 @@ spongeConvention {

mitLicense()
licenseParameters {
val organization: String by project
val url: String by project
this["name"] = "Math"
this["organization"] = organization
this["url"] = url
name = "Math"
organization = project.organization
url = project.url
}

sharedManifest {
attributes(
"Specification-Title" to project.name,
"Specification-Vendor" to "SpongePowered - https://spongepowered.org"
)
attributes "Specification-Title": project.name,
"Specification-Vendor": "SpongePowered - https://spongepowered.org"
}
}

val floatData = file("src/templateData/float.yaml")
val intData = file("src/templateData/integer.yaml")
val licenseText = objects.property(String::class)
def floatData = file("src/templateData/float.yaml")
def intData = file("src/templateData/integer.yaml")
def licenseText = objects.property(String)
licenseText.set(provider {
val properties = (license as ExtensionAware).extra.properties.toMutableMap()
val template = groovy.text.SimpleTemplateEngine().createTemplate(file("HEADER.txt")).make(properties)

val writer = StringWriter()
template.writeTo(writer)
val text = writer.toString()
val lineEnding = license.lineEnding.get()
text.split(Regex("\r?\n")).stream()
def properties = [*: license.ext.properties]
def template = new groovy.text.SimpleTemplateEngine().createTemplate(file("HEADER.txt")).make(properties)
def text = template.toString()
def lineEnding = license.lineEnding.get()
Arrays.stream(text.split("\r?\n"))
.map { if (it.isEmpty()) { " *" } else { " * $it" } }
.collect(Collectors.joining(lineEnding, "/*$lineEnding", "$lineEnding */"))
})
Expand Down Expand Up @@ -107,9 +101,6 @@ sourceSets {


dependencies {
val errorproneVersion: String by project
val junitVersion: String by project

compileOnlyApi("com.google.errorprone:error_prone_annotations:$errorproneVersion")
errorprone("com.google.errorprone:error_prone_core:$errorproneVersion")

Expand All @@ -118,17 +109,14 @@ dependencies {
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}

tasks {
jar {
from(rootProject.file("LICENSE.txt")) {
rename { "LICENSE-spongepowered-math.txt" }
}
jar {
from(rootProject.file("LICENSE.txt")) {
rename { "LICENSE-spongepowered-math.txt" }
}
}

withType(JavaCompile::class) {
options.compilerArgs.add("-Xlint:-cast") // skip cast warnings, the generated source is most likely just overly safe.

}
tasks.withType(JavaCompile.class) {
options.compilerArgs << "-Xlint:-cast" // skip cast warnings, the generated source is most likely just overly safe.
}

// -- Publishing -- //
Expand All @@ -138,29 +126,29 @@ indra {
}
configurePublications {
pom {
name.set("Math")
inceptionYear.set("2013")
name = "Math"
inceptionYear = "2013"

developers {
developer {
id.set("DDoS")
name.set("Aleksi Sapon")
email.set("[email protected]")
id = "DDoS"
name = "Aleksi Sapon"
email = "[email protected]"
}
developer {
id.set("kitskub")
name.set("Jack Huey")
email.set("[email protected]")
id = "kitskub"
name = "Jack Huey"
email = "[email protected]"
}
developer {
id.set("Wolf480pl")
name.set("Wolf480pl")
email.set("[email protected]")
id = "Wolf480pl"
name = "Wolf480pl"
email = "[email protected]"
}
developer {
id.set("lukespragg")
name.set("Luke Spragg")
email.set("[email protected]")
id = "lukespragg"
name = "Luke Spragg"
email = "[email protected]"
}
}
}
Expand Down

0 comments on commit 980090b

Please sign in to comment.