Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

1.16 Replacing ${version} in toml


hohserg
 Share

Recommended Posts

I added follow code to my build script for replace ${version} placeholder in my toml by gradle project version



processResources {
    // This will ensure that this task is redone when the versions change.
    inputs.property 'version', project.version

    // Replace stuff in mods.toml, nothing else
    from(sourceSets.main.resources.srcDirs) {
        include 'META-INF/mods.toml'

        // Replace version
        expand 'version':project.version
    }

    // Copy everything else except the mods.toml
    from(sourceSets.main.resources.srcDirs) {
        exclude 'META-INF/mods.toml'
    }
}

On build it crashes with

* What went wrong:
Execution failed for task ':ElegantNetworking_1.16:processResources'.
> Could not copy file 'C:\Users\hohserg\Documents\GitHub\ElegantNetworking1\ElegantNetworking_1.16\src\main\resources\META-INF\mods.toml' to 'C:\Users\hohserg\Documents\GitHub\ElegantNetworking1\ElegantNetworking_1.16\build\resources\main\META-INF\mods.toml'.

How to insert version to toml by gradle?

Link to comment
Share on other sites

Hey, I may be misunderstanding what you want to do, but make sure you do not change the version string in mods.toml.

It should be: version="${file.jarVersion}"

That string will be auto-replaced by gradle.

 

In build.gradle under jar/manifest/attributes, you can set "Implementation-Version" to "project.version".
e.g.
"Implementation-Version": project.version,

This should be enough for gradle to pull the version from the Jar Metadata.

 

Note: If you are running from Eclipse your Mod's Version may display as "NONE", that's fine. When you actually create a jar for your mod, for instance with the "build/jar" Gradle Task. That jar should have a valid version when you drop it into a "mods" folder.

Edited by HeavensSword
  • Like 1
Link to comment
Share on other sites

6 hours ago, HeavensSword said:

That string will be auto-replaced by gradle.

It will be replaced by FML at runtime.

 

6 hours ago, HeavensSword said:

When you actually create a jar for your mod, for instance with the "build/jar" Gradle Task.

Do not use the jar task directly, it will cause your mod to not be reobfuscated. You must run the build task.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.