Skip to main content

Interpolate resources

In this guide, you will learn how to interpolate resources in your project using Tableau. The main goal of resource interpolation is to provide a consistent and easy way to create metadata files for your project.

An example of this is your neoforge.mods.toml file, which contains metadata about your mod. In particular, it contains the mod ID, version, and other information that is used by NeoForge to identify your mod. As well as the versions of NeoForge and Minecraft that your mod is compatible with.

The goal of this guide is it to explain how Tableau helps with this process, and how you can use it to your advantage.

info

While you can use resource processing to fill in the required values in your neoforge.mods.toml file, we recommend that you use the NeoForge metadata generation module that comes with tableau

Configuring Tableaus interpolation targets

By default, Tableau will not interpolate any resources, however its interpolation mechanism is active. To add resources as interpolation targets, you need to configure the resourceProcessing block in the Tableau DSL:

build.gradle
tableau {
resourceProcessing {
matching += ["**/**.json"]
}
}

alternatively, you can use the matching method to add resources to the interpolation targets:

build.gradle
tableau {
resourceProcessing {
matching("**/**.json")
}
}

The result of either of these methods is that the glob pattern **/**.json is added to the list of resources that Tableau will interpolate. In this example all .json files in your projects resources of the main-sourceset will be interpolated.

Interpolating your mods toml files

To interpolate your mods neoforge.mods.toml file, you can use the modsToml method in the processingResources block:

build.gradle
tableau {
resourceProcessing {
modsToml()
}
}

This will interpolate the neoforge.mods.toml, and mods.toml file in your resources, and replace any placeholders with the values configured.

Interpolating all files

To interpolate all files in your resources, you can use the all method in the processingResources block:

build.gradle
tableau {
resourceProcessing {
all()
}
}

This will interpolate all files in your resources, and replace any placeholders with the values configured.

Configuring values for interpolation

Tableau will interpolate resources using the values configured in the properties map of the processResources block in the Tableau DSL. The key of the map is the placeholder that will be replaced, and the value is the value that will replace the placeholder.

You can add your own values to the properties map:

build.gradle
tableau {
resourceProcessing {
properties += [
myPropertyOne: "some_value",
myPropertyTwo: "1.0.0"
]
}
}

Adding the project information as a properties

Tableau has a shortcut to add the project properties as interpolation properties, using the fromProject method:

build.gradle
tableau {
resourceProcessing {
fromProject()
}
}
info

This will add all properties of the project to the interpolation properties.

Additionally, this will also add the version of the project as version to the properties.

NeoGradle information as properties

By default, the NeoGradle module will also add interpolation properties to the project. This includes the version of minecraft and NeoForge that the project is compatible with.

You can configure each of these properties in the neogradle block of the resourceProcessing block:

build.gradle
tableau {
resourceProcessing {
neogradle {
minimalMinecraftVersion = "1.16.5"
minimalForgeVersion = "1.0.0"
}
}
}
info

By default, these values are set to the current minecraft version, and will resolve the relevant neoforge version if it is dynamic.

Disabling NeoGradle interpolation

If you do not want NeoGradle to add interpolation properties, you can disable it by setting the interpolateVersions property to false:

build.gradle
tableau {
resourceProcessing {
neogradle {
interpolateVersions = false
}
}
}