On 9 January 2013 13:51, Adam Murdoch <[email protected]> wrote:
> > On 10/01/2013, at 7:12 AM, Daz DeBoer wrote: > > G'day > > In order to publish to a maven repository, you now need to explicitly add > a MavenPublication. The rationale for this change is described at > https://github.com/gradle/gradle/blob/master/design-docs/publication-model.md#publish-web-application-to-maven-repository > > The DSL for doing so looks like: > > publishing.publications { > myPublicationName(MavenPublication) { > from components.java // Publish the java-library component > } > } > > publishing.publications { > myPublicationName { > // More config for the existing publication > } > } > > So the method name gives the publication name, and the type is determined > by the class argument. This is different from RepositoryHandler, for > example, which uses the method name to define the type, and has a separate > way of setting the 'name'. Using the name for type does lead to a bit of > ambiguity in the DSL, because when creating you use repository.type and > when accessing repository.name. > > repositories { > flatDir { > name "myFlatDir" > } > } > repositories { > myFlatDir { > // some extra config > } > } > > I'm not sure the new syntax is better or worse, but it is a different > paradigm. One thing to note is that the name of a publication is not > particularly important: there will often be a single publication of a type, > and the name is only used for referencing elsewhere in the build. > > So one option is to go with: > > publishing.publications { > maven { // Creates a new MavenPublication > name "myMavenPublication" > from components.java > } > } > > publishing.publications { > myMavenPublication { > // More config for the existing publication > } > } > > This would be more consistent with other parts of the DSL > > > Not really. We use both approaches. Tasks are defined using name(type) > syntax, for example. > Right. In that case I'm fairly comfortable leaving it as-is for now. Sounds like name(Type) is a reasonable pattern that could be usefully adapted to other containers/types. I just didn't want to introduce a new pattern that wasn't going to be more broadly applicable. I'll leave the publication DSL as-is for now. Daz PS I think I'm done with https://github.com/gradle/gradle/blob/master/design-docs/publication-model.md#publish-web-application-to-maven-repository
