Unable to download war file from Nexus

Hi,

What could be the possible solution for this error?

Could not find method war() for arguments on org.gra dle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@c 1d588.

I am trying to download my war file from Nexus repository, but it throws me the above mentioned error.

Please Help!

What did you write in the dependencies block?

I wrote as,

repositories {
maven { url fullRepoUrl }
}
!
configurations {
war
}
!
dependencies {
war “$project.group:$project.name:$project.version”
}
!
task downloadBinaryArchive(type: Copy) {
from configurations.war
into “$buildDir/download”
}

Please Help!.

I renamed it as war1, but it didnt downloaded from nexus.

dependencies {
war “$project.group:$project.name:$project.version”
}

The default extension is always “jar”. You’ll have to tell Gradle that you’re looking for a war file, not a jar file by specifying the extension explicitly using “@war”:

dependencies {
  war "$project.group:$project.name:$project.version@war"
}
1 Like

To refine @Raffael_Herzog answer, the documentation says

50.4.1.2. Artifact only notation
As said above, if no module descriptor file can be found, Gradle by default downloads a jar with the name of the module. But sometimes, even if the repository contains module descriptors, you want to download only the artifact jar, without the dependencies. [14] And sometimes you want to download a zip from a repository, that does not have module descriptors. Gradle provides an artifact only notation for those use cases - simply prefix the extension that you want to be downloaded with ‘@’ sign

So the most important thing is to look at the module descriptor in your repository.
Is there any ?
If yes, is it correct ? Is your war file an artifact of this module ?
If no, then the explicit extension notation might help

Let me as well come back to your first post

Could not find method war() for arguments on org.gra dle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@c 1d588

Is this error generated with the code you provided ? Or did you try something else and the error is not here anymore (only you cannot retrieve your artifact) ?

@Francois_Guillot
There is No module Descriptor, I provided explicit notation @war.

Yes the error was generated with the code i have provided.
I changed the name as war1 and the error is nomore.

@Raffael_Herzog Thanks, I am nearing for the solution.

But still I cant download. It throwed me another error
Could not resolve all dependencies for configuration ‘:web:war1’.

Could not find web.war (quickstart-app:web:1.0).

I guess ‘war’ is a reserved keyword. You shouldn’t name configuration with it. Rather use something that explains what the configurations contains (i.e. myProjectCompile, specificAntLib, etc etc)

Is this the result of resolving your GString “$project.group:$project.name:$project.version” ?
In this case, by saying '“$project.group:$project.name:$project.version@war” you actually say
I want to retrieve the war file named with the default conventional value, ie web.war

your artifact is probably NOT namef web.war, but something else (non conventional)

in this case you have to use a more explicit dependency definition, such as

dependencies {
  war1 "$project.group:$project.name:$project.version" {
    artifact {
      //useful when some artifact properties unconventional
      name = 'someArtifact' //artifact name different than module name
      extension = 'war'
      type = 'someType' // optional
      classifier = 'someClassifier' // optional
    }
  }
}

I am really sorry, I am getting this error now…

  • What went wrong:
    A problem occurred evaluating project ‘:web’.

Could not find method quickstart-app:web:1.0() for arguments [build_a0i3qevttf
5dxbfju3veeytsj$_run_closure2_closure10_closure24@129cb02] on org.gradle.api.int
ernal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@fd947e.

The first error which I got. It seems weird!
FYI, This is how my Nexus looks like…

my bad, it’s

dependencies {
  war1 ("$project.group:$project.name:$project.version") { <--- parenthesis added around the dependency definition
    artifact {
      name = "$project.name-$project.version"
      extension = 'war'
    }
  }
}

although i’m a bit surprised that your war is not picked up, since ‘name-version’ is conventional

Now the error is “type must not be null”
:frowning:

Well, add type=war in the artifact block

Hi @Francois_Guillot / @Raffael_Herzog,

The issue has been resolved by providing the code as,

war1 (“$project.group:$appName:$project.version@war”){
artifact {
name = “$appName”
extension = ‘war’
type = ‘war’
}
}

Thanks a lot!