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>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<version>1.5</version>
|
||||
<artifactId>luckperms-api</artifactId>
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -10,9 +10,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>luckperms-bukkit</artifactId>
|
||||
<version>1.5</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>LuckPerms</name>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
@ -46,6 +44,16 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<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>
|
||||
</execution>
|
||||
</executions>
|
||||
@ -72,14 +80,14 @@
|
||||
<dependency>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<artifactId>luckperms-common</artifactId>
|
||||
<version>1.5</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- LuckPerms API -->
|
||||
<dependency>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<artifactId>luckperms-api</artifactId>
|
||||
<version>1.5</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- HikariCP -->
|
||||
|
@ -39,9 +39,12 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
private TrackManager trackManager;
|
||||
private Datastore datastore;
|
||||
private UuidCache uuidCache;
|
||||
private Logger log;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
log = LogUtil.wrap(getLogger());
|
||||
|
||||
getLog().info("Loading configuration...");
|
||||
configuration = new BukkitConfig(this);
|
||||
|
||||
@ -138,11 +141,6 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
Bukkit.getScheduler().runTask(this, r);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLog() {
|
||||
return LogUtil.wrap(getLogger());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return getDescription().getVersion();
|
||||
|
@ -10,9 +10,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>luckperms-bungee</artifactId>
|
||||
<version>1.5</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>LuckPerms</name>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
@ -46,6 +44,16 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<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>
|
||||
</execution>
|
||||
</executions>
|
||||
@ -65,14 +73,14 @@
|
||||
<dependency>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<artifactId>luckperms-common</artifactId>
|
||||
<version>1.5</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- LuckPerms API -->
|
||||
<dependency>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<artifactId>luckperms-api</artifactId>
|
||||
<version>1.5</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- HikariCP -->
|
||||
|
@ -32,9 +32,12 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
||||
private TrackManager trackManager;
|
||||
private Datastore datastore;
|
||||
private UuidCache uuidCache;
|
||||
private Logger log;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
log = LogUtil.wrap(getLogger());
|
||||
|
||||
getLog().info("Loading configuration...");
|
||||
configuration = new BungeeConfig(this);
|
||||
|
||||
@ -98,11 +101,6 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
||||
LuckPerms.unregisterProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLog() {
|
||||
return LogUtil.wrap(getLogger());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return getDescription().getVersion();
|
||||
|
@ -9,7 +9,6 @@
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<version>1.5</version>
|
||||
<artifactId>luckperms-common</artifactId>
|
||||
<build>
|
||||
<plugins>
|
||||
@ -30,7 +29,7 @@
|
||||
<dependency>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<artifactId>luckperms-api</artifactId>
|
||||
<version>1.5</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- HikariCP -->
|
||||
|
@ -10,9 +10,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>luckperms-sponge</artifactId>
|
||||
<version>1.5</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>LuckPerms</name>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
@ -46,10 +44,54 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<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>
|
||||
</execution>
|
||||
</executions>
|
||||
</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>
|
||||
</build>
|
||||
|
||||
@ -65,14 +107,14 @@
|
||||
<dependency>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<artifactId>luckperms-common</artifactId>
|
||||
<version>1.5</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- LuckPerms API -->
|
||||
<dependency>
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<artifactId>luckperms-api</artifactId>
|
||||
<version>1.5</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- HikariCP -->
|
||||
@ -89,5 +131,12 @@
|
||||
<version>1.7.9</version>
|
||||
<scope>compile</scope>
|
||||
</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>
|
||||
</project>
|
||||
|
@ -37,9 +37,8 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@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 {
|
||||
static final String VERSION = "1.5"; // TODO load this from pom
|
||||
|
||||
@Inject
|
||||
private Logger logger;
|
||||
@ -142,7 +141,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return VERSION;
|
||||
return "MAGIC";
|
||||
}
|
||||
|
||||
@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