Skip to content

Commit

Permalink
Package structure with shaded dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
CubBossa committed Jan 20, 2024
1 parent 8a51bd5 commit 79ee2be
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 48 deletions.
44 changes: 8 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,10 @@ Make sure to use the latest version.
<dependencies>
<dependency>
<groupId>de.cubbossa</groupId>
<artifactId>TinyTranslations</artifactId>
<!-- alternatively TinyTranslations-paper -->
<artifactId>TinyTranslations-bukkit</artifactId>
<version>[version]</version>
</dependency>

<!-- All kyori dependencies if not yet present -->
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.14.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.14.0</version>
</dependency>
</dependencies>
```

Expand All @@ -82,8 +66,8 @@ plugin can load the latest classes. Occurring errors would potentially disable y
<configuration>
<relocations>
<relocation>
<pattern>de.cubbossa.tinytranslationsde.cubbossa.tinytranslations</pattern>
<shadedPattern>[yourpluginpath].libs.translations</shadedPattern>
<pattern>de.cubbossa.tinytranslations</pattern>
<shadedPattern>[yourpluginpath].libs.tinytranslations</shadedPattern>
</relocation>
</relocations>
</configuration>
Expand All @@ -98,24 +82,15 @@ or with gradle:
```groovy
tasks.shadowJar {
minimize()
relocate 'de.cubbossa.tinytranslations', '[yourpluginpath].libs.translations'
relocate 'de.cubbossa.tinytranslations', '[yourpluginpath].libs.tinytranslations'
}
```

### Dependencies (Spigot Libraries)

Your server must find and load the Kyori Adventure classes for Translations to work.
Either also shade them or instead register them as Spigot Libraries.
Therefore, go to your plugin.yml and add the section:
```yml
libraries:
- net.kyori:adventure-api:4.14.0
- net.kyori:adventure-platform-bukkit:4.3.2
- net.kyori:adventure-text-minimessage:4.14.0
- net.kyori:adventure-text-serializer-legacy:4.14.0
- net.kyori:adventure-text-serializer-gson:4.14.0
- net.kyori:adventure-text-serializer-plain:4.14.0
```
Either use `TinyTranslations-paper` to use the Adventure classes provided by paper or use
`TinyTranslations-bukkit` to include them as shaded dependencies.

## Overview

Expand Down Expand Up @@ -197,10 +172,8 @@ class ExamplePlugin extends JavaPlugin {
Translations translations;

public void onEnable() {
// Enable Framework
TranslationsFramework.enable(new File(getDataFolder(), "/.."));
// create a Translations instance for your plugin
translations = TranslationsFramework.application("MyPlugin");
translations = TinyTranslationsBukkit.application(this);

// define the storage types for your plugins locale
translations.setMessageStorage(new PropertiesMessageStorage(getLogger(), new File(getDataFolder(), "/lang/")));
Expand Down Expand Up @@ -230,7 +203,6 @@ class ExamplePlugin extends JavaPlugin {
public void onDisable() {
// close open Translations instance
translations.close();
TranslationsFramework.disable();
}
}
```
Expand Down
42 changes: 42 additions & 0 deletions TinyTranslations-bukkit-common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.cubbossa</groupId>
<artifactId>TinyTranslations</artifactId>
<version>4.3.3</version>
</parent>

<artifactId>TinyTranslations-bukkit-common</artifactId>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>de.cubbossa</groupId>
<artifactId>TinyTranslations-common</artifactId>
<version>4.3.3</version>
</dependency>

<!--This adds the Spigot API artifact to the build -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
64 changes: 52 additions & 12 deletions TinyTranslations-bukkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,66 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>de.cubbossa:TinyTranslations-common</include>
<include>de.cubbossa:TinyTranslations-bukkit-common</include>
<include>net.kyori:adventure-api</include>
<include>net.kyori:adventure-platform-bukkit</include>
<include>net.kyori:adventure-text-minimessage</include>
<include>net.kyori:adventure-text-serializer-legacy</include>
<include>net.kyori:adventure-text-serializer-gson</include>
<include>net.kyori:adventure-text-serializer-plain</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>de.cubbossa.tinytranslations.libs.kyori</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

<dependencies>
<dependency>
<groupId>de.cubbossa</groupId>
<artifactId>TinyTranslations-common</artifactId>
<version>4.3.3</version>
</dependency>

<!--This adds the Spigot API artifact to the build -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<groupId>de.cubbossa</groupId>
<artifactId>TinyTranslations-bukkit-common</artifactId>
<version>4.3.3</version>
</dependency>
</dependencies>

</project>
70 changes: 70 additions & 0 deletions TinyTranslations-paper/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.cubbossa</groupId>
<artifactId>TinyTranslations</artifactId>
<version>4.3.3</version>
</parent>

<artifactId>TinyTranslations-paper</artifactId>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>de.cubbossa:TinyTranslations-common</include>
<include>de.cubbossa:TinyTranslations-bukkit-common</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>


<dependencies>
<dependency>
<groupId>de.cubbossa</groupId>
<artifactId>TinyTranslations-common</artifactId>
<version>4.3.3</version>
</dependency>
<dependency>
<groupId>de.cubbossa</groupId>
<artifactId>TinyTranslations-bukkit-common</artifactId>
<version>4.3.3</version>
</dependency>
</dependencies>
</project>
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<name>TinyTranslations</name>
<modules>
<module>TinyTranslations-common</module>
<module>TinyTranslations-bukkit-common</module>
<module>TinyTranslations-paper</module>
<module>TinyTranslations-bukkit</module>
</modules>

Expand Down

0 comments on commit 79ee2be

Please sign in to comment.