Hi Ronan,
Thanks so much for the help.
This worked out perfectly. I didn't need to do the dependsOnChildren()
actually.
I just added this to the subprojects closure:
[code]
project.afterEvaluate {
if (project.hasProperty("war")) {
project.task("unversionedWar", type: War, dependsOn: "war") { version
= null }
project.artifacts { archives unversionedWar }
} else if (project.hasProperty("jar")) {
project.task("unversionedJar", type: Jar, dependsOn: "jar") { version
= null }
project.artifacts { archives unversionedJar }
}
}
[/code]
Cheers,
Eric
On Tue, Jun 7, 2011 at 3:10 PM, Ronen Narkis <[email protected]> wrote:
> This is the code in my case:
>
> def parent = project
>
> allprojects {
> project.afterEvaluate {
> if(parent.hasProperty('downloadSources')){
> ideaModule.downloadSources=true
>
> }
> }
> }
>
> On Wed, Jun 8, 2011 at 1:09 AM, Ronen Narkis <[email protected]> wrote:
>
>> Im using (for enabling download source on child projects):
>>
>>
>> http://gradle.org/current/docs/dsl/org.gradle.api.Project.html#org.gradle.api.Project:afterEvaluate(groovy.lang.Closure)
>>
>> within the subproject closure and dependsOnChildren in the root project
>> (so they will evaluate before the parent does)
>>
>> Ronen
>>
>>
>> On Wed, Jun 8, 2011 at 12:58 AM, Eric Berry <[email protected]> wrote:
>>
>>> Hello,
>>> I have a multi-project build like so:
>>> [root]
>>> /app
>>> /webapp
>>>
>>> I'm trying to add an unversioned jar file or war file to the
>>> sub-projects, but I want it to be conditional.
>>>
>>> Eg. The 'app' project applies the java plugin, so it should also produce
>>> an unversioned jar file. The 'webapp' project applies the war plugin so it
>>> should produce an unversioned war file.
>>>
>>> The easiest way I found to produce the actual j/war file is to create a
>>> new task and add it to the artifacts closure.
>>> [code]
>>> task("unversionedArtifact", type: Jar, dependsOn: "classes") { version =
>>> null }
>>>
>>> artifacts { archives unversionedArtifact }
>>> [/code]
>>>
>>> The issue I'm having is essentially changing the type based on whether or
>>> not java, or war is applied.
>>>
>>> I've tried adding a check to see if the 'war' task is available:
>>> [code]
>>> if(project.tasks['war']) {
>>> extension = 'war'
>>> }
>>> [/code]
>>>
>>> But this results in an error because the war plugin hasn't been applied
>>> yet. I added this task to the root project's build.gradle file, under the
>>> subprojects closure.
>>>
>>> Is there an easy and generic way I can do this so that I can put it in
>>> the subprojects closure and have it for both types of projects?
>>>
>>> Thanks,
>>> Eric
>>>
>>> --
>>> Learn from the past. Live in the present. Plan for the future.
>>> Blog: http://eric-berry.blogspot.com
>>> jEdit <http://www.jedit.org> - Programmer's Text Editor
>>> Bazaar <http://bazaar.canonical.com> - Version Control for Humans
>>>
>>
>>
>
--
Learn from the past. Live in the present. Plan for the future.
Blog: http://eric-berry.blogspot.com
jEdit <http://www.jedit.org> - Programmer's Text Editor
Bazaar <http://bazaar.canonical.com> - Version Control for Humans