After test, I found a simple way to fix the error to add file to distZip
task.

distZip {
into(applicationName) {
from 'src/main/app'
}
}

One suggestion about this, since we always need to package more files into
our application distribution, not only bin script and libs, but also some
configuration files and other files like readme. Why we don't add it into
the application plugin : add a file list properties for the additional
directory / files, if set, copy them into the distribution.

I think this is a general requirement for almost everyone and every
application. So it will be helpful if it is supported by this plugin.

Xiaojian



在 Tue, May 17, 2011 at 2:35 PM,敖小剑 <[email protected]>写道:

>
> Thanks, when I turn to use installApp, it works.
>
> Seems the userguide is not update for this upgrade, both the online
> userguide and the one in the distribution zip file of 1.0-milestone-3.
>
> ---------------
>
> And another question about it:
>
> installApp {
>     from 'src/main/conf'
> }
>
> This works well but it copies only the files in  src/main/conf , not the
> directory" src/main/conf" itself. I checked the userguide about the copy
> task that this is a feature of the copy task, not a bug or something. So I
> change to add a "src/main/app" directory and move conf to under it. Yeah,
> perhaps later I will have move files or directory which need to copy. For
> example, a empty directory logs for log4j to avoid error the logs dir is not
> exists.
>
> It seems wonderful, but the same solution failed in task distZip:
>
> distZip {
> from 'src/main/app'
> }
>
> The generated zip file is like this:
>
> gradleDemoApp.zip
>     -- conf
>     --  gradleDemoApp
>             -- lib
>             ---bin
> The zip task add a new directory in the zip file and it doesn't work for
> the additional "from" property. I know I can add additional script to add
> the files to correct position. But for the distZip task, it seems a small
> bug ?
>
> At last, many thank to Adam Murdoch for your quickly response.
>
>
> Sky Ao
>
>
> 2011/5/17 Adam Murdoch <[email protected]>
>
>>
>> On 17/05/2011, at 2:46 PM, 敖小剑 wrote:
>>
>> Hi
>>
>> I want to use gradle application plugin and I have some configuration need
>> to package into the application distribution. For example, log4j.xml, or
>> *.properties.
>>
>> The target application directory should be like this:
>>
>> /approot
>>     -- libs
>>     -- bin
>>     -- conf
>>
>> Now there is no similar feature supported by gradle application plugin.
>> I have to do this action by hand. My solution is to add a new
>> task copyConf and add
>> it as dependent task to the standard task of application plugin "install".
>>
>> This is my build.gradle:
>>
>> apply plugin:'application'
>> apply plugin:'java'
>> apply plugin:'eclipse'
>>
>> mainClassName = 'net.sourcesky.study.gradle.application.DemoMain'
>>
>> applicationName = 'gradleDemoApp'
>>
>> *task copyConf(type: Copy) {*
>> *   from 'src/main/conf'*
>> *   into "build/install/gradleDemoApp/conf"*
>> *}*
>> *
>> *
>> *install.dependsOn copyConf*
>>
>>
>> The task was renamed 'installApp' in Gradle 1.0-milestone-3:
>>
>> installApp.dependsOn copyConf.
>>
>> Here's another approach you could use instead of adding another task:
>>
>> installApp {
>>     from 'src/main/conf'
>> }
>>
>> distZip {
>>     from 'src/main/conf'
>> }
>>
>>
>> --
>> Adam Murdoch
>> Gradle Co-founder
>> http://www.gradle.org
>> VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
>> http://www.gradleware.com
>>
>>
>

Reply via email to