Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload via SCP with Gradle

Inside a Java module build by Gradle, I want to upload the resulting JAR(s) of my project to a remote location which is reachable via SSH/SCP. All examples I found did not work inside my environment. There is also an example how to use SCP inside the Gradle tutorial: http://gradle.org/docs/current/userguide/maven_plugin.html (search for "Example 38.4. Upload of file via SSH"). I adapted the example a bit and now have this build.gradle:

apply plugin: 'java'
apply plugin: 'maven'

description = "User Service Implementation"

repositories {
    mavenCentral()
}

configurations {
    deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
}

dependencies {
    deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
}

uploadArchives {
    repositories.mavenDeployer {
        name = 'sshDeployer' // optional
        configuration = configurations.deployerJars
        repository(url: "scp://miniappserver") {
            authentication(userName: "root", password: "test")
        }
    }
}

But when I test that script I'm getting this error:

$ gradle uploadArchives -q

FAILURE: Build failed with an exception.

* Where:
Build file '/home/ifischer/git/userservice/implementation/build.gradle' line: 11

* What went wrong:
A problem occurred evaluating project ':implementation'.
Cause: Could not find method deployerJars() for arguments [org.apache.maven.wagon:wagon-ssh:2.2] on project ':implementation'.

What am I doing wrong? Can anybody provide a complete working example?

[should post that question to the gradle-user mailing list, but it's currently down...]

like image 526
Wolkenarchitekt Avatar asked Jan 27 '12 11:01

Wolkenarchitekt


1 Answers

As kindly replied on the Gradle Mailing list (sorry for double posting) I had to remove the "org.apache.maven.wagon:wagon-ssh:2.2" inside the configurations-task:

(...)
configurations {
    deployerJars 
}
(...)
like image 51
Wolkenarchitekt Avatar answered Nov 09 '22 22:11

Wolkenarchitekt