Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle, 'url' cannot be applied to (java.lang.String)

Since some time, on any maven { url "whatever" } I'm getting this warning:

Imgur

Here a sample project experiencing the issue

It's not critical neither a blocker, but it's kind of annoying

Does anybody know where it comes from?

Specs:

  • Idea IU 181.3263.15
  • JRE 1.8.0_152
  • kotlin 1.2.21
  • gradle 4.4.1
  • Win 7 x64
like image 239
elect Avatar asked Feb 07 '18 09:02

elect


2 Answers

To make IntelliJ IDEA stop complaining, you can use:

maven {
    url = 'http://myrepo'
}

which I believe is the Groovy shortcut for setUrl('http://myrepo').

like image 126
Igor Akkerman Avatar answered Nov 15 '22 08:11

Igor Akkerman


Your IDE is analyzing the Gradle DSL. With fully expanded syntax, your code looks like this:

project.dependencies({(RepositoryHandler handler) -> {
   handler.maven({(MavenArtifactRepository repository) -> {
       repository.setUrl("https://...");
   });
};

If you look in the Gradle API, you can see that MavenArtifactRepository has two methods:

void    setUrl(Object url)
void    setUrl(URI url)

So the IDE is saying you should pass Object or an URI. If you use setUri(...) the annoying IDE warning should go away.

like image 32
tkruse Avatar answered Nov 15 '22 09:11

tkruse