cire
cire
JCHJava Community | Help. Code. Learn.
Created by cire on 12/30/2024 in #java-help
How can I dynamically change a plugin's version depending on certain criteria?
We have a multi platform project, however each platform has its own platform-dependent implementation of some classes. In our case, 2 of these target platforms require the same plugin, however they rely on different versions. So far, I have tried to dynamically set extra[pluginVersion] via either -PbuildingForB and gradle.taskGraph.whenReady , then setting a classpath in the dependencies block of the buildscript block, and finally applying the plugin after the plugins block. Unfortunately, this errors with Cannot get property 'pluginVersion' on extra properties extension as it does not exist.
gradle.build.kts
buildscript {
extra {
"pluginVersionA" to "1.0"
"pluginVersionB" to "2.0"
"pluginVersion" to "1.0"
}

extra["pluginVersion"] = project.findProperty("buildingForB")?.let {
if (it == "true") extra["pluginVersionB"] else extra["pluginVersionA"]
} ?: extra["pluginVersionA"]

gradle.taskGraph.whenReady {
if (tasks.contains(task("buildPlatformB")))
extra["pluginVersion"] = extra["pluginVersionB"];
}

repositories {
mavenCentral()
}
dependencies {
classpath("com.example:example-plugin:${extra["pluginVersion"]}")
}
}

plugins {
...
}

apply(plugin = "org.example")
gradle.build.kts
buildscript {
extra {
"pluginVersionA" to "1.0"
"pluginVersionB" to "2.0"
"pluginVersion" to "1.0"
}

extra["pluginVersion"] = project.findProperty("buildingForB")?.let {
if (it == "true") extra["pluginVersionB"] else extra["pluginVersionA"]
} ?: extra["pluginVersionA"]

gradle.taskGraph.whenReady {
if (tasks.contains(task("buildPlatformB")))
extra["pluginVersion"] = extra["pluginVersionB"];
}

repositories {
mavenCentral()
}
dependencies {
classpath("com.example:example-plugin:${extra["pluginVersion"]}")
}
}

plugins {
...
}

apply(plugin = "org.example")
7 replies
JCHJava Community | Help. Code. Learn.
Created by cire on 10/17/2024 in #java-help
Java agent throws UnsupportedClassVersionError when Instrumentation#retransformClasses is called.
I need to dump who invokes a setCancelled(boolean cancelled) method in a running jar (Spigot 1.8). I decided to do this via dumping the caller using StackWalker by using a javaagent to add a method call which dumps the caller, the item field which is of type org.bukkit.inventory.ItemStack, & the cancelled argument. The only issue currently, is that when i call retransformClasses the whole thing comes burning down. Target class: org.bukkit.event.player.PlayerInteractEvent The agent is compiled under Java 17.0.12 the JVM is 17.0.12 The spigot jar is java 8 (i think) Ran via the -javaagent command line option
86 replies
JCHJava Community | Help. Code. Learn.
Created by cire on 4/13/2024 in #java-help
Can not determine cause of failure
Hello! I was practicing on some past codeforces problems (https://codeforces.com/gym/102951/problem/C), and I just can't seem to get this one. I know my code probably isn't the typical way of doing this, but I can't seem to figure out why it fails on test 4. Code: https://pastebin.com/Hdian9Ak
8 replies
JCHJava Community | Help. Code. Learn.
Created by cire on 6/1/2023 in #java-help
Difference between <?> and <L>
I'm making a listener system, and I was wondering what the difference between
public void register(Class<? extends Listener> listener)
public void register(Class<? extends Listener> listener)
and
public void register(Class<L extends listener> listener)
public void register(Class<L extends listener> listener)
Is either one better than the other, and if so, which?
47 replies