Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite Setup #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
9 changes: 6 additions & 3 deletions .vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ export default defineConfig({
link: "/docs/introduction",
},
{
text: "Setup",
text: "Getting Started",
items: [
{ text: "Dependencies", link: "/docs/setup/dependencies" },
{
text: "Project Setup",
link: "/docs/starting-out/project-setup"
},
{
text: "Your First Server",
link: "/docs/setup/your-first-server",
link: "/docs/starting-out/your-first-server",
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ The goal of this wiki is to familiarize you with our library. The most important

The project Javadoc is currently hosted [here](https://minestom.github.io/Minestom/). Additionally, we do have a [Discord server](https://discord.gg/pkFRvqB) where you can ask anything you want.

If you do not know how you landed here, Minestom is a complete rewrite of the Minecraft server software without any Mojang code. You can learn more about it [here](https://github.com/Minestom/Minestom).
If you do not know how you landed here: Minestom is a complete rewrite of the Minecraft server software without any Mojang code. You can learn more about it [here](https://github.com/Minestom/Minestom).
96 changes: 0 additions & 96 deletions docs/setup/dependencies.md

This file was deleted.

179 changes: 179 additions & 0 deletions docs/starting-out/project-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
---
description: Describes how to set up a Minestom project.
---

<script setup>
import axios from "axios";
import { ref, onMounted } from 'vue'

const version = ref("<--version-->");

const fetchVersion = async () => {
try {
const response = await axios.get("/api/latest-version");
const ver = response.data.latestVersion;
if (ver != null) {
version.value = ver;
}
} catch (error) {
console.error("Error fetching libraries:", error);
}
}

onMounted(() => {
fetchVersion();
});
</script>

# Project Setup

## Adding the dependency

Minestom is available on Maven Central.
Get it by enabling Maven Central (on Gradle) and adding a version to your dependencies.

:::tabs

== Gradle (Groovy)

```groovy-vue
repositories {
mavenCentral()
}
dependencies {
implementation 'net.minestom:minestom-snapshots:{{ version }}'
}
```

== Gradle (Kotlin)

```kotlin-vue
repositories {
mavenCentral()
}
dependencies {
implementation("net.minestom:minestom-snapshots:{{version}}")
}
```

== Maven

```xml-vue
<dependencies>
<!-- ... -->
<dependency>
<groupId>net.minestom</groupId>
<artifactId>minestom-snapshots</artifactId>
<version>{{version}}</version>
</dependency>
</dependencies>
```

:::

The version string is always the first 10 characters of a commit hash. You can view commits
[here](https://github.com/Minestom/Minestom/commits/master/).

Minestom PR branches are also published and can be used to preview upcoming features. For such branches, the version
string is `{branch}-{first 10 chars of commit}`. For example, the 1_20_5 branch was usable with the version string
`1_20_5-dd965f4bb8`.

## Setting up shading

For Gradle users, we will use [the "Shadow" plugin](https://imperceptiblethoughts.com/shadow/introduction/) to include Minestom in the JAR file.
Copy link
Member

Choose a reason for hiding this comment

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

This should be part of the gradle tabs


For Maven users, you will need [the "Shade" plugin](https://maven.apache.org/plugins/maven-shade-plugin/). If you use Maven and would like to contribute an example
Copy link
Member

Choose a reason for hiding this comment

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

This should be part of the maven tab

it would be appreciated :)

::: warning
Copy link
Member

Choose a reason for hiding this comment

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

This should be part of the gradle tabs

As of the time writing this, the original shadow plugin from johnrengelman has not been updated for Java 21 support, so we'll use a fork in this example.
Copy link
Member

Choose a reason for hiding this comment

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

Please link GradleUp/shadow#908 for now

:::

:::tabs

== Gradle (Groovy)

```groovy
plugins {
id "io.github.goooler.shadow" version "8.1.7"
}
```

== Gradle (Kotlin)

```kts
plugins {
id("io.github.goooler.shadow") version "8.1.7"
}
```

:::

## Finishing the configuration

Finally, to create a runnable JAR, set your main class to be run.

With all of this done, all we need to do is run the `shadowJar` task to create a working uber (fat) jar! (The jar will be put in `/build/libs/` by default)
Copy link
Member

Choose a reason for hiding this comment

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

Gradle specific again


Below is a complete `build.gradle`/`build.gradle.kts` file

:::tabs

== Gradle (Groovy)

```groovy
plugins {
id 'java'
id "io.github.goooler.shadow" version "8.1.7"
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {
// Change this to the latest version
implementation 'net.minestom:minestom-snapshots:<version>'
}

jar {
manifest {
// Change this to your main class
attributes 'Main-Class': 'org.example.Main'
}
}
```

== Gradle (Kotlin)

```kts
plugins {
id("java")
// If you need Kotlin support, use the kotlin("jvm") plugin
id("io.github.goooler.shadow") version "8.1.7"
}

group = "org.example"
version = "1.0-SNAPSHOT"

repositories {
mavenCentral()
}

dependencies {
// Change this to the latest version
implementation("net.minestom:minestom-snapshots:<version>")
}

tasks.withType<Jar> {
manifest {
// Change this to your main class
attributes["Main-Class"] = "org.example.Main"
}
}
```
Copy link
Member

Choose a reason for hiding this comment

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

Should have a maven tab here, even if it only asks someone to PR a correct pom file


:::
Loading