Skip to content

Commit

Permalink
Update Maven/Gradle usage
Browse files Browse the repository at this point in the history
  • Loading branch information
SoSeDiK committed Jun 16, 2024
1 parent 33ec0c3 commit f48ecb4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 37 deletions.
18 changes: 11 additions & 7 deletions wiki/Using-Gradle.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
To start using NB-API, you either need to depend on its plugin version, or shade (include) it inside your plugin.

> [!IMPORTANT]
> Plugin and shaded versions have different ``artifactId``. Make sure to correctly choose the one you need!
# Option 1) NBT-API as a dependency

Add the following Entries to your Gradle build at the correct location:
Add the following entries to your Gradle build at the correct locations:

```groovy
compileOnly("de.tr7zw:item-nbt-api-plugin:VERSION")
```

(Get the current Version from [here](https://www.spigotmc.org/resources/nbt-api.7939/))
(Get the current ``VERSION`` from [here](https://modrinth.com/plugin/nbtapi/versions))

```groovy
repositories {
Expand Down Expand Up @@ -38,17 +43,16 @@ plugins {
```

The latest version of the shadow plugin can be found [here](https://github.com/johnrengelman/shadow/releases).
<br/>

Add NBT-API to your dependencies:

```groovy
implementation("de.tr7zw:item-nbt-api:VERSION")
```

(Get the current Version from [here](https://www.spigotmc.org/resources/nbt-api.7939/))
(Get the current ``VERSION`` from [here](https://modrinth.com/plugin/nbtapi/versions))

> [!IMPORTANT]
> [!WARNING]
> Make sure you're using ``item-nbt-api`` as ``artifactId``, never shade the ``-plugin`` artifact!
```groovy
Expand All @@ -62,15 +66,15 @@ repositories {
}
```

After this you can add the shadowjar configuration to relocate the api package:
After this you can add the shadowJar configuration to relocate the API package:

```groovy
shadowJar {
relocate("de.tr7zw.changeme.nbtapi", "YOUR PACKAGE WHERE THE API SHOULD END UP")
}
```

If you want to run the shadowJar task when the build task is executed, you can write like this:
If you want to run the shadowJar task when the build task is executed, you can use this:

```groovy
build {
Expand Down
71 changes: 41 additions & 30 deletions wiki/Using-Maven.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
To start using NB-API, you either need to depend on its plugin version, or shade (include) it inside your plugin.

> [!IMPORTANT]
> Plugin and shaded versions have different ``artifactId``. Make sure to correctly choose the one you need!
# Option 1) NBT-API as a dependency

Add the following Entries to your pom at the correct location:
Add the following entries to your pom at the correct locations:

```xml
<dependency>
Expand All @@ -11,7 +16,7 @@ Add the following Entries to your pom at the correct location:
</dependency>
```

(Get the current Version from [here](https://modrinth.com/plugin/nbtapi/versions))
(Get the current ``VERSION`` from [here](https://modrinth.com/plugin/nbtapi/versions))

```xml
<repositories>
Expand All @@ -34,40 +39,16 @@ depend: [NBTAPI]
# Option 2) Shading the NBT-API into your plugin
Add the following Entries to your pom at the correct location:
```xml
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>VERSION</version>
</dependency>
```

(Get the current Version from [here](https://modrinth.com/plugin/nbtapi/versions))
To include NBT-API directly in your plugin, you can use the maven shade plugin.
> [!IMPORTANT]
> Make sure you're using ``item-nbt-api`` as ``artifactId``, never shade the ``-plugin`` artifact!
```xml
<repositories>
...
<!-- CodeMC -->
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
<layout>default</layout>
</repository>
...
</repositories>
```
Add the plugin to the build configuration, as shown here:
```xml
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<version>3.6.0</version>
<executions>
<execution>
<id>shade</id>
Expand All @@ -89,7 +70,9 @@ Add the following Entries to your pom at the correct location:
</plugins>
```

Example:
The latest version of the shade plugin can be found [here](https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-shade-plugin).

Replace ``YOUR PACKAGE WHERE THE API SHOULD END UP`` with your own unique package. For example:

```xml
<relocation>
Expand All @@ -98,3 +81,31 @@ Example:
</relocation>
```

Then, add NBT-API to your dependencies by including the following entries to your pom at the correct locations:

```xml
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>VERSION</version>
</dependency>
```

(Get the current ``VERSION`` from [here](https://modrinth.com/plugin/nbtapi/versions))

> [!WARNING]
> Make sure you're using ``item-nbt-api`` as ``artifactId``, never shade the ``-plugin`` artifact!
```xml
<repositories>
...
<!-- CodeMC -->
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
<layout>default</layout>
</repository>
...
</repositories>
```

0 comments on commit f48ecb4

Please sign in to comment.