Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ plugins {

// pom packaging for root
id "java-platform"

id "idea"
}

allprojects {
Expand Down Expand Up @@ -149,6 +151,9 @@ subprojects {

maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://papermc.io/repo/repository/maven-public/" }
maven { url "https://repo.codemc.io/repository/maven-public/" }

maven{ url "https://repo.pl3x.net/"}

// Note: Subprojects can't have repo overrides to we have to put it here
// Define a Ivy repo for the font width data (that way we don't need another plugin!)
Expand Down
2 changes: 1 addition & 1 deletion bukkit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {
// Source: https://docs.gradle.org/6.8.3/userguide/java_library_plugin.html
compileOnly project(":common:serverversion")

compileOnly "com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT"
compileOnly("net.pl3x.purpur:purpur-api:1.16.5-R0.1-SNAPSHOT")

// Fun fact: paper/spigot/etc doesn't include netty! (as it's from NMS)
// So instead let's use the netty version that we were using before (inherited from bungeecord)
Expand Down
39 changes: 30 additions & 9 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
buildscript {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guessing you discussed this with @Prouser123 - gets the okay from me if he approves.

repositories {
mavenCentral();
jcenter();
google();
}
dependencies {
classpath group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '2.2.0.201212191850-r'
classpath("com.squareup:javapoet:1.13.0")
classpath("com.google.guava:guava:30.1-jre")
classpath("de.skuzzle:semantic-version:2.1.0")
classpath("org.projectlombok:lombok:1.18.20")
}
}

plugins {
// Nemerosa Versioning Plugin for the build info
id "net.nemerosa.versioning" version "2.14.0"

// for "api" in dependencies { }
id "java-library"

id 'idea'
}

dependencies {
Expand All @@ -18,7 +35,9 @@ dependencies {
// Font width data (see above)
dddResource "dumbdogdiner:mc-font-extractor:main:mojangles_width_data@json"

implementation "com.google.code.gson:gson:2.8.6"
api "com.google.code.gson:gson:2.8.6"
compileOnly "com.google.code.gson:gson:2.8.6"
implementation("de.skuzzle:semantic-version:2.1.0")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for, aside from the blindingly obvious?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wouldn't compile until I did that and idk why until I funfuck gradle

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment refers to line 40 btw - guessing it's just a semver package but worth consulting @Prouser123 about modifying the build file if you haven't already.


// Dependencies available in both bukkit and bungee
compileOnly "net.md-5:bungeecord-chat:1.16-R0.5-SNAPSHOT"
Expand Down Expand Up @@ -49,25 +68,26 @@ dependencies {
def dataBuildTimestamp = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"

// Import the filter
import de.skuzzle.semantic.Version
import org.apache.tools.ant.filters.ReplaceTokens

// Define the map containing the tokens we want to replace
def tokensMap = [
BUILDINFO_VERSION: project.rootProject.version,
BUILDINFO_VERSION : project.rootProject.version,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird formatting, but I will let it pass.

BUILDINFO_DATEFORMAT: dataBuildTimestamp,
BUILDINFO_TIMESTAMP: new java.text.SimpleDateFormat(dataBuildTimestamp).format(new Date()),
BUILDINFO_COMMIT: versioning.info.commit,
BUILDINFO_BRANCH: versioning.info.branch,
BUILDINFO_ISDIRTY: versioning.info.dirty.toString()
]
BUILDINFO_TIMESTAMP : new java.text.SimpleDateFormat(dataBuildTimestamp).format(new Date()),
BUILDINFO_COMMIT : versioning.info.commit,
BUILDINFO_BRANCH : versioning.info.branch,
BUILDINFO_ISDIRTY : versioning.info.dirty.toString()
]

// Create task to replace the tokens with their actual values
// NOTE: At the moment this replaces tokens *globally* (format eg. @BUILDINFO_COMMIT@ in source code)
task processSourceTokens(type: Sync) {
from sourceSets.main.java
into "build/processed/src/main/java"
filter(ReplaceTokens, tokens: tokensMap)

// Pretty print the build info
println("\n----- (Common) StickyAPI Build Info -----\n")
tokensMap.each { println "${String.format("%1\$-" + 10 + "s", it.key.replace("BUILDINFO_", "").toLowerCase())}\t${it.value}" }
Expand All @@ -85,7 +105,7 @@ compileJava.source = processSourceTokens.outputs

// Font Width Info
task copyMCFontExtractor(type: Copy) {
def path = project.configurations.dddResource.find {it.name.startsWith("mc-font-extractor") }
def path = project.configurations.dddResource.find { it.name.startsWith("mc-font-extractor") }
println("common: Found font data at: " + path)
from file(path)
// into file("src/main/resources")
Expand Down Expand Up @@ -115,3 +135,4 @@ task commonSources(type: Jar, dependsOn: classes) {

// Common build: override the usual sources output with our one containing ServerVersion
tasks.sources.finalizedBy commonSources

73 changes: 73 additions & 0 deletions common/buildinfo.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
buildscript {
repositories {
mavenCentral();
jcenter();
google();
}
dependencies {
classpath group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '2.2.0.201212191850-r'
classpath("com.squareup:javapoet:1.13.0")
classpath("com.google.guava:guava:30.1-jre")
classpath("de.skuzzle:semantic-version:2.1.0")
classpath("org.projectlombok:lombok:1.18.20")
}
}

import com.squareup.javapoet.CodeBlock
import com.squareup.javapoet.FieldSpec
import com.squareup.javapoet.JavaFile
import com.squareup.javapoet.MethodSpec
import com.squareup.javapoet.TypeName
import com.squareup.javapoet.TypeSpec
import de.skuzzle.semantic.Version
import lombok.Getter


import javax.lang.model.element.Modifier
import java.text.SimpleDateFormat

task DoBuildInfo {
doFirst {
TypeSpec buildInfoClass = TypeSpec.classBuilder("BuildInfo")
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.addField(FieldSpec.builder(Version.class, "version")
.addModifiers(Modifier.PRIVATE, Modifier.FINAL)
.addAnnotation(Getter.class)
.initializer("\$T.parseVersion(\$S)", Version.class, Version.parseVersion("3.0.2"))
.build()
)

.addMethod(
MethodSpec.methodBuilder("getTimestamp")
.returns(String)
.addCode(CodeBlock.builder()
.beginControlFlow("try")
.addStatement("return new \$T(\$S).parse(\$S).toString()", SimpleDateFormat.class, "yyyy-MM-dd'T'HH:mm:ss.SSSZ", "2021-04-08T14:34:13.901-0600")
.nextControlFlow("catch (\$T e)", Exception.class)
.addStatement("e.printStackTrace()")
.addStatement("return null")
.endControlFlow()
.build()
)

.addModifiers(Modifier.PUBLIC).build()
)

.addField(FieldSpec.builder(String, "branch")
.addModifiers(Modifier.PRIVATE, Modifier.FINAL)
.addAnnotation(Getter)
.initializer("\"\$s\"", branch)
.build()
)

.addField(FieldSpec.builder(TypeName.BOOLEAN, "dirty")
.addModifiers(Modifier.PRIVATE, Modifier.FINAL)
.addAnnotation(Getter)
.initializer("true")
.build()
)
.build()
JavaFile jfile = JavaFile.builder(getProject().getRootProject().getGroup() as String, buildInfoClass).build();
jfile.writeTo(getProject().getProjectDir().toPath().resolve("src/main/java").toFile());
}
}
31 changes: 31 additions & 0 deletions common/src/main/java/com/dumbdogdiner/BuildInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2020-2021 DumbDogDiner <dumbdogdiner.com>. All rights reserved.
* Licensed under the MIT license, see LICENSE for more information...
*/
package com.dumbdogdiner;

import de.skuzzle.semantic.Version;
import java.lang.Exception;
import java.lang.String;
import java.text.SimpleDateFormat;
import lombok.Getter;

public final class BuildInfo {
@Getter
private final Version version = Version.parseVersion("3.0.2");

@Getter
private final String branch = "branch";

@Getter
private final boolean dirty = true;

public String getTimestamp() {
try {
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").parse("2021-04-08T14:34:13.901-0600").toString();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
Loading