-
Notifications
You must be signed in to change notification settings - Fork 0
§2. Annotations
Arno Dölinger edited this page Jun 30, 2026
·
2 revisions
Platform Weaver decides what stays and what is stripped from each build based on platform annotations.
| Annotation | Kept when building for | Stripped when building for |
|---|---|---|
@FabricOnly |
fabric |
Paper, Neoforge, anything else |
@PaperOnly |
paper |
Fabric, Neoforge, anything else |
@NeoForgeOnly |
neoforge |
Fabric, Paper, anything else |
A declaration with no platform annotation is compiled into every JAR. A declaration annotated for a platform other than the target is removed before bytecode is written, so its platform-specific types never need to resolve at runtime.
Platform Weaver isn't limited to the three built-in annotations. Define your own in one line with @PlatformOnly:
import io.github.arnodoelinger.platformweaver.PlatformOnly
@PlatformOnly("spigot")
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.SOURCE)
annotation class SpigotOnlyThe string passed to @PlatformOnly is the platform key matched against your build's target. The plugin picks the annotation up automatically — you don't need to add it to the compiler plugin classpath.