mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 06:11:24 +00:00
clean up gradle
This commit is contained in:
+10
-9
@@ -2,10 +2,10 @@ import com.dfsek.terra.configureCompilation
|
|||||||
import com.dfsek.terra.configureDependencies
|
import com.dfsek.terra.configureDependencies
|
||||||
import com.dfsek.terra.configureDistribution
|
import com.dfsek.terra.configureDistribution
|
||||||
import com.dfsek.terra.configurePublishing
|
import com.dfsek.terra.configurePublishing
|
||||||
import com.dfsek.terra.configureVersioning
|
import com.dfsek.terra.forSubProjects
|
||||||
|
import com.dfsek.terra.preRelease
|
||||||
import com.dfsek.terra.version
|
import com.dfsek.terra.version
|
||||||
import com.dfsek.terra.versionProjects
|
import com.dfsek.terra.versionProjects
|
||||||
import com.dfsek.terra.preRelease
|
|
||||||
|
|
||||||
|
|
||||||
preRelease(true)
|
preRelease(true)
|
||||||
@@ -18,11 +18,6 @@ versionProjects(":platforms", version("6.0.0"))
|
|||||||
allprojects {
|
allprojects {
|
||||||
group = "com.dfsek.terra"
|
group = "com.dfsek.terra"
|
||||||
|
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
configureVersioning()
|
|
||||||
}
|
|
||||||
|
|
||||||
configureCompilation()
|
configureCompilation()
|
||||||
configureDependencies()
|
configureDependencies()
|
||||||
configurePublishing()
|
configurePublishing()
|
||||||
@@ -54,7 +49,13 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
project(":platforms").subprojects.forEach { // Platform projects are where distribution happens
|
forSubProjects(":platforms") {
|
||||||
it.configureDistribution()
|
configureDistribution()
|
||||||
|
}
|
||||||
|
forSubProjects(":common:addons") {
|
||||||
|
dependencies {
|
||||||
|
"compileOnly"(project(":common:api"))
|
||||||
|
"testImplementation"(project(":common:api"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ fun Project.addonDir(dir: File, task: Task) {
|
|||||||
println("Deleting old addon: " + it.absolutePath)
|
println("Deleting old addon: " + it.absolutePath)
|
||||||
it.delete()
|
it.delete()
|
||||||
}
|
}
|
||||||
project(":common:addons").subprojects.forEach { addonProject ->
|
forSubProjects(":common:addons") {
|
||||||
val jar = (addonProject.tasks.named("jar").get() as Jar)
|
val jar = (tasks.named("jar").get() as Jar)
|
||||||
|
|
||||||
val boot = if (addonProject.project.extra.has("bootstrap") && addonProject.project.extra.get("bootstrap") as Boolean) "bootstrap/" else ""
|
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
|
||||||
val target = File(dir, boot + jar.archiveFileName.get())
|
val target = File(dir, boot + jar.archiveFileName.get())
|
||||||
|
|
||||||
val base = "${jar.archiveBaseName.get()}-${project.version}"
|
val base = "${jar.archiveBaseName.get()}-${version}"
|
||||||
|
|
||||||
println("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")
|
println("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.dfsek.terra
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream
|
|
||||||
import org.gradle.api.Project
|
|
||||||
|
|
||||||
fun Project.getGitHash(): String {
|
|
||||||
val stdout = ByteArrayOutputStream()
|
|
||||||
exec {
|
|
||||||
commandLine = mutableListOf("git", "rev-parse", "--short", "HEAD")
|
|
||||||
standardOutput = stdout
|
|
||||||
}
|
|
||||||
return stdout.toString().trim()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Project.gitClone(name: String) {
|
|
||||||
val stdout = ByteArrayOutputStream()
|
|
||||||
exec {
|
|
||||||
commandLine = mutableListOf("git", "clone", name)
|
|
||||||
standardOutput = stdout
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -43,7 +43,18 @@ fun Project.configureCompilation() {
|
|||||||
"ISSUES" to properties["terra.issues"],
|
"ISSUES" to properties["terra.issues"],
|
||||||
"LICENSE" to properties["terra.license"]
|
"LICENSE" to properties["terra.license"]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
tasks.withType<ProcessResources> {
|
||||||
|
include("**/*.*")
|
||||||
|
filter<ReplaceTokens>(
|
||||||
|
"tokens" to mapOf(
|
||||||
|
"VERSION" to version.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<Javadoc> {
|
tasks.withType<Javadoc> {
|
||||||
|
|||||||
@@ -49,11 +49,4 @@ fun Project.configureDependencies() {
|
|||||||
compileOnly("com.google.guava:guava:30.0-jre")
|
compileOnly("com.google.guava:guava:30.0-jre")
|
||||||
testImplementation("com.google.guava:guava:30.0-jre")
|
testImplementation("com.google.guava:guava:30.0-jre")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (project(":common:addons").subprojects.contains(this)) { // If this is an addon project, depend on the API.
|
|
||||||
dependencies {
|
|
||||||
compileOnly(project(":common:api"))
|
|
||||||
testImplementation(project(":common:api"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -34,9 +34,9 @@ fun Project.configureDistribution() {
|
|||||||
|
|
||||||
val installAddons = tasks.create("installAddons") {
|
val installAddons = tasks.create("installAddons") {
|
||||||
group = "terra"
|
group = "terra"
|
||||||
project(":common:addons").subprojects.forEach {
|
forSubProjects(":common:addons") {
|
||||||
it.afterEvaluate {
|
afterEvaluate {
|
||||||
dependsOn(it.tasks.getByName("build")) // Depend on addon JARs
|
dependsOn(tasks.getByName("build")) // Depend on addon JARs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,12 +52,12 @@ fun Project.configureDistribution() {
|
|||||||
dest.parentFile.mkdirs()
|
dest.parentFile.mkdirs()
|
||||||
|
|
||||||
val zip = ZipOutputStream(FileOutputStream(dest))
|
val zip = ZipOutputStream(FileOutputStream(dest))
|
||||||
|
|
||||||
project(":common:addons").subprojects.forEach { addonProject ->
|
forSubProjects(":common:addons") {
|
||||||
val jar = (addonProject.tasks.named("jar").get() as Jar)
|
val jar = (tasks.named("jar").get() as Jar)
|
||||||
println("Packaging addon ${jar.archiveFileName.get()} to ${dest.absolutePath}.")
|
println("Packaging addon ${jar.archiveFileName.get()} to ${dest.absolutePath}.")
|
||||||
|
|
||||||
val boot = if(addonProject.project.extra.has("bootstrap") && addonProject.project.extra.get("bootstrap") as Boolean) "bootstrap/" else ""
|
val boot = if(extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
|
||||||
|
|
||||||
val entry = ZipEntry("addons/$boot${jar.archiveFileName.get()}")
|
val entry = ZipEntry("addons/$boot${jar.archiveFileName.get()}")
|
||||||
zip.putNextEntry(entry)
|
zip.putNextEntry(entry)
|
||||||
@@ -88,10 +88,10 @@ fun Project.configureDistribution() {
|
|||||||
resources.computeIfAbsent("lang") { ArrayList() }.add(it.name)
|
resources.computeIfAbsent("lang") { ArrayList() }.add(it.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
project(":common:addons").subprojects.forEach { addonProject ->
|
forSubProjects(":common:addons") {
|
||||||
val jar = (addonProject.tasks.named("jar").get() as Jar).archiveFileName.get()
|
val jar = (tasks.named("jar").get() as Jar).archiveFileName.get()
|
||||||
resources.computeIfAbsent(
|
resources.computeIfAbsent(
|
||||||
if (addonProject.project.extra.has("bootstrap") && addonProject.project.extra.get("bootstrap") as Boolean) "addons/bootstrap"
|
if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "addons/bootstrap"
|
||||||
else "addons"
|
else "addons"
|
||||||
) { ArrayList() }.add(jar)
|
) { ArrayList() }.add(jar)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.dfsek.terra
|
||||||
|
|
||||||
|
import org.gradle.api.Action
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
|
||||||
|
|
||||||
|
var isPrerelease = false
|
||||||
|
|
||||||
|
|
||||||
|
fun Project.getGitHash(): String {
|
||||||
|
val stdout = ByteArrayOutputStream()
|
||||||
|
exec {
|
||||||
|
commandLine = mutableListOf("git", "rev-parse", "--short", "HEAD")
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
|
return stdout.toString().trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.gitClone(name: String) {
|
||||||
|
val stdout = ByteArrayOutputStream()
|
||||||
|
exec {
|
||||||
|
commandLine = mutableListOf("git", "clone", name)
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.forSubProjects(project: String, action: Action<Project>) {
|
||||||
|
project(project).subprojects.forEach {
|
||||||
|
action.execute(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun preRelease(preRelease: Boolean) {
|
||||||
|
isPrerelease = preRelease
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.versionProjects(project: String, version: String) {
|
||||||
|
forSubProjects(project) {
|
||||||
|
this.version = version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.version(version: String): String {
|
||||||
|
return if (!isPrerelease)
|
||||||
|
version
|
||||||
|
else //Only use git hash if it's a prerelease.
|
||||||
|
"$version-BETA+${getGitHash()}"
|
||||||
|
}
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package com.dfsek.terra
|
|
||||||
|
|
||||||
import org.apache.tools.ant.filters.ReplaceTokens
|
|
||||||
import org.gradle.api.Project
|
|
||||||
import org.gradle.kotlin.dsl.filter
|
|
||||||
import org.gradle.kotlin.dsl.withType
|
|
||||||
import org.gradle.language.jvm.tasks.ProcessResources
|
|
||||||
|
|
||||||
var isPrerelease = false
|
|
||||||
|
|
||||||
fun preRelease(preRelease: Boolean) {
|
|
||||||
isPrerelease = preRelease
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Project.versionProjects(project: String, version: String) {
|
|
||||||
project(project).subprojects.forEach {
|
|
||||||
it.version = version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Project.version(version: String): String {
|
|
||||||
return if (!isPrerelease)
|
|
||||||
version
|
|
||||||
else //Only use git hash if it's a prerelease.
|
|
||||||
"$version-BETA+${getGitHash()}"
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Project.configureVersioning() {
|
|
||||||
tasks.withType<ProcessResources> {
|
|
||||||
include("**/*.*")
|
|
||||||
filter<ReplaceTokens>(
|
|
||||||
"tokens" to mapOf(
|
|
||||||
"VERSION" to version.toString()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -51,7 +51,7 @@ public class DependencySorter {
|
|||||||
|
|
||||||
if(!range.isSatisfiedBy(dependency.getVersion())) {
|
if(!range.isSatisfiedBy(dependency.getVersion())) {
|
||||||
throw new DependencyVersionException("Addon " + addon.getID() + " specifies dependency on " + id + ", versions " + range +
|
throw new DependencyVersionException("Addon " + addon.getID() + " specifies dependency on " + id + ", versions " + range +
|
||||||
", but non-matching version " + dependency.getVersion() + " is installed..");
|
", but non-matching version " + dependency.getVersion().getFormatted() + " is installed..");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!visited.get(dependency.getID())) { // if we've not visited it yet
|
if(!visited.get(dependency.getID())) { // if we've not visited it yet
|
||||||
|
|||||||
Reference in New Issue
Block a user