bmuschko / gradle-cargo-plugin

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

Wildfly example #78

Closed hrstoyanov closed 10 years ago

hrstoyanov commented 10 years ago

I wanted to post a working Wildfly 8 Final example, if someone needs it :

apply plugin: 'war' apply plugin: 'cargo'

buildscript { repositories { maven {url 'https://repository.jboss.org/nexus/content/groups/public'} jcenter() mavenCentral() }

    dependencies {
        classpath 'org.gradle.api.plugins:gradle-cargo-plugin:1.4'
    }

}

cargo {

    containerId = 'wildfly8x'

    remote {
        hostname = 'localhost'
        username = 'admin'
        password = 'admin'
    }

    local {
        jvmArgs = '-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n'
        homeDir = file('/home/hristo/java/wildfly-8.0.0.Final')
    }

}

dependencies {

//... Your dependencies

//Java EE
providedCompile "javax:javaee-api:7.0"

//Cargo
cargo 'org.wildfly:wildfly-controller-client:8.0.0.Final'
cargo 'org.codehaus.cargo:cargo-ant:1.4.5'    

}

bmuschko commented 10 years ago

Starting with version 1.3 you don't need to provide the Cargo dependencies anymore. The plugin does this for you. Do you actually need to provide the dependency org.wildfly:wildfly-controller-client:8.0.0.Final? I'd think that org.codehaus.cargo:cargo-core-uberjar:1.4.5 declare a transitive dependency on it.

Other than that your configuration looks like any other container configuration. Do you think the documentation should be improved here? IMHO it already provides an example for it.

hrstoyanov commented 10 years ago

Benjamin, Here is what happens, if I comment out this dependency:

//Cargo //cargo 'org.wildfly:wildfly-controller-client:8.0.0.Final' //cargo 'org.codehaus.cargo:cargo-ant:1.4.5'

.... Starting Build Settings evaluated using settings file '/home/hristo/projects/other/odbserver/settings.gradle'. Projects loaded. Root project using build file '/home/hristo/projects/other/odbserver/build.gradle'. Included projects: [root project 'odbserver', project ':api', project ':server', project ':web-client'] Evaluating root project 'odbserver' using build file '/home/hristo/projects/other/odbserver/build.gradle'. Compiling build file '/home/hristo/projects/other/odbserver/build.gradle' using StatementExtractingScriptTransformer. Compiling build file '/home/hristo/projects/other/odbserver/build.gradle' using BuildScriptTransformer. Evaluating project ':api' using build file '/home/hristo/projects/other/odbserver/api/build.gradle'. Evaluating project ':server' using build file '/home/hristo/projects/other/odbserver/server/build.gradle'. Compiling build file '/home/hristo/projects/other/odbserver/server/build.gradle' using StatementExtractingScriptTransformer. Compiling build file '/home/hristo/projects/other/odbserver/server/build.gradle' using BuildScriptTransformer. Evaluating project ':web-client' using build file '/home/hristo/projects/other/odbserver/web-client/build.gradle'. Compiling build file '/home/hristo/projects/other/odbserver/web-client/build.gradle' using StatementExtractingScriptTransformer. Compiling build file '/home/hristo/projects/other/odbserver/web-client/build.gradle' using BuildScriptTransformer. All projects evaluated. Selected primary task 'cargoRedeployRemote' Tasks to be executed: [task ':server:cargoRedeployRemote'] :server:cargoRedeployRemote (Thread[main,5,main]) started. :server:cargoRedeployRemote Executing task ':server:cargoRedeployRemote' (up-to-date check took 0.0 secs) due to: Task has not declared any outputs. Container ID = wildfly8x Deployable artifacts = [/home/hristo/projects/other/odbserver/server/build/libs/server-1.0.war] Starting action 'redeploy' for remote container 'WildFly 8.x' on 'http://localhost:8080' Container properties = [:] :server:cargoRedeployRemote FAILED :server:cargoRedeployRemote (Thread[main,5,main]) completed. Took 1.269 secs.

FAILURE: Build failed with an exception.

BUILD FAILED

Total time: 8.811 secs Stopped 0 compiler daemon(s). hristo@peruncsHP8570p:~/projects/other/odbserver$

bmuschko commented 10 years ago

I think this should be something that needs to be addressed by Cargo itself (either as transitive dependency or documentation). Could you please ask this question on the Cargo user mailing list?

hrstoyanov commented 10 years ago

I wasted some time on my WildFly 8 set-up, so I wanted to show how my set-up deviated from the examples. Here are the tricks:

  1. You will need maven {url 'https://repository.jboss.org/nexus/content/groups/public'}

in order too get jboss remoting downloaded.

See https://community.jboss.org/thread/237151

  1. You will need the following dependencies

    cargo 'org.wildfly:wildfly-controller-client:8.0.0.Final' cargo 'org.codehaus.cargo:cargo-ant:1.4.5'

bmuschko commented 10 years ago

I understand that this kind of stuff can waste a lot of time. However, dependencies might get outdated in terms of their coordinates. I still think this is something that the Cargo project needs to handle and not this plugin. The plugin is just a wrapper around the library and provides a DSL. The core logic is Cargo. That's where this needs to be addressed.

hrstoyanov commented 10 years ago

I tried ... filing bugs with CODEHOUSE is not as straightforward ... sigh .. i will try later tonight

bmuschko commented 10 years ago

Any luck with this?

hrstoyanov commented 10 years ago

I sent an email to user@cargo.codehaus.org, referencing this thread and asked them to open an issue. It is up to you to keep this issue open, so CARGO developers can look at it, but most importantly, help other Wildfly developers.

hrstoyanov commented 10 years ago

Benjamin, Here is what I got over at the Cargo user mail list:

http://cargo.996258.n3.nabble.com/Wildfly-8-Final-unnecessary-dependencies-td18342.html

I think the dependency is needed, but maybe it is not clear from the cargo docs

bmuschko commented 10 years ago

I think you wrote "unnecessary" instead of "necessary". Could you please follow up? The Cargo developer didn't fully understand your question.

bmuschko commented 10 years ago

The dependencies for Wildfly are described on the Cargo webpage: http://cargo.codehaus.org/JBoss+Remote+Deployer#JBossRemoteDeployer-jboss. I am going to close the ticket. Your code might end up becoming an integration test though.

ljani commented 10 years ago

Just for the sake of completeness, here's a complete example with proper formatting:

apply plugin: 'war'
apply plugin: 'cargo'

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.gradle.api.plugins:gradle-cargo-plugin:1.5'
    }
}

repositories {
    maven {
        // org.wildfly:wildfly-controller-client:8.1.0.Final has a transitive dependency on 
        // org.jboss.remoting:jboss-remoting:4.0.3.Final, which is only found here:
        url 'https://repository.jboss.org/nexus/content/groups/public/'
    }
}

dependencies {
    providedCompile 'javax:javaee-api:7.0'

    // Without the wildfly-controller-client, you'll get following error:
    //   ContainerException: Failed to create deployer with implementation class WildFly8xRemoteDeployer
    cargo 'org.wildfly:wildfly-controller-client:8.1.0.Final'

    // Without cargo-ant you'll get following error:
    //   Problem: failed to create task or type cargo
    cargo 'org.codehaus.cargo:cargo-ant:1.4.8'
}

cargo {
    containerId = 'wildfly8x'
    local {
        homeDir = file('C:/Local/wildfly')
    }
    remote {
        hostname = 'localhost'
        username = 'user'
        password = 'pass'
    }
}

I'm posting this, because as a first time Gradle user, it took me a while to understand that maven {url 'https://repository.jboss.org/nexus/content/groups/public'} should be outside of the buildscript in contrast to what the first comment says.

Here are the full errors if someone ends up googling them. Missing cargo 'org.wildfly:wildfly-controller-client:8.1.0.Final':

Execution failed for task ':sample-web:cargoDeployRemote'.
> org.codehaus.cargo.container.ContainerException: Failed to create deployer with implementation class org.codehaus.cargo.container.wildfly.WildFly8xRemoteDeployer for the parameters (container [id = [wildfly8x]], deployer type [remote]).

Missing maven {url 'https://repository.jboss.org/nexus/content/groups/public'}:

Execution failed for task ':sample-web:cargoDeployRemote'.
> Could not resolve all dependencies for configuration ':sample-web:cargo'.
   > You must specify a URL for a Maven repository.

Missing cargo 'org.codehaus.cargo:cargo-ant:1.4.8':

Execution failed for task ':sample-web:cargoRedeployRemote'.
> Problem: failed to create task or type cargo
  Cause: The name is undefined.
  Action: Check the spelling.
  Action: Check that any custom tasks/types have been declared.
  Action: Check that any <presetdef>/<macrodef> declarations have taken place.