Can the cargo plugin deploy war files from the local maven repository?

I’m working on a gradle build which builds several war files and publishes them to the local maven repo. In another project I want gradle to deploy all the new war files to a tomcat server and then run webetsts against them.

I have it working but the only way I was able to refer to the war files using cargo was with something like :

deployable {

file = file( ‘file://’ + new File(System.getProperty(‘user.home’), ‘.m2/repository/company/project/5.0.0/myWar-5.0.0.war’).absolutePath)

context = ‘myContext’

}

I’m going to make another pass through this and make the version numbers dynamic etc. But my question is : “Is this the best way to do something like this?” It seems odd to construct a file path to my local maven repo. I would think that since I added the war files as dependencies that the cargo plugin would just know about them but it doesn’t seem to work that way.

If you need to deploy a War file located in a Maven repository, you can first resolve it using Gradle’s regular dependency management, and then deploy it.

Yes that is what I’m doing now. Currently everything is local, the wars are being built and published to the local maven repo, the project that deploys them is local, and tomcat is local.

Even though I add the wars as dependencies it really doesn’t do anything because they aren’t going to get pulled from anywhere, I have to go and build the other projects first to put them there.

I may rework this and just do it all as a multi project build.

That’s not what I meant. I meant something like this:

configurations {
    warDeploy
}
  dependencies {
    warDeploy ...
}
  deployable {
      file = { configurations.warDeploy.files.singleFile } // remove curly braces if not supported by cargo plugin
}

Now you no longer need to assemble a path manually, and it works both for local and remote Wars.

Thanks so much! What worked for me was something like …

configurations {

warDeploy }

dependencies{

warDeploy “myCompany:myProject:myVersion@war” }

deployable {

file = file( project.configurations.warDeploy.asPath ) }

Since I am deploying 4 war files I made 4 configurations each with 1 war file dependency. I’m still pretty new to gradle so I had no idea about the ‘asPath’ syntax on the dependency.

‘asPath’ isn’t the right choice here (it creates a class path notation), though it might work if the configuration just contains a single file. In my code snippet I forgot ‘configurations.’, which I’ve added by now.

I changed all 4 instances of ‘asPath’ to ‘singleFile’ and it works as well, thanks again.