Skip to content

Commit

Permalink
Change back to setUrl() for kotlin/groovy compatibility. #134
Browse files Browse the repository at this point in the history
url = "foo" doesn't work in kotlin, so while this doesn't
look that great, it does work in both languages.
  • Loading branch information
deepy committed Feb 6, 2021
1 parent d79af78 commit d1ea695
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ node {
}
```

In the `settings.gradle` file:
In the `settings.gradle/settings.gradle.kts` file:

```gradle
dependencyResolutionManagement {
Expand All @@ -231,7 +231,7 @@ dependencyResolutionManagement {
// Declare the Node.js download repository
ivy {
name = "Node.js"
url = "https://nodejs.org/dist/"
setUrl("https://nodejs.org/dist/")
patternLayout {
artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (GradleVersion.current() >= GradleVersion.version("6.8")) {

ivy {
name = "Node.js"
url = "https://nodejs.org/dist/"
setUrl("https://nodejs.org/dist/")
patternLayout {
artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]")
}
Expand Down

4 comments on commit d1ea695

@dawi
Copy link

@dawi dawi commented on d1ea695 Feb 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url = uri("https://nodejs.org/dist/") would also be possible. :)

@bsautel
Copy link
Contributor

@bsautel bsautel commented on d1ea695 Feb 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and it would be probably better. The setUrl(String url) method is probably here for backwards compatibility.
@deepy what do you think about that?
This works on both Groovy and Kotlin DSLs, even though in Kotlin we cannot assign its value with = like all the properties.

@deepy
Copy link
Member Author

@deepy deepy commented on d1ea695 Feb 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setUrl(Object) is the same as project.uri(Object) https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/repositories/IvyArtifactRepository.html#setUrl-java.lang.Object-

the only reason I've touched this is because I wanted to keep it the same between the implementation in the plugin and the documentation, so that the next time we change something it's just a copy-paste :-)
I'm perfectly fine with any solution that works in both kotlin and groovy (for making the documentation simpler) :-)

@bsautel
Copy link
Contributor

@bsautel bsautel commented on d1ea695 Feb 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I did not check the Javadoc before writing my answer and url is not a property. Using setUrl(Object) or setUrl(Uri) is similar because Gradle will transform the object to an URI. That's ok for me, sorry for my irrelevant answer.

Please sign in to comment.