bmuschko / gradle-cargo-plugin

Gradle plugin that provides deployment capabilities to local and remote containers via Cargo
Apache License 2.0
258 stars 63 forks source link

Could not find method cargo() #211

Closed Hugolarson closed 1 month ago

Hugolarson commented 1 month ago

Hi,

Im using this build.gradle to deploy remote but I'm getting this error when running.

Could not find method cargo() for arguments [org.codehaus.cargo:cargo-core-uberjar:1.9.10, org.codehaus.cargo:cargo-licensed-dtds:1.9.10, org.codehaus.cargo:cargo-ant:1.9.10] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Don't think there is anything wrong with it hence.

buildscript { repositories { gradlePluginPortal()

}
dependencies {
    classpath 'com.bmuschko:gradle-cargo-plugin:2.9.0'
}

}

dependencies { def cargoVersion = '1.9.10' cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion", "org.codehaus.cargo:cargo-licensed-dtds:$cargoVersion", "org.codehaus.cargo:cargo-ant:$cargoVersion" } apply plugin: 'com.bmuschko.cargo'

cargo { containerId = 'tomcat10' port = 443

deployable {
    file = file('c:/projekt/libs/order.war')
    context = '/'
}

remote {
    protocol = 'https'
    hostname = 'testserver.se'
    username = 'test'
    password = 'test123'
}

}

bmuschko commented 1 month ago

You need to apply the plugin first before you can use the custom configuration named cargo it provided.

Hugolarson commented 1 month ago

Thank you for the response.

apply plugin: 'com.bmuschko.cargo' is before cargo and after dependencies

Please do you have a short samle build.gradle?

Thanks

c:\projekt\Cargo-tomcat>gradlew cargoDeployRemote

Task :cargoDeployRemote FAILED

FAILURE: Build failed with an exception.

bmuschko commented 1 month ago
apply plugin: 'com.bmuschko.cargo'

dependencies {
    cargo ...
}
Hugolarson commented 1 month ago

Im so sorry. it is like that. Going nuts here.

buildscript { repositories { gradlePluginPortal()

}
dependencies {
    classpath 'com.bmuschko:gradle-cargo-plugin:2.9.0'
}

}

apply plugin: 'com.bmuschko.cargo'

dependencies { def cargoVersion = '1.9.10' cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion", "org.codehaus.cargo:cargo-licensed-dtds:$cargoVersion", "org.codehaus.cargo:cargo-ant:$cargoVersion" } cargo { ..... }

bmuschko commented 1 month ago

I will need to see a full project. Please create a new repository including a Gradle Wrapper that reproduces the issue.

Hugolarson commented 1 month ago

Hi, I'm very new to github but created this. hope it's ok https://github.com/Hugolarson/cargo

bmuschko commented 1 month ago

You are missing the definition of repositories for the Cargo dependencies, as indicated by the following error message:

Execution failed for task ':cargoRunLocal'.
> Could not resolve all files for configuration ':cargo'.
   > Cannot resolve external dependency org.codehaus.cargo:cargo-core-uberjar:1.9.10 because no repositories are defined.
     Required by:
         project :
   > Cannot resolve external dependency org.codehaus.cargo:cargo-licensed-dtds:1.9.10 because no repositories are defined.
     Required by:
         project :
   > Cannot resolve external dependency org.codehaus.cargo:cargo-ant:1.9.10 because no repositories are defined.
     Required by:
         project :

Add the following to your build script:

repositories {
    mavenCentral()
}
Hugolarson commented 1 month ago

Still does not work.

I tried with only mavenCentral(). And with both mavenCentral() and gradlePluginPortal(). still does not work.

buildscript { repositories { gradlePluginPortal() mavenCentral() } dependencies { classpath 'com.bmuschko:gradle-cargo-plugin:2.9.0' } }

bmuschko commented 1 month ago

You added it to buildscript but that's not where it goes. It need to be added in the same way I posted it in my previous comment. Please refer to the Gradle documentation for more info on the difference.

Hugolarson commented 1 month ago

Thank you so much. Very weak with gradle and looked every where for a full example but alas could not find any.

Thanks again sir!