Thanks again, your support is really appreciated. I've modified your example
a bit:
[install, uploadArchives].each {task ->
def taskRepositories = task.repositories.all as List
if (!taskRepositories.empty) {
addParentScopeMappings(taskRepositories[0].pom.scopeMappings,
configurations.compile)
}
}
private void addParentScopeMappings(def scopeMappings, Configuration
configuration) {
configuration.extendsFrom.each {parentConfiguration ->
scopeMappings.addMapping(300, parentConfiguration, 'compile')
addParentScopeMappings(scopeMappings, parentConfiguration)
}
}
(My uploadArchives task had no repositories.)
Why do we only want to configure the first repository?
On Tue, Jul 20, 2010 at 2:50 AM, Adam Murdoch <[email protected]> wrote:
> On 17/07/10 12:23 AM, Levi Hoogenberg wrote:
>
> Hi,
>
> I'm trying to use Gradle to generate pom files, so that I can create an
> online M2 repository that contains my project's artifacts. Eventually, I'd
> like to use Sonatype for this, but this way seemed less time-consuming.
>
> Anyway, my project declares two custom configurations:
>
> configurations {
> distribution
> apiDocs.extendsFrom distribution
> compile.extendsFrom apiDocs
> }
>
> (All JAR files in the distribution configuration will be packaged in the
> distribution zip, the apiDocs JARs form the classpath for the Javadoc task.)
>
> Now, when I run *gradle install*, the modules' generated pom.xmls do
> contain a <dependency> element for each dependency in the compile
> configuration, but none for the distribution or apiDocs configurations'
> dependencies.
>
> Is this intended behaviour?
>
>
> No, this is a bug. I've added a JIRA issue for this:
> http://jira.codehaus.org/browse/GRADLE-1042
>
>
> Can I use some workaround to get the behaviour I would like?
>
>
> You can add scope mappings for the custom configurations. Here's an
> example:
>
> [install, uploadArchives].each { task ->
> configure(task.repositories.all.asList()[0].pom.scopeMappings) {
> addMapping(300, configurations.apiDocs, 'compile')
> addMapping(300, configurations.distributions, 'compile')
> }
> }
>
>
> --
> Adam Murdoch
> Gradle Developerhttp://www.gradle.org
> CTO, Gradle Inc. - Gradle Training, Support, Consultinghttp://www.gradle.biz
>
>