Cargo build for JBoss 5.1.0.GA fails: cannot find ClientLoginModule

Ok, it works now, thanks to the workaround proposed by René Groeschke in this post:

In my case, it takes a configuration and injects the resolved files in the Ant classloader:

  ClassLoader antClassLoader = org.apache.tools.ant.Project.class.classLoader
                 configurations.cargo.each { File f ->
                         antClassLoader.addURL(f.toURI().toURL())
                 }

After some struggle with dependencies conflicts, I got the following script to successfully deploy on my jboss:

apply plugin: 'war'
apply plugin: 'com.bmuschko.cargo'

buildscript {
    repositories {
        maven{
          url "https://nexus.lbg.office.lyra/content/groups/vad_repo/"
        }
    }
    dependencies {
        classpath 'com.bmuschko:gradle-cargo-plugin:2.1.1'
  }
}

repositories {
   maven{
         url "https://nexus.lbg.office.lyra/content/groups/vad_repo/"
   }
}

configurations {
  antcp
}

configurations.all {
  resolutionStrategy {
    // add dependency substitution rules
    dependencySubstitution {
      //specifying a fixed version for all libraries with 'org.gradle' group
      eachModule { ModuleDependencySubstitution details ->
        if (details.requested.group == 'commons-logging') {
          details.useVersion '1.1.1'
        }
        if (details.requested.module == 'jboss-common-core') {
          details.useVersion '2.2.14.GA'
        }
        if (details.requested.module == 'jboss-logging-spi') {
          details.useVersion '2.1.0.GA'
        }
      }
    }
  }
}

dependencies {
  def cargoVersion = '1.4.5'
  cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion", "org.codehaus.cargo:cargo-ant:$cargoVersion"
  cargo 'org.jboss.jbossas:jboss-as-jbossas-remoting:5.1.0.GA'

  antcp 'org.jboss.jbossas:jboss-as-jbossas-remoting:5.1.0.GA'
  antcp 'org.jboss.jbossas:jboss-as-client:5.1.0.GA'
}

ClassLoader antClassLoader = org.apache.tools.ant.Project.class.classLoader
                 configurations.antcp.each { File f ->
                         antClassLoader.addURL(f.toURI().toURL())
                 }

cargo {
    containerId = 'jboss51x'
    port = 1099

    remote {
      username = "admin"
      password = "admin"
      hostname = "127.0.0.1"
    }

    deployable {
        context = 'myawesomewebapp'
    }

}

Hope it helps !