[GRADLE-3138] addToAntBuilder chokes with files that have double dollar in the name Created: 22/Jul/14  Updated: 24/Jan/17  Resolved: 24/Jan/17

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Szczepan Faber Assignee: Unassigned
Resolution: Duplicate Votes: 2


 Description   

Code like files("1$$2.txt").addToAntBuilder(...) does not work correctly. It seems that double dollar confuses addToAntBuilder. Vanilla ant does cope with such files (I tested) so I assume it's a problem with addToAntBuilder() method. I suspect that some GString-like escaping is kicking in because '$' -> '$', '$$' -> '$', '$$$' -> '$$'.

File with such name are pretty for compiled scala classes, e.g. "ActivityBuilder$$anonfun$filterEntities$1$$anonfun$apply$1.class" (real example). The problem can manifest in various ways. In my case, jacoco report generation failed with:

org.gradle.api.tasks.TaskExecutionException
Caused by: : Error while creating report
Caused by: java.io.FileNotFoundException: /Users/sfaber/foo/ActivityBuilder$anonfun$filterEntities$1$anonfun$apply$1.class (No such file or directory)
	at org.apache.tools.ant.types.resources.FileResource.getInputStream(FileResource.java:217)
	at org.jacoco.ant.ReportTask.createBundle(ReportTask.java:568)
	at org.jacoco.ant.ReportTask.createReport(ReportTask.java:547)
	at org.jacoco.ant.ReportTask.execute(ReportTask.java:494)
	... 28 more

Sample project that reproduces the problem:

task repro {
  doLast {
    file('in').mkdirs()
    file('in/1.txt') << ""
    file('in/1$$2.txt') << ""
      
    def ft = fileTree('in')
    ant.copy(todir: 'out') {
     ft.addToAntBuilder(project.ant, 'resources')
    }
    println "Inspect the content of 'in' and 'out' dirs"
  }
}


 Comments   
Comment by Kevin Scaldeferri [ 09/Nov/15 ]

Is there any hope that this bug is being fixed? Or are there any known work-arounds?

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Kevin Scaldeferri [ 27/Nov/16 ]

I am still interested in this issue. It looks like the original report contains enough detail to satisfy the current guidelines.

Comment by Eric Wendelin [ 24/Jan/17 ]

Moved to https://github.com/gradle/gradle/issues/1249

Generated at Wed Jun 30 12:40:59 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.