Skip to content
Draft
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: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ bin
.project
.idea
*.code-workspace
*.ipr
*.iws

# Generated resources
common/src/main/resources/generated/*
**/src/main/resources/generated/*
**/src/gen/
43 changes: 29 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ plugins {

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

id "idea"
}

allprojects {
group = "com.dumbdogdiner"
version = "3.0.2"
version = "3.1.0"

// java plugin is applied in subprojects
apply plugin: "jacoco"
Expand Down Expand Up @@ -172,6 +174,10 @@ subprojects {
// Maven Central is defined in allprojects (for JaCoCo)
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/" }
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots"}

// 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 Expand Up @@ -219,11 +225,16 @@ subprojects {
}
}

task sources(type: Jar, dependsOn: classes) {
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set("sources")
from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc
archiveClassifier.set('javadoc')
}


// Javadoc Fixes
// Some environments (such as the builder image) do not use UTF-8 as the default encoding!
Expand All @@ -238,22 +249,25 @@ subprojects {

// Run the linter before compiling the source code.
tasks.compileJava.dependsOn spotlessApply
tasks.build.dependsOn sources
tasks.build.dependsOn sourcesJar
tasks.javadoc.finalizedBy(javadocJar)



// Per-module publishing (eg. stickyapi-common)
if (project.name != "serverversion") { // Ignore :common:serverversion (already included in :common)
publishing {
publications {
gprSubprojects(MavenPublication) {
artifactId "${rootProject.name}-${project.name}"
println("[debug] ${project.name} found component: " + components.java)

from(components.java)
artifact sources // Publish the output of the sources task
}
publishing {
publications {
gprSubprojects(MavenPublication) {
artifactId "${rootProject.name}-${project.name}"
println("[debug] ${project.name} found component: " + components.java)

from(components.java)
artifact sourcesJar // Publish the output of the sourcesJar task
artifact javadocJar // Publish the output of the javadocJar task
}
}
}

}

// Root build: include dependencies (see below)
Expand Down Expand Up @@ -296,7 +310,8 @@ task copySubprojectJars(type: Copy, dependsOn: subprojects.jar) {

// Copy subproject jar and sources
from(subprojects.jar)
from(subprojects.sources)
from(subprojects.sourcesJar)
from(subprojects.javadocJar)
into rootProject.file("build/libs/modules")
}

Expand Down
17 changes: 17 additions & 0 deletions buildSrc/src/main/groovy/DownloadTask.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction

class DownloadTask extends DefaultTask {
@Input
String sourceUrl

@OutputFile
File target

@TaskAction
void download() {
ant.get(src: sourceUrl, dest: target)
}
}
7 changes: 5 additions & 2 deletions bukkit/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
dependencies {
api project(":common") // api - transistively expose common dependency when implementing :bukkit
// I don't know why i need to do this rn, i have to figure it out???
//compileOnly project(":common").sourceSets.serverVersion.output
testImplementation project(":common").sourceSets.test.output


// 3.0.2: serverversion is not transistive from common
// Since we depend on common, the class is still available at runtime
// -------------------------
// Why: "compileOnly" | This typically includes dependencies which are shaded when found at runtime.
// 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
181 changes: 126 additions & 55 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,85 +1,144 @@
buildscript {
repositories {
mavenCentral();
}
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")
}
}

/* TODO: use features, and publish only the combined feature with BOTH serverversion and genreated
For now this is fine */
plugins {
// Nemerosa Versioning Plugin for the build info
id "net.nemerosa.versioning" version "2.14.0"

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

// For IntelliJ
id "idea"
}

// For now: we will just combine the output directory of each sourceset
sourceSets {
generated {
// java.outputDir = file('build/classes/main')
java.srcDir file('src/gen/java')
resources.srcDir file('src/gen/resources')
//compileClasspath += main.compileClasspath
}

serverVersion {
// java.outputDir = file('build/classes/main')
java.srcDir file('src/serverVersion/java')

// No resources necessary
//resources.srcDir file('src/serverVersion/resources')
}

main {
java.outputDir = file('build/classes/main')
resources.srcDirs += file('src/gen/resources')
/*compileClasspath += generated.output
runtimeClasspath += generated.output
compileClasspath += serverVersion.output
runtimeClasspath += serverVersion.output*/
}

test {
compileClasspath += generated.output
runtimeClasspath += generated.output
// compileClasspath += serverVersion.output
// runtimeClasspath += serverVersion.output
// resources.srcDirs += file('src/gen/resources')
}
}
//System.out.println(sourceSets.generated.getApiConfigurationName())
configurations {
generatedCompile.extendsFrom(compile)

serverVersionCompile.extendsFrom(compile)
generatedApi

//
// generatedApi{
// extendsFrom(generatedCompile)
// canBeResolved = false
// canBeConsumed = true
// }

testImplementation.extendsFrom compileOnly
}

dependencies {
// Depend on the config project
api project(":config") // api - transistively expose config dependency when implementing :common
testImplementation project(":config").sourceSets.test.output

api sourceSets.serverVersion.output
api sourceSets.generated.output

// LocaleProviderTest - add snakeyaml so YamlProvider (from the :config project) can work properly
// testRuntimeOnly = only accessible during the test job
testRuntimeOnly "org.yaml:snakeyaml:1.27"

// Font width data (see above)
dddResource "dumbdogdiner:mc-font-extractor:main:mojangles_width_data@json"

implementation "com.google.code.gson:gson:2.8.6"
// Explicit GSON
api "com.google.code.gson:gson:2.8.6"

// Dependencies available in both bukkit and bungee
compileOnly "net.md-5:bungeecord-chat:1.16-R0.5-SNAPSHOT"

// Only included in paper? (ShortID.java)
compileOnly "commons-lang:commons-lang:2.6"

// Needed for Buildinfo, explicitly
generatedCompileClasspath("org.jetbrains:annotations:20.1.0")

// For buildinfo versioning; we want api so that it gets exposed to consuming thingies
api("de.skuzzle:semantic-version:2.1.0")
generatedImplementation("de.skuzzle:semantic-version:2.1.0")

// Include the most generic forms possible, used only by ServerVersion
serverVersionCompileOnly "net.md-5:bungeecord-api:1.16-R0.5-SNAPSHOT"
serverVersionCompileOnly "org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT"

testImplementation "net.md-5:bungeecord-api:1.16-R0.5-SNAPSHOT"
testImplementation "org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT"
testImplementation ('org.eclipse.jgit:org.eclipse.jgit:2.2.0.201212191850-r')
}



test {
// Dynamically we can have it grab allllllll of the other dependancy types, this is a todo
}



// Use --add-opens to ensure functionality of FieldUtil [java.lang.reflect.Field] (required in Java 16+)
// This will export java.lang.reflect to unnamed modules (eg. stickyapi) so that FieldUtil can still function.
// Alternative: ["--illegal-access=warn"] (same functionality as pre Java 16)
// JEP: https://openjdk.java.net/jeps/396
test.jvmArgs = ["--add-opens=java.base/java.lang.reflect=ALL-UNNAMED"]

/*
Build Info
----------
The following lines (and the processSourceTokens task) serve to embed build information
such as versions, timestamps, commit details, as well as branch and working tree status
into StickyAPI during build-time.

When using StickyAPI, these values can be retrieved from their respective getters at
com.dumbdogdiner.stickyapi.Stickyapi

----------
idea {
module {
sourceDirs += file('src/gen/java')
generatedSourceDirs += file('src/gen/java')
}
}

The processSourceTokens task will also print out a list of all the tokens to be added
to the build, for debugging reasons (eg. to ensure the info is correct)

These is also an accompanying test at (test src) com.dumbdogdiner.stickyapi.StickyAPITest
*/

// Set the timestamp format
def dataBuildTimestamp = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"

// Import the filter
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_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()
]

// 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}" }
}
// Use the filter task as the input for compileJava
compileJava.source = processSourceTokens.outputs


/*
Expand All @@ -91,33 +150,45 @@ 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")
// - Please keep this comment for future reference.
// - This is how we would do this if we weren't also adding build info (see processSourceTokens, above comments)
destinationDir file("src/main/resources/generated/")
into file("src/gen/resources/")
rename "mc-font-extractor-main-mojangles_width_data.json", "mojangles_width_data.json"
}
tasks.processGeneratedResources.dependsOn(copyMCFontExtractor)


// Run the font data copier
tasks.processResources.dependsOn copyMCFontExtractor

apply from: 'versioning-buildinfo.gradle'
tasks.compileJava.dependsOn(buildInfo)

// Common build: create a jar from the :common & :common:serverversion projects
// Common build: create a jar
jar {
dependsOn generatedClasses
dependsOn serverVersionClasses
dependsOn classes
from sourceSets.main.output
from project(":common:serverversion").sourceSets.main.output
from sourceSets.generated.output
from sourceSets.serverVersion.output
setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}

// Common build: create uber sources from subproject sources
task commonSources(type: Jar, dependsOn: classes) {
dependsOn jar
archiveClassifier.set("sources")
// Use source code from :common & :common:serverversion projects
from sourceSets.main.allSource
from project(":common:serverversion").sourceSets.main.allSource
from sourceSets.generated.allSource
from sourceSets.serverVersion.allSource
setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}

task cleanGenerated(type: Delete){
delete 'src/gen/'
}

// Common build: override the usual sources output with our one containing ServerVersion
tasks.sources.finalizedBy commonSources
tasks.clean.finalizedBy(cleanGenerated)
tasks.sourcesJar.finalizedBy commonSources
4 changes: 0 additions & 4 deletions common/serverversion/build.gradle

This file was deleted.

3 changes: 0 additions & 3 deletions common/serverversion/lombok.config

This file was deleted.

This file was deleted.

Loading