mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-29 12:37:40 +01:00
Set version on build in sponge plugin
This commit is contained in:
parent
d88657f369
commit
4ca1e26f0f
@ -9,7 +9,6 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<version>1.5</version>
|
|
||||||
<artifactId>luckperms-api</artifactId>
|
<artifactId>luckperms-api</artifactId>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>luckperms-bukkit</artifactId>
|
<artifactId>luckperms-bukkit</artifactId>
|
||||||
<version>1.5</version>
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>LuckPerms</name>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>clean package</defaultGoal>
|
<defaultGoal>clean package</defaultGoal>
|
||||||
@ -46,6 +44,16 @@
|
|||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<minimizeJar>true</minimizeJar>
|
<minimizeJar>true</minimizeJar>
|
||||||
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.slf4j</pattern>
|
||||||
|
<shadedPattern>me.lucko.luckperms.lib.slf4j</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>com.zaxxer.hikari</pattern>
|
||||||
|
<shadedPattern>me.lucko.luckperms.lib.hikari</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
@ -72,14 +80,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<artifactId>luckperms-common</artifactId>
|
<artifactId>luckperms-common</artifactId>
|
||||||
<version>1.5</version>
|
<version>${project.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- LuckPerms API -->
|
<!-- LuckPerms API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<artifactId>luckperms-api</artifactId>
|
<artifactId>luckperms-api</artifactId>
|
||||||
<version>1.5</version>
|
<version>${project.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- HikariCP -->
|
<!-- HikariCP -->
|
||||||
|
@ -39,9 +39,12 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
private TrackManager trackManager;
|
private TrackManager trackManager;
|
||||||
private Datastore datastore;
|
private Datastore datastore;
|
||||||
private UuidCache uuidCache;
|
private UuidCache uuidCache;
|
||||||
|
private Logger log;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
log = LogUtil.wrap(getLogger());
|
||||||
|
|
||||||
getLog().info("Loading configuration...");
|
getLog().info("Loading configuration...");
|
||||||
configuration = new BukkitConfig(this);
|
configuration = new BukkitConfig(this);
|
||||||
|
|
||||||
@ -138,11 +141,6 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
Bukkit.getScheduler().runTask(this, r);
|
Bukkit.getScheduler().runTask(this, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Logger getLog() {
|
|
||||||
return LogUtil.wrap(getLogger());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return getDescription().getVersion();
|
return getDescription().getVersion();
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>luckperms-bungee</artifactId>
|
<artifactId>luckperms-bungee</artifactId>
|
||||||
<version>1.5</version>
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>LuckPerms</name>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>clean package</defaultGoal>
|
<defaultGoal>clean package</defaultGoal>
|
||||||
@ -46,6 +44,16 @@
|
|||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<minimizeJar>true</minimizeJar>
|
<minimizeJar>true</minimizeJar>
|
||||||
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.slf4j</pattern>
|
||||||
|
<shadedPattern>me.lucko.luckperms.lib.slf4j</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>com.zaxxer.hikari</pattern>
|
||||||
|
<shadedPattern>me.lucko.luckperms.lib.hikari</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
@ -65,14 +73,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<artifactId>luckperms-common</artifactId>
|
<artifactId>luckperms-common</artifactId>
|
||||||
<version>1.5</version>
|
<version>${project.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- LuckPerms API -->
|
<!-- LuckPerms API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<artifactId>luckperms-api</artifactId>
|
<artifactId>luckperms-api</artifactId>
|
||||||
<version>1.5</version>
|
<version>${project.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- HikariCP -->
|
<!-- HikariCP -->
|
||||||
|
@ -32,9 +32,12 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
private TrackManager trackManager;
|
private TrackManager trackManager;
|
||||||
private Datastore datastore;
|
private Datastore datastore;
|
||||||
private UuidCache uuidCache;
|
private UuidCache uuidCache;
|
||||||
|
private Logger log;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
log = LogUtil.wrap(getLogger());
|
||||||
|
|
||||||
getLog().info("Loading configuration...");
|
getLog().info("Loading configuration...");
|
||||||
configuration = new BungeeConfig(this);
|
configuration = new BungeeConfig(this);
|
||||||
|
|
||||||
@ -98,11 +101,6 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
LuckPerms.unregisterProvider();
|
LuckPerms.unregisterProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Logger getLog() {
|
|
||||||
return LogUtil.wrap(getLogger());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return getDescription().getVersion();
|
return getDescription().getVersion();
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<version>1.5</version>
|
|
||||||
<artifactId>luckperms-common</artifactId>
|
<artifactId>luckperms-common</artifactId>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
@ -30,7 +29,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<artifactId>luckperms-api</artifactId>
|
<artifactId>luckperms-api</artifactId>
|
||||||
<version>1.5</version>
|
<version>${project.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- HikariCP -->
|
<!-- HikariCP -->
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>luckperms-sponge</artifactId>
|
<artifactId>luckperms-sponge</artifactId>
|
||||||
<version>1.5</version>
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>LuckPerms</name>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>clean package</defaultGoal>
|
<defaultGoal>clean package</defaultGoal>
|
||||||
@ -46,10 +44,54 @@
|
|||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<minimizeJar>true</minimizeJar>
|
<minimizeJar>true</minimizeJar>
|
||||||
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.slf4j</pattern>
|
||||||
|
<shadedPattern>me.lucko.luckperms.lib.slf4j</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>com.zaxxer.hikari</pattern>
|
||||||
|
<shadedPattern>me.lucko.luckperms.lib.hikari</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>de.icongmbh.oss.maven.plugins</groupId>
|
||||||
|
<artifactId>javassist-maven-plugin</artifactId>
|
||||||
|
<version>1.1.0</version>
|
||||||
|
<configuration>
|
||||||
|
<includeTestClasses>false</includeTestClasses>
|
||||||
|
<transformerClasses>
|
||||||
|
<transformerClass>
|
||||||
|
<className>me.lucko.luckperms.utils.VersionUtil</className>
|
||||||
|
<properties>
|
||||||
|
<property>
|
||||||
|
<name>version</name>
|
||||||
|
<value>${project.version}</value>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</transformerClass>
|
||||||
|
</transformerClasses>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>process-classes</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>javassist</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
|
<artifactId>luckperms-sponge</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
@ -65,14 +107,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<artifactId>luckperms-common</artifactId>
|
<artifactId>luckperms-common</artifactId>
|
||||||
<version>1.5</version>
|
<version>${project.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- LuckPerms API -->
|
<!-- LuckPerms API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.lucko.luckperms</groupId>
|
<groupId>me.lucko.luckperms</groupId>
|
||||||
<artifactId>luckperms-api</artifactId>
|
<artifactId>luckperms-api</artifactId>
|
||||||
<version>1.5</version>
|
<version>${project.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- HikariCP -->
|
<!-- HikariCP -->
|
||||||
@ -89,5 +131,12 @@
|
|||||||
<version>1.7.9</version>
|
<version>1.7.9</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- javassist maven -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.icongmbh.oss.maven.plugins</groupId>
|
||||||
|
<artifactId>javassist-maven-plugin</artifactId>
|
||||||
|
<version>1.1.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -37,9 +37,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Plugin(id = "luckperms", name = "LuckPerms", version = LPSpongePlugin.VERSION, authors = {"Luck"}, description = "A permissions plugin")
|
@Plugin(id = "luckperms", name = "LuckPerms", version = "MAGIC", authors = {"Luck"}, description = "A permissions plugin")
|
||||||
public class LPSpongePlugin implements LuckPermsPlugin {
|
public class LPSpongePlugin implements LuckPermsPlugin {
|
||||||
static final String VERSION = "1.5"; // TODO load this from pom
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
@ -142,7 +141,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return VERSION;
|
return "MAGIC";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
package me.lucko.luckperms.utils;
|
||||||
|
|
||||||
|
import de.icongmbh.oss.maven.plugin.javassist.ClassTransformer;
|
||||||
|
import javassist.*;
|
||||||
|
import javassist.bytecode.AnnotationsAttribute;
|
||||||
|
import javassist.bytecode.annotation.Annotation;
|
||||||
|
import javassist.bytecode.annotation.StringMemberValue;
|
||||||
|
import me.lucko.luckperms.LPSpongePlugin;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the version value of the plugin.
|
||||||
|
* Most of the code in this class was taken from:
|
||||||
|
* https://github.com/icon-Systemhaus-GmbH/javassist-maven-plugin/blob/master/README.textile
|
||||||
|
*/
|
||||||
|
public class VersionUtil extends ClassTransformer {
|
||||||
|
private String version = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean shouldTransform(CtClass clazz) throws NotFoundException {
|
||||||
|
CtClass pluginClass = ClassPool.getDefault().get(LPSpongePlugin.class.getName());
|
||||||
|
return !clazz.equals(pluginClass) && clazz.subtypeOf(pluginClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void applyTransformations(CtClass clazz) throws Exception {
|
||||||
|
AnnotationsAttribute attribute = (AnnotationsAttribute) clazz.getClassFile().getAttribute(AnnotationsAttribute.visibleTag);
|
||||||
|
Annotation annotation = attribute.getAnnotation("org.spongepowered.api.plugin.Plugin");
|
||||||
|
StringMemberValue versionValue = (StringMemberValue) annotation.getMemberValue("version");
|
||||||
|
versionValue.setValue(version);
|
||||||
|
attribute.setAnnotation(annotation);
|
||||||
|
|
||||||
|
CtMethod getVersionMethod = clazz.getDeclaredMethod("getVersion");
|
||||||
|
CtMethod hackedVersionMethod = CtNewMethod.make("public String getVersion() { return \"" + this.version + "\"; }", clazz);
|
||||||
|
clazz.removeMethod(getVersionMethod);
|
||||||
|
clazz.addMethod(hackedVersionMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configure(final Properties properties) {
|
||||||
|
assert properties != null;
|
||||||
|
version = properties.getProperty("version");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user