Jump to content

Execution failed for task ':processResources'


Myxtro

Recommended Posts

I get the following error when trying to run my mod. The processResources Gradle script doesn't seem to work.

Execution failed for task ':processResources'.
> Could not copy file 'D:\Minecraft Modding\mods\UnnamedMod\src\main\resources\META-INF\mods.toml' to 'D:\Minecraft Modding\mods\UnnamedMod\build\resources\main\META-INF\mods.toml'.
   > Missing property (file) for Groovy template expansion. Defined keys [minecraft_version, minecraft_version_range, forge_version, forge_version_range, loader_version_range, mod_id, mod_name, mod_license, mod_version, mod_authors, mod_description, project].

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':processResources'.
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:149)
	at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
	...
Caused by: org.gradle.api.internal.file.AbstractFileTreeElement$CopyFileElementException: Could not copy file 'D:\Minecraft Modding\mods\UnnamedMod\src\main\resources\META-INF\mods.toml' to 'D:\Minecraft Modding\mods\UnnamedMod\build\resources\main\META-INF\mods.toml'.
	at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:88)
	at org.gradle.api.internal.file.copy.DefaultFileCopyDetails.copyTo(DefaultFileCopyDetails.java:129)
	...
Caused by: org.gradle.api.GradleException: Missing property (file) for Groovy template expansion. Defined keys [minecraft_version, minecraft_version_range, forge_version, forge_version_range, loader_version_range, mod_id, mod_name, mod_license, mod_version, mod_authors, mod_description, project].
	at org.gradle.api.internal.file.copy.FilterChain$3.transform(FilterChain.java:132)
	at org.gradle.api.internal.file.copy.FilterChain$3.transform(FilterChain.java:115)
	... 146 more
Caused by: groovy.lang.MissingPropertyException: No such property: file for class: SimpleTemplateScript1
	at SimpleTemplateScript1.run(SimpleTemplateScript1.groovy:1)
	at org.gradle.api.internal.file.copy.FilterChain$3.transform(FilterChain.java:129)
	... 155 more

Some context: I originally made this mod in 1.17 and have updated it through every version since. This happened after the update to 1.20. Because my Gradle files where becoming outdated I opted to copy the gradle files from a newer project so they would be up to date. The "Load Gradle Changes" button works fine. It's just that this fails when I try to launch the game.

The gradle files I updated were:

  • build.gradle
  • gradle.properties
  • mods.toml
  • settings.gradle
  • gradle-wrapper.jar (from the folder gradle\wrapper)
  • gradle-wrapper.properties (from the folder gradle\wrapper)

 

EDIT:

Here are some file fragments from what I think could be relevant. I've removed comments for readability.

 build.gradle (partially):

def resourceTargets = ['META-INF/mods.toml', 'pack.mcmeta']
def replaceProperties = [
        minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
        forge_version: forge_version, forge_version_range: forge_version_range,
        loader_version_range: loader_version_range,
        mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
        mod_authors: mod_authors, mod_description: mod_description
]
processResources {
    inputs.properties replaceProperties
    replaceProperties.put 'project', project

    filesMatching(resourceTargets) {
        expand replaceProperties
    }
}

 

mods.toml:

modLoader="javafml"

loaderVersion="${loader_version_range}"

license="${mod_license}"

[[mods]]

modId="${mod_id}"

version="${mod_version}"

displayName="${mod_name}"

logoFile="example.png"

credits="Thanks to you!"

authors="${mod_authors}"

description="${mod_description}"

[[dependencies.unnamedmod]]
    modId="forge"
    mandatory=true
    versionRange="${forge_version_range}"
    ordering="NONE"
    side="BOTH"
[[dependencies.unnamedmod]]
    modId="minecraft"
    mandatory=true
    versionRange="${minecraft_version_range}"
    ordering="NONE"
    side="BOTH"

 

properties.gradle:

org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false


minecraft_version=1.20.1

minecraft_version_range=[1.20.1,1.21)

forge_version=47.1.0

forge_version_range=[47,)

loader_version_range=[47,)

mapping_channel=parchment

mapping_version=2023.08.13-1.20.1

mod_id=unnamedmod

mod_name=UnnamedMod

mod_license=All Rights Reserved

mod_version=0.0.1-1.20.1

mod_group_id=net.unnamedmod

mod_authors=Myxtro

 

 

Edited by Myxtro
Link to comment
Share on other sites

Quote

Could not copy file 'D:\Minecraft Modding\mods\UnnamedMod\src\main\resources\META-INF\mods.toml' to 'D:\Minecraft Modding\mods\UnnamedMod\build\resources\main\META-INF\mods.toml'.

> Missing property (file) for Groovy template expansion. Defined keys [minecraft_version, minecraft_version_range, forge_version, forge_version_range, loader_version_range, mod_id, mod_name, mod_license, mod_version, mod_authors, mod_description, project].

That error says gradle is trying to copy your mods.toml, replacing properties as it does so.

One of the properties in your mods.toml is something like:

${file}

But you haven't defined what that value should be in your processResources task in the buid.gradle

unlike the other defined properties: https://github.com/MinecraftForge/MinecraftForge/blob/ab70bde1d648125acee073a93a25d4b8f08985c9/mdk/build.gradle#L153

which probably actually come from the gradle.properties?

 

Beyond that we can't help you. We have no psychic powers. You don't show the contents of any of your files.

You should put a simple project on github that reproduces your problem if you want further help.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

I solved it, but maybe not in the correct way. The problem was that I needed to add 

file: file

to the replaceProperties in build.gradle. I then added

file=examplefile

to gradle.properties. What would be a better value than "examplefile"? I don't really know what file it's looking for

Edited by Myxtro
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.