1
0
Fork 0
mirror of https://codeberg.org/stonecutter/stonecutter.git synced 2025-12-10 05:42:56 +00:00
Modern Gradle plugin for multi-version management
Find a file
2025-11-17 19:18:08 +01:00
.woodpecker Replace GitHub Actions deploy workflow with Woodpecker configuration for Dokka updates. 2025-07-13 19:27:12 +02:00
buildSrc Update to Gradle 9.2 2025-11-17 17:57:26 +01:00
gradle/wrapper Update to Gradle 9.2 2025-11-17 17:57:26 +01:00
stitcher Update dependencies to use version catalog, adapt build scripts, and switch to Kotlin 2.2 2025-08-26 07:27:56 +02:00
stonecutter Bump version to 0.7.11 2025-11-17 19:18:08 +01:00
tools Add stricter validation rules and new definitions to the settings schema 2025-08-10 11:48:50 +02:00
.gitignore Add community resources 2025-04-05 08:13:11 +02:00
.gitmodules Add pages module 2025-04-04 18:36:55 +02:00
build.gradle.kts Update to Gradle 9.2 2025-11-17 17:57:26 +01:00
gradle.properties Bump version to 0.7.11 2025-11-17 19:18:08 +01:00
gradlew Initial port (very unfinished) 2023-12-20 13:41:42 +01:00
gradlew.bat Initial commit 2023-06-08 08:52:31 +03:00
LICENSE Do a licensing 2 2024-08-05 16:00:45 +02:00
README.md readme and beta 2024-06-03 21:29:59 +02:00
settings.gradle.kts Update to Gradle 9.2 2025-11-17 17:57:26 +01:00

Stonecutter

Modern Gradle plugin for multi-version management.

What is it?

Stonecutter is a Gradle plugin that allows working on a project that targets multiple compatible release versions of a dependency.
It's mostly meant for mods Minecraft mods, but on itself the plugin is platform-independent.

This project is inspired by Preprocessor, JCP and The original Stonecutter, expanding on their features and providing new ones.

This page briefly covers the functionality of Stonecutter. For more information visit the Stonecutter website.

Features

Comment syntax

Like other code processors, Stonecutter uses comments to specify how the code fragment should be modified. To accomplish that, Stonecutter uses the custom language and parser - Stitcher.

Supported functionality:

// Simple semver condition
//? if >1.2.0
func()

// Targeting multiple lines
//? if >1.2.0 {
func1()
func2()
//?}

// Boolean operations
//? if >1.2.0 || <0.3.0
func()

// Comparing provided variables
//? if id: >1.2.0
func()

And much more! See the Documentation website for a detailed guide.

Performance

Even though the Stitcher parser is optimised on itself, Stonecutter caches both the produced ASTs and transformed files to speed up version switching.

Clean code

One of the first reasons to work on Stonecutter was the clutter of Preprocessor and JCP.
For example, here's a block of code from the Preprocessor repository:

//#if MC>=11200
category.addDetail(name, callable::call);
//#else
//$$ category.setDetail(name, callable::call);
//#endif

The same functionality in Stonecutter is accomplished using:

//? >=1.12 {
category.addDetail(name, callable::call);
//?} else 
/*category.setDetail(name, callable::call);*/

The difference is not too apparent on a small example, but when it comes to disabling entire methods, a single multiline comment looks much better than a dozen //$$ .

Stonecutter also has inline comment support, which allows doing this:

target.call(arg1, arg2, /*? if dependency: >=0.2 >>*//*arg3,*/ arg4)

There are even more features, described as usual on the Documentation website.

Roadmap

Stonecutter already went through countless hours of development and research, but there is still more to go.
Planned features include:

  • Resource file support
  • Intellij IDEA plugin
  • Multi-file processing scripts
  • Project tree management (for Architectury support)
  • File transformation plugins

If you have any questions or suggestions, join my Discord server or open an issue/start a discussion.