[GRADLE-1635] Expand in Copy Task should only replace variables that exist in the scope Created: 23/Jun/11 Updated: 10/Feb/17 Resolved: 10/Feb/17 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 1.0-milestone-3 |
Fix Version/s: | None |
Type: | Bug | ||
Reporter: | Jani | Assignee: | Unassigned |
Resolution: | Won't Fix | Votes: | 5 |
Attachments: | build.gradle install.xml |
Description |
If expand is used in the copy task gradle tries to replace all strings starting with $ with gradle variables. So if a file contains a string starting with $ that is not a string to be replaced the copy task fails. Here's my example: 1. Build script } 2. File to be copied with expand: The variable $jarName is expanded correctly yet $INSTALL_PATH is a variable that must not be replaced. Yet gradle fails because it can not find the variable INSTALL_PATH. By the way: |
Comments |
Comment by Benjamin Muschko [ 27/Sep/11 ] |
Jani, did you find a workaround for this in the meantime? I am running into the same issue. |
Comment by Jani [ 27/Sep/11 ] |
Hi, well sort of: I ended up adding all variables that gradle wants to replace as variables. So I added a variable INSTALL_PATH having the value $INSTALL_PATH and so on. This makes the build file quite ugly if there are many. Bye, |
Comment by Benjamin Muschko [ 01/Oct/11 ] |
I had a look at the Gradle source code. The expand method for the Copy task type uses groovy.text.SimpleTemplateEngine which replaces ${..} as well as $.. by default. This is usually not what people want for regular templates. All too often this is used for shell scripts that use environment variables itself. Jani, thanks for your reply. I am not sure if that helps you but I used the Ant filter ExpandProperties instead:
ant.property(name: 'jarName', value: jar.archivePath.name)
filter(org.apache.tools.ant.filters.ExpandProperties, project: ant.antProject)
This requires using ${..} as replacement tokens. The problem is that you cannot passing tokens. You'll have to define them as Ant properties in your project which is not great. |
Comment by Benjamin Muschko [ 11/Oct/11 ] |
Sent pull request that provides an expand method for using an implementation of groovy.text.TemplateEngine. |
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:
We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle! |
Comment by Benjamin Muschko [ 10/Feb/17 ] |
Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved. |