Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

Provide maven(url: String, name: String? = null, ...) shortcut #256

Closed
sdeleuze opened this issue Jan 26, 2017 · 6 comments
Closed

Provide maven(url: String, name: String? = null, ...) shortcut #256

sdeleuze opened this issue Jan 26, 2017 · 6 comments

Comments

@sdeleuze
Copy link

sdeleuze commented Jan 26, 2017

Current syntax to specify Maven repositories is not very idiomatic. Providing a regular Kotlin maven()function with parameters like maven(url: String, name: String? = null, ...) would be more easy to use for end users via autocomplete, positional or named parameters, and would read and write more easily.

Current syntax:

repositories {
  maven { setUrl("...") }
}

Proposed syntax:

repositories {
  maven(url = "...") // can be abbreviated to maven("...")
}
@bamboo bamboo added this to the 0.9.0 milestone Feb 6, 2017
@bamboo
Copy link
Member

bamboo commented Apr 12, 2017

Alternatively we could add the strongly typed setter setUrl(URI) to MavenArtifactRepository and then the syntax would be:

maven { url = uri("...") }

@bamboo
Copy link
Member

bamboo commented Apr 12, 2017

As a second step we could work with the Kotlin team to introduce the concept of implicit conversion compiler plugins and achieve complete parity with Groovy with the advantage of compile time checking:

maven { url = "..." } // statically checked implicit conversion from String to URI 

@eskatos
Copy link
Member

eskatos commented Apr 12, 2017

I like the alternative route a lot.

We should refrain from adding adhoc shortcuts. They are terrible to maintain, they may outnumber us at some point 😄 and they surely will minimize the goodness we could get from a coherent frontend on top of the Gradle API.

@eskatos eskatos self-assigned this Apr 13, 2017
@eskatos
Copy link
Member

eskatos commented Apr 18, 2017

Type safe setters have been added to the Gradle API in:

  • MavenArtifactRepository
  • IvyArtifactRepository
  • MavenPluginRepository
  • IvyPluginRepository

See gradle/gradle#1823

This provides the following:

repositories {
  maven { url = uri("...") }
}

Implicit conversions will be addressed in #335

@eskatos eskatos closed this as completed Apr 18, 2017
@sdeleuze
Copy link
Author

As commented on #335, I am against introducing implicit conversion to Kotlin, and I still think such shortcut is relevant for such frequently used statement.

@bamboo
Copy link
Member

bamboo commented Aug 16, 2017

We should reconsider this shortcut.

@bamboo bamboo reopened this Aug 16, 2017
@bamboo bamboo modified the milestones: 0.11.0, 0.9.0 Aug 16, 2017
@bamboo bamboo self-assigned this Aug 24, 2017
bamboo added a commit that referenced this issue Aug 24, 2017
@bamboo bamboo closed this as completed Aug 24, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants