Skip to content

Commit

Permalink
Fix build errors reporting to the wrong directory by updating blossom (
Browse files Browse the repository at this point in the history
…GeyserMC#4771)

* Fix build errors reporting to the wrong directory by updating blossom

* Add info comment
  • Loading branch information
AlexProgrammerDE authored Jun 20, 2024
1 parent ded6f6b commit fc529a6
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 19 deletions.
28 changes: 16 additions & 12 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import net.kyori.blossom.BlossomExtension

plugins {
// Allow blossom to mark sources root of templates
idea
alias(libs.plugins.blossom)
id("geyser.publish-conventions")
}
Expand Down Expand Up @@ -84,16 +84,20 @@ tasks.processResources {
}
}

configure<BlossomExtension> {
val mainFile = "src/main/java/org/geysermc/geyser/GeyserImpl.java"
val info = GitInfo()

replaceToken("\${version}", "${project.version} (${info.gitVersion})", mainFile)
replaceToken("\${gitVersion}", info.gitVersion, mainFile)
replaceToken("\${buildNumber}", info.buildNumber, mainFile)
replaceToken("\${branch}", info.branch, mainFile)
replaceToken("\${commit}", info.commit, mainFile)
replaceToken("\${repository}", info.repository, mainFile)
sourceSets {
main {
blossom {
val info = GitInfo()
javaSources {
property("version", "${project.version} (${info.gitVersion})")
property("gitVersion", info.gitVersion)
property("buildNumber", info.buildNumber.toString())
property("branch", info.branch)
property("commit", info.commit)
property("repository", info.repository)
}
}
}
}

fun Project.buildNumber(): Int =
Expand Down
37 changes: 37 additions & 0 deletions core/src/main/java-templates/org/geysermc/geyser/BuildData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

package org.geysermc.geyser;

// The constants are replaced before compilation
public class BuildData {
public static final String GIT_VERSION = "{{ gitVersion }}";
public static final String VERSION = "{{ version }}";

public static final String BUILD_NUMBER = "{{ buildNumber }}";
public static final String BRANCH = "{{ branch }}";
public static final String COMMIT = "{{ commit }}";
public static final String REPOSITORY = "{{ repository }}";
}
12 changes: 6 additions & 6 deletions core/src/main/java/org/geysermc/geyser/GeyserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ public class GeyserImpl implements GeyserApi {
.enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES);

public static final String NAME = "Geyser";
public static final String GIT_VERSION = "${gitVersion}";
public static final String VERSION = "${version}";
public static final String GIT_VERSION = BuildData.GIT_VERSION;
public static final String VERSION = BuildData.VERSION;

public static final String BUILD_NUMBER = "${buildNumber}";
public static final String BRANCH = "${branch}";
public static final String COMMIT = "${commit}";
public static final String REPOSITORY = "${repository}";
public static final String BUILD_NUMBER = BuildData.BUILD_NUMBER;
public static final String BRANCH = BuildData.BRANCH;
public static final String COMMIT = BuildData.COMMIT;
public static final String REPOSITORY = BuildData.REPOSITORY;

/**
* Oauth client ID for Microsoft authentication
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ architectury-plugin = "3.4-SNAPSHOT"
architectury-loom = "1.6-SNAPSHOT"
minotaur = "2.8.7"
lombok = "8.4"
blossom = "1.2.0"
blossom = "2.1.0"

[libraries]
base-api = { group = "org.geysermc.api", name = "base-api", version.ref = "base-api" }
Expand Down

0 comments on commit fc529a6

Please sign in to comment.