gradle icon indicating copy to clipboard operation
gradle copied to clipboard

Build issue with my project.

Open ni-cky opened this issue 3 years ago • 3 comments

I am trying to build my project currently but the following exception is being thrown:

> Could not copy file 'C:\Users\nicky\Desktop\fabric-example-mod-master\Grisha\src\main\resources\fabric.mod.json' to 'C:\Users\nicky\Desktop\fabric-example-mod-master\Grisha\build\resources\main\fabric.mod.json'.
   > Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
     SimpleTemplateScript6.groovy: 1: Unexpected input: '(' @ line 1, column 10.
        out.print("""{
                 ^

     1 error

Help would be greatly appreciated as I am currently under heavy time crunch and struggling >.<

ni-cky avatar Aug 20 '21 19:08 ni-cky

Thank you for your interest in Gradle!

Your issue appears to be a question about how to use Gradle. Your question might be better answered on our forums or StackOverflow. We have several resources on help.gradle.org that you should check out first.

If you think you have come across a Gradle bug, please file a new issue describing the problem and how to reproduce it.

If you think Gradle is missing a feature, please file a new issue describing your use case for the feature.

mlopatkin avatar Aug 22 '21 08:08 mlopatkin

@mlopatkin not really helpful. He should have provided an example to reproduce the error. But aside from that it's actually a gradle issue not a question how to use gradle. Please reopen this ticket or I will create a new one.

Got the same error:

Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
     SimpleTemplateScript34.groovy: 1: Unexpected character: '"' @ line 1, column 13.
        out.print("""

I created a minimal example to reproduce the issue. In my case it seems gradle kotlin dsl doesn't handle comments inside property files.

Either commenting out this in build.gradle.kts:

tasks.withType<ProcessResources> {
	filesMatching("*.properties") {
		expand("version" to version, "buildTimestamp" to LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")))
	}
}

Or removing this in application.properties:

#  \ \\\\\\\\n \\\\) test %m%n

Fixes the build.

See minimal reproducable example added: demo.zip logs.txt

judos avatar Sep 17 '22 14:09 judos

@judos thanks, putting this back into the triage queue.

mlopatkin avatar Sep 17 '22 14:09 mlopatkin

I've run into similar issue. Couldn't really find any obvious reason. Adding escapeBackslash = true to expand helped. Example:

filesMatching('**/config*.*') {
    expand('version': project.version) {
        escapeBackslash = true
    }
}

T-PWK avatar Dec 23 '22 12:12 T-PWK

This is affecting me too. I can confirm that it works correctly in v6.9.4, but fails in v7.0.0 (and the latest versions 7.6.1 and v8.0.1)

daveoh avatar Mar 03 '23 15:03 daveoh

This seems to happen when there are other unescaped placeholder variables in the yml file.

tasks.processResources {
    filesMatching("application.yml") {
        expand("profile" to profile)
    }
}
# works fine
spring:
    profiles.active: ${profile}
    batch.job.name: \${job.name:NONE}
# error occurred
spring:
    profiles.active: ${profile}
    batch.job.name: ${job.name:NONE}
---
> Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
     SimpleTemplateScript23.groovy: 1: Unexpected input: '(' @ line 1, column 10.
        out.print("""spring:

tested on gradle 7.6 related to #24868

umbum avatar Aug 01 '23 05:08 umbum

Can confirm! Gradle 8.4, I'm expanding namespace, package, and version.

Execution failed for task ':processResources'.
> Could not copy file '/home/<redacted>/Projects/Magnesium/src/main/resources/quilt.mod.json' to '/home/<redacted>/Projects/Magnesium/build/resources/main/quilt.mod.json'.
   > Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
     SimpleTemplateScript4.groovy: 1: Unexpected input: '(' @ line 1, column 10.
        out.print("""{
                 ^
The expanded file
{
	"schema_version": 1,
	"quilt_loader": {
		"group": "${package}",
		"id": "${namespace}",
		"version": "${version}",
		"metadata": {
			"name": "Magnesium",
			"description": "Actual data manipulation for data packs.",
			"contributors": {
				"Laxystem": "Developer"
			},
			"contact": {
				"homepage": "https://laxla.quest/",
				"issues": "https://github.com/LaylaMeower/${namespace}/issues",
				"sources": "https://github.com/LaylaMeower/${namespace}/issues"
			},
			"icon": "assets/${namespace}/icon.png"
		},
		"intermediate_mappings": "net.fabricmc:intermediary",
		"entrypoints": {
			"init": {
				"adapter": "kotlin",
				"value": "${package}.${namespace}.Magnesium"
			}
		},
		"depends": [
			{
				"id": "quilt_loader",
				"versions": ">=0.19.2"
			},
			{
				"id": "quilted_fabric_api",
				"versions": ">=7.4.0"
			},
			{
				"id": "qkl",
				"versions": ">=2.1.0"
			},
			{
				"id": "minecraft",
				"versions": ">=1.20.1"
			}
		]
	},
	"mixin": "${namespace}.mixins.json"
}

Renaming package to group seems to solve the problem -- is it because package is a groovy operator?

Laxystem avatar Nov 21 '23 15:11 Laxystem

Getting same error with below property in yaml, workaround on it setting the property through an *.properties override file

logging:
  pattern:
    correlation: "[${spring.application.name:},%X{traceId:-},%X{spanId:-}] "

leandremucyo avatar Nov 29 '23 17:11 leandremucyo

Same issue, workaround not possible for me as the resource is generated by a plugin, please resolve

BlueTree242 avatar Jan 21 '24 22:01 BlueTree242