[GRADLE-3198] The gradle copy task is not honouring the caseSensitive property. Created: 20/Nov/14  Updated: 10/Feb/17  Resolved: 10/Feb/17

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

Type: Bug
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Won't Fix Votes: 0


 Description   

Hello,

I'm having a problem with the Copy task-type in gradle, namely that it doesn't copy all the files I want.
I'm copying a tree full of *.ddl files, but some are called *.DDL, and those don't get copied, even though I set caseSensitive = false in the copy task.

I created the following test build to show the problem:

task makefiles << {
mkdir 'fromtest'
file('fromtest/lower.foo').write('Test file lower case foo')
file('fromtest/upper.FOO').write('Test file upper case FOO')
file('fromtest/lower.foobar').write('Test file lower case bar')
}

task copyfoo (type: Copy, dependsOn: makefiles) {
into 'totest'
from 'fromtest'
include '*.foo'
caseSensitive = false
}

task show(dependsOn: copyfoo) << {
fileTree('totest').each

{ println it.name }

}

The code above only copies lower.foo, whereas I would expect it to also copy upper.FOO
What am I doing wrong ?



 Comments   
Comment by Gradle Forums [ 20/Nov/14 ]

Hi,
I have the same issue.
Has anybody an idea? Is this a known bug?

Comment by Gradle Forums [ 20/Nov/14 ]

I have created a workaround for this bug (I assume this is a bug!).
Sorry if this looks a bit cluttered - I am a beginner in groovy

/**

  • Workaround for broken caseSensitive property of the copy task.
  • Checks whether the file starts with given extension prefix and if
  • the given path segment is part of the files path.
  • Both checks are case insensitive.
    *
  • @param fileTreeElement The FileTreeElement instance to check.
  • @param extPrefix The prefix of the file extension.
  • @param pathSegment Optional part of the file path.
  • Backward slashes are converted to forward slashes!
  • @return boolean
    */
    def checkExtension(fileTreeElement, extPrefix, pathSegment='') {
    def path = fileTreeElement.getPath().toLowerCase().replace("
    ", "/")
    def lext = path.split('[.]')
    def ll = lext.length
    def ext = ''
    if (ll > 1) { ext = lext[ll - 1] }

    path.contains(pathSegment) && ext.startsWith(extPrefix)
    }

use this in the copy task as follows:

task copyExcel(type: Copy, dependsOn: copyXmlGen) {
from srcDir
into defaultDir + '/common/gtnexus'
includeEmptyDirs false
include(

{checkExtension(it, 'xl', 'com/foo/bar')}

)
}

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 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.

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