Skip to content

Commit

Permalink
Merge pull request #68 from GeorgeV220/gradle-kotlin
Browse files Browse the repository at this point in the history
Migrate from Maven to Gradle Kotlin Build
  • Loading branch information
unldenis authored Nov 3, 2024
2 parents 445d537 + 0fdf7a5 commit c8bb23c
Show file tree
Hide file tree
Showing 25 changed files with 677 additions and 568 deletions.
97 changes: 50 additions & 47 deletions .github/workflows/release-on-version-change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Release on Version Change
on:
push:
branches:
- master # Change this to your target branch
- master
paths:
- 'pom.xml'
- '**/build.gradle.kts'

permissions:
contents: write
Expand All @@ -15,48 +15,51 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Java
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'

- name: Get project version
id: get_version
run: echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV

- name: Check if version has changed
id: check_version
run: |
latest_version=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
current_version=${{ env.VERSION }}
echo "Latest version: $latest_version"
echo "Current version: $current_version"
if [ "$current_version" != "$latest_version" ]; then
echo "::set-output name=version_changed::true"
else
echo "::set-output name=version_changed::false"
fi
- name: Create GitHub Release
if: steps.check_version.outputs.version_changed == 'true'
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
name: Release ${{ env.VERSION }}
body: |
Release of version ${{ env.VERSION }}.
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Log the output for debugging
- name: Log Release Creation Status
run: |
echo "Release creation status:"
echo "${{ steps.create_release.outputs }}"
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Java
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'

- name: Get project version
id: get_version
run: |
# Run Gradle to get the project version
version=$(./gradlew -q printVersion)
echo "VERSION=${version}" >> $GITHUB_ENV
- name: Check if version has changed
id: check_version
run: |
latest_version=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
current_version=${{ env.VERSION }}
echo "Latest version: $latest_version"
echo "Current version: $current_version"
if [ "$current_version" != "$latest_version" ]; then
echo "::set-output name=version_changed::true"
else
echo "::set-output name=version_changed::false"
fi
- name: Create GitHub Release
if: steps.check_version.outputs.version_changed == 'true'
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
name: Release ${{ env.VERSION }}
body: |
Release of version ${{ env.VERSION }}.
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Log the output for debugging
- name: Log Release Creation Status
run: |
echo "Release creation status:"
echo "${{ steps.create_release.outputs }}"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
# IntelliJ
out/

# Gradle
*/build/
.gradle/

# Compiled class file
*.class

Expand Down
27 changes: 27 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Hologram-Lib - An asynchronous, high-performance Minecraft Hologram library
* for servers running versions 1.8 to 1.18.
*
* Copyright (C) 2023 unldenis <https://github.com/unldenis>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
}
71 changes: 71 additions & 0 deletions buildSrc/src/main/kotlin/buildlogic.java-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Hologram-Lib - An asynchronous, high-performance Minecraft Hologram library
* for servers running versions 1.8 to 1.18.
*
* Copyright (C) 2023 unldenis <https://github.com/unldenis>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

plugins {
`java-library`
`maven-publish`
}

repositories {
mavenLocal()
maven {
url = uri("https://repo.maven.apache.org/maven2/")
}

maven {
url = uri("https://repo.dmulloy2.net/repository/public/")
}

maven {
url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
}

maven {
url = uri("https://repo.codemc.io/repository/maven-releases/")
}

maven {
url = uri("https://repo.codemc.io/repository/maven-snapshots/")
}

maven {
url = uri("https://jitpack.io")
}
}

dependencies {
compileOnly("org.jetbrains:annotations:24.0.1")
}

group = "org.holoeasy"
version = "4.2.0"
java.sourceCompatibility = JavaVersion.VERSION_1_8

publishing {
publications.create<MavenPublication>("maven") {
from(components["java"])
}
}

tasks.register("printVersion") {
doLast {
println(project.version)
}
}
11 changes: 11 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[versions]
com-comphenix-protocol-protocollib = "5.3.0"
com-github-retrooper-packetevents-spigot = "2.5.0"
org-jetbrains-kotlin-kotlin-stdlib = "1.9.21"
org-spigotmc-spigot-api = "1.16.5-R0.1-SNAPSHOT"

[libraries]
com-comphenix-protocol-protocollib = { module = "com.comphenix.protocol:ProtocolLib", version.ref = "com-comphenix-protocol-protocollib" }
com-github-retrooper-packetevents-spigot = { module = "com.github.retrooper:packetevents-spigot", version.ref = "com-github-retrooper-packetevents-spigot" }
org-jetbrains-kotlin-kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "org-jetbrains-kotlin-kotlin-stdlib" }
org-spigotmc-spigot-api = { module = "org.spigotmc:spigot-api", version.ref = "org-spigotmc-spigot-api" }
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit c8bb23c

Please sign in to comment.