Re: war woes

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: war woes

hans_d
Administrator

On Jul 2, 2008, at 7:44 PM, JerodLass wrote:

>
> I have also been trying to adjust the WAR files I create.  I have a  
> directory
> called "Web Content" that contains several critical directories  
> including
> the WEB-INF directory.  Thus far, I have tried using the war plugin  
> with:
>
> task(name+'_war').fileSet(dir: new File('Web Content')){
>     exclude('WEB-INF/**')
> }
>
> task(name+'_war').webInfFileSets = [new FileSet(dir: new File('Web
> Content/WEB-INF'))]
>
> and I have also tried not using the plugin, and defining my own lib  
> task
> instead:
>
> libs{
>     war(){
>         fileSet(dir: new File('Web Content')){
>                 exclude('WEB-INF/**')
>             }
>         webInfFileSets = [new FileSet(dir: new File('Web Content/
> WEB-INF'))]
>     }
> }
>
> Both compile, but neither seems to be setting the properties with any
> effect.  WEB-INF files don't end up in the WEB-INF directory and  
> Web Content
> files don't end up anywhere.  What am I doing wrong?  How can I  
> properly
> access the properties of the war task?  Thanks for the help.

I had no time to try why the above doesn't work yet. I will do so soon.

What about using the src/webapp folder?

- Hans

>
> -Jerod
> --
> View this message in context: http://www.nabble.com/war-woes- 
> tp18243089p18243089.html
> Sent from the gradle-user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>

--
Hans Dockter
Gradle Project lead
http://www.gradle.org





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: war woes

hans_d
Administrator
Hi Jerod,

sorry for taking so long to respond. I'm in the midst of my  
Groovy2Java refactoring which absorbs most of my resources right now.


On Jul 2, 2008, at 7:44 PM, JerodLass wrote:

>
> I have also been trying to adjust the WAR files I create.  I have a  
> directory
> called "Web Content" that contains several critical directories  
> including
> the WEB-INF directory.  Thus far, I have tried using the war plugin  
> with:
>
> task(name+'_war').fileSet(dir: new File('Web Content')){
>     exclude('WEB-INF/**')
> }
>
> task(name+'_war').webInfFileSets = [new FileSet(dir: new File('Web
> Content/WEB-INF'))]
>
> and I have also tried not using the plugin, and defining my own lib  
> task
> instead:
>
> libs{
>     war(){
>         fileSet(dir: new File('Web Content')){
>                 exclude('WEB-INF/**')
>             }
>         webInfFileSets = [new FileSet(dir: new File('Web Content/
> WEB-INF'))]
One hint. Gradle offers the file method, which creates a File object  
out of a String relative to the project dir.

In this case you could write: file('Web Content/WEB-INF')

But we should add convenience methods to add to a webInfFileSet like  
we add a fileset: http://jira.codehaus.org/browse/GRADLE-138

>     }
> }
>
> Both compile, but neither seems to be setting the properties with any
> effect.  WEB-INF files don't end up in the WEB-INF directory and  
> Web Content
> files don't end up anywhere.  What am I doing wrong?  How can I  
> properly
> access the properties of the war task?  Thanks for the help.

I don't understand why this does not work at, as you describe. I have  
attached a sample war project (gradlep.zip) which works for me with 0.2.

It has the layout:

src/main/webapp
src/main/content
src/additionalWebInf

The content of webapp is automatically added to the war. The content  
of 'content' is added as a fileset. The content of additionalWebInf  
is added as a webinf fileset. Everythings works except one bug. The  
web.xml from webapp is not added. This is strange as we even have an  
integration test for this. I have filed a Jira: http://
jira.codehaus.org/browse/GRADLE-139

But this bug is not a big problem. You can specify the web.xml  
directly. Here is the build file.

import org.gradle.api.tasks.util.FileSet

group = 'gradle'
version = '1.0'
usePlugin('war')
targetCompatibility = '1.5'
sourceCompatibility = '1.5'

gradlep_war {
     fileSet(dir: file('src/main/content'))
     webInfFileSets = [new FileSet(dir: new File('src/
additionalWebInf'))]
     webXml = file('src/main/webapp/WEB-INF/web.xml')
}

I'm off for the weekend. There will be a new release soon (including  
a fix for your JSch classpath problem).

Keep Gradling ;)

- Hans

>
> -Jerod
> --
> View this message in context: http://www.nabble.com/war-woes- 
> tp18243089p18243089.html
> Sent from the gradle-user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
--
Hans Dockter
Gradle Project lead
http://www.gradle.org









---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

gradlep.zip (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: war woes

hans_d
Administrator
Hi Jerod,

On Jul 4, 2008, at 5:21 PM, Hans Dockter wrote:

> I don't understand why this does not work at, as you describe. I  
> have attached a sample war project (gradlep.zip) which works for me  
> with 0.2.
>
> It has the layout:
>
> src/main/webapp
> src/main/content
> src/additionalWebInf
>
> The content of webapp is automatically added to the war. The  
> content of 'content' is added as a fileset. The content of  
> additionalWebInf is added as a webinf fileset. Everythings works  
> except one bug. The web.xml from webapp is not added. This is  
> strange as we even have an integration test for this. I have filed  
> a Jira: http://jira.codehaus.org/browse/GRADLE-139

I was fortunately wrong. There is no bug in Gradle but the error lies  
in the build script. See below:

>
> But this bug is not a big problem. You can specify the web.xml  
> directly. Here is the build file.
>
> import org.gradle.api.tasks.util.FileSet
>
> group = 'gradle'
> version = '1.0'
> usePlugin('war')
> targetCompatibility = '1.5'
> sourceCompatibility = '1.5'
>
> gradlep_war {
>     fileSet(dir: file('src/main/content'))
>     webInfFileSets = [new FileSet(dir: new File('src/
> additionalWebInf'))]
>     webXml = file('src/main/webapp/WEB-INF/web.xml')
> }

We overwrite the default webInfFileSet here: The correct version is:

gradlep_war {
     fileSet(dir: file('src/main/content'))
     webInfFileSets = webInfFileSets + [new FileSet(dir: file('src/
additionalWebInf'))]
}

Than everything is fine. Of course this points out that we need a  
webInfFileSet method as described above.

If any of your code is not working as expected please send me a test  
case for reproducing this.

- Hans

--
Hans Dockter
Gradle Project lead
http://www.gradle.org





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: war woes

JerodLass
I got it working with the following code:

task(name+'_war').fileSet(dir: new File(projectDir, 'Web Content')){
    include('**/*')
    exclude('WEB-INF/**')
}

task(name+'_war').webInfFileSets = [new FileSet(dir: new File(projectDir, 'Web Content/WEB-INF'), excludes: new LinkedHashSet(['lib/*.jar']))]

It seems a little bizarre but it does what I want, and then I just used ant to copy over the correct manifest file.  Is there a better way to point gradle at an existing manifest to use?  This is useful for projects that are moving over to gradle when I don't want to rewrite the classpath attribute.

Jerod


hdockter wrote
Hi Jerod,

On Jul 4, 2008, at 5:21 PM, Hans Dockter wrote:

> I don't understand why this does not work at, as you describe. I  
> have attached a sample war project (gradlep.zip) which works for me  
> with 0.2.
>
> It has the layout:
>
> src/main/webapp
> src/main/content
> src/additionalWebInf
>
> The content of webapp is automatically added to the war. The  
> content of 'content' is added as a fileset. The content of  
> additionalWebInf is added as a webinf fileset. Everythings works  
> except one bug. The web.xml from webapp is not added. This is  
> strange as we even have an integration test for this. I have filed  
> a Jira: http://jira.codehaus.org/browse/GRADLE-139

I was fortunately wrong. There is no bug in Gradle but the error lies  
in the build script. See below:

>
> But this bug is not a big problem. You can specify the web.xml  
> directly. Here is the build file.
>
> import org.gradle.api.tasks.util.FileSet
>
> group = 'gradle'
> version = '1.0'
> usePlugin('war')
> targetCompatibility = '1.5'
> sourceCompatibility = '1.5'
>
> gradlep_war {
>     fileSet(dir: file('src/main/content'))
>     webInfFileSets = [new FileSet(dir: new File('src/
> additionalWebInf'))]
>     webXml = file('src/main/webapp/WEB-INF/web.xml')
> }

We overwrite the default webInfFileSet here: The correct version is:

gradlep_war {
     fileSet(dir: file('src/main/content'))
     webInfFileSets = webInfFileSets + [new FileSet(dir: file('src/
additionalWebInf'))]
}

Than everything is fine. Of course this points out that we need a  
webInfFileSet method as described above.

If any of your code is not working as expected please send me a test  
case for reproducing this.

- Hans

--
Hans Dockter
Gradle Project lead
http://www.gradle.org





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: war woes

hans_d
Administrator
Hi Jerod,

On Jul 7, 2008, at 8:52 PM, JerodLass wrote:

>
> I got it working with the following code:
>
> task(name+'_war').fileSet(dir: new File(projectDir, 'Web Content')){
>     include('**/*')
>     exclude('WEB-INF/**')
> }
>
> task(name+'_war').webInfFileSets = [new FileSet(dir: new File
> (projectDir,
> 'Web Content/WEB-INF'), excludes: new LinkedHashSet(['lib/*.jar']))]
>
> It seems a little bizarre but it does what I want, and then I just  
> used ant
> to copy over the correct manifest file.

This looks more complicated than necessary. I don't know your exact  
prerequisites. It looks like you have a folder Web Content which is  
simply an exploded web archive except the classes dir.

task(name+'_war').fileSet(dir: file(projectDir, "Web Content")) {
        excludes("lib/*.jar")
}

I guess that the Web Content/lib folder contains jars is a legacy issue.

> Is there a better way to point
> gradle at an existing manifest to use?  This is useful for projects  
> that are
> moving over to gradle when I don't want to rewrite the classpath  
> attribute.

For Gradle's manifest support see user's guide 9.8.4.

- Hans

>
> Jerod
>
>
>
> hdockter wrote:
>>
>> Hi Jerod,
>>
>> On Jul 4, 2008, at 5:21 PM, Hans Dockter wrote:
>>
>>> I don't understand why this does not work at, as you describe. I
>>> have attached a sample war project (gradlep.zip) which works for me
>>> with 0.2.
>>>
>>> It has the layout:
>>>
>>> src/main/webapp
>>> src/main/content
>>> src/additionalWebInf
>>>
>>> The content of webapp is automatically added to the war. The
>>> content of 'content' is added as a fileset. The content of
>>> additionalWebInf is added as a webinf fileset. Everythings works
>>> except one bug. The web.xml from webapp is not added. This is
>>> strange as we even have an integration test for this. I have filed
>>> a Jira: http://jira.codehaus.org/browse/GRADLE-139
>>
>> I was fortunately wrong. There is no bug in Gradle but the error lies
>> in the build script. See below:
>>
>>>
>>> But this bug is not a big problem. You can specify the web.xml
>>> directly. Here is the build file.
>>>
>>> import org.gradle.api.tasks.util.FileSet
>>>
>>> group = 'gradle'
>>> version = '1.0'
>>> usePlugin('war')
>>> targetCompatibility = '1.5'
>>> sourceCompatibility = '1.5'
>>>
>>> gradlep_war {
>>>     fileSet(dir: file('src/main/content'))
>>>     webInfFileSets = [new FileSet(dir: new File('src/
>>> additionalWebInf'))]
>>>     webXml = file('src/main/webapp/WEB-INF/web.xml')
>>> }
>>
>> We overwrite the default webInfFileSet here: The correct version is:
>>
>> gradlep_war {
>>      fileSet(dir: file('src/main/content'))
>>      webInfFileSets = webInfFileSets + [new FileSet(dir: file('src/
>> additionalWebInf'))]
>> }
>>
>> Than everything is fine. Of course this points out that we need a
>> webInfFileSet method as described above.
>>
>> If any of your code is not working as expected please send me a test
>> case for reproducing this.
>>
>> - Hans
>>
>> --
>> Hans Dockter
>> Gradle Project lead
>> http://www.gradle.org
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Re%3A-war-woes- 
> tp18258312p18323941.html
> Sent from the gradle-user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>

--
Hans Dockter
Gradle Project lead
http://www.gradle.org





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email