Deploying to a maven repository via SCP with Gradle
Deploying your artifacts to a remote Maven repository with Gradle is possible, but the official documentation is rather thin at the time of this writing. Worse, it tells you to use a version of wagon-ssh that ignores the provided password and prompt for it at the command line (use gradle -i to see its message).
So, without further ado, here is a build.gradle that uploads its artifact via scp with a password. It has been tested with Gradle 1.0-milestone-6.
apply plugin: 'java'
apply plugin: 'maven'
configurations {
deployerJars
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
//the one and only version that works
deployerJars 'org.apache.maven.wagon:wagon-ssh:1.0-alpha-3'
}
uploadArchives {
repositories.mavenDeployer {
configuration = configurations.deployerJars
uniqueVersion = false
String username = 'me'
String password = 'secret'
repository(url: 'scp://repos.mycompany.com/releases') {
authentication(userName: username, password: password)
}
snapshotRepository(url: 'scp://repos.mycompany.com/snapshots') {
authentication(userName: username, password: password)
}
}
}
Of course, in a real world scenario, it would be wiser to get the username and password from your gradle.properties or any other non-public file.