Ok, it's not intuitive, but it makes sense now.

Thanks!

- Adrian

On Tue, Jul 19, 2011 at 9:36 PM, Luke Daley <[email protected]>wrote:

>
> On 19/07/2011, at 12:09 AM, Adrian Abraham wrote:
>
> Ok, so the magic line is "repositories['mavenInstaller'].with {"
>
> If I remove the tests classifier and use my original block:
>
>> install {
>> *  repositories.mavenInstaller { *
>>     tests = addFilter('tests') { artifact, file -> artifact.name ==~
>> '.*-tests' }
>>     main = addFilter('main') { artifact, file -> !(artifact.name ==~
>> '.*-tests') }
>>   }
>> }
>>
>
> I get the following error:
>
>> Execution failed for task ':install'.
>> Cause: Could not publish configurations [configuration ':archives'].
>> Cause: A POM cannot have multiple artifacts with the same type and
>> classifier. Already have MavenArtifact foo:jar:jar:null, trying to add
>> MavenArtifact foo:jar:jar:null.
>>
>
>
> But if I change the install block to:
>
>> install {
>> *  repositories['mavenInstaller'].with { *
>>     tests = addFilter('tests') { artifact, file -> artifact.name ==~
>> '.*-tests' }
>>     main = addFilter('main') { artifact, file -> !(artifact.name ==~
>> '.*-tests') }
>>   }
>> }
>>
> It works fine.
>
> Why does repositories.mavenInstaller { ... } behave differently from
> repositories['mavenInstaller'].with { ... } ?
>
>
> repositories.mavenInstaller { ... } creates a new installer (which won't be
> used by the install task), while repositories['mavenInstaller'] accesses the
> installer that was created during the configuration of the install task by
> the maven plugin.
>
> It's not an ideal state of affairs, and will be fixed at some point.
>
> --
>
> Luke Daley
> Principal Engineer, Gradleware
> http://gradleware.com
>
>

Reply via email to