On 19/01/2011, at 12:21 AM, zebulon wrote:
> I have several projects that share common properties like
> dependencies, repositories, uploadArchive etc.. so I create a gradle
> script for this. My first intention was to add your jar section in
> this script as well instead of being written in each "build.gradle"
> per project files, i.e.:
>
> //script.gradle
> jar {
> manifest {
> def manifestClasspath = configurations.runtime.collect
> {it.getName() }.join(' ')
> attributes 'Class-Path': manifestClasspath,
> }
> }
>
> In each porject, my gradle file looks like:
> apply from: '../script.gradle'
>
> dependencies {
> compile group: 'log4j', name: 'log4j', version: '1.+'
> etc..
When you apply the script, the dependencies have not yet been defined (they're
later in the script, after the apply statement). And so, configurations.runtime
is empty.
You can do something like this, which defers building the classpath attribute
until after the runtime configuration has been configured:
jar.doFirst {
manifest { def manifestClasspath = ... }
}
>
> Unfortunalty, the generated manifest has an empty classpath.
> But when I move the jar section from the gradle script to per project
> build.gradle file, then the classpath is correctly filled... I would
> prefer to put this section in the shared script, if possible?
>
> 2011/1/18 TheKaptain <[email protected]>:
>>
>> Are you trying to
>> 1) apply the same Jar configuration to multiple Java projects or
>> 2) build the jar once and use it as a dependency in multiple Projects?
>>
>> --
>> View this message in context:
>> http://gradle.1045684.n5.nabble.com/manifest-and-classpath-tp3343782p3345544.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
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz