On 20/12/2010, at 6:42 PM, Masatoshi Hayashi wrote:

> Hello,
> 
> I want to copy a dos command file using the CopyTask.
> 
> like this
> 
> task copyCommand(type:Copy) {
>    from "src/command.bat" // that has sjis strings
>    into "dist/command.bat"
>    filter(org.apache.tools.ant.filters.ReplaceTokens, 
> tokens:[jarPath:jar.archivePath.name])
> }
> 
> but when I saw the copied file ("dist/command.bat"), the sjis strings in the 
> file had been broken.
> I guess I need to specify the file encoding of the file.

The Copy task always uses the JVM's default encoding. Could you add a jira 
issue for this problem?

> 
> Can I solve this problem with Gradle?

As a work around, you can use the Ant copy task:

ant.copy(file: 'src/command.bar', tofile: 'dist/command.bat', encoding: 'sjis') 
{
    filterchain {
        replaceTokens {
            token(key: 'jarPath', value=jar.archivePath.name)
        }
    }
}


--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz

Reply via email to