I have a gradle project which I want to upload to a private remote maven repository using SCP with a private key. How to do this?
Asked
Active
Viewed 2,350 times
4
-
Hey Opal, thank you for correcting my text. Can you explain me why there is a down vote on my question? – R Gastmeier May 31 '15 at 13:29
1 Answers
4
In your Gradle build file (build.gradle), add the following:
apply plugin: 'java'
apply plugin: 'maven' // you need this plugin for mavenDeployer support
// here you specify how the dependency is going to be retreived
// for example:
// compile group: 'co.domain', name: 'library', version: '0.1'
group = 'co.domain'
rootProject.name = 'library'
version = '0.1'
task deployJar(type: Jar)
configurations {
deployerJars
}
dependencies {
deployerJars "org.apache.maven.wagon:wagon-ssh:2.9"
}
uploadArchives {
repositories.mavenDeployer {
configuration = configurations.deployerJars
repository(url: "scp://<url-of-your-webserver>/<path-to-maven-directory>") {
authentication(userName: "ssh-username", privateKey: "<path-to-private-key-file")
}
}
}
The repository url could look something like this:
scp://domain.co/var/www/maven/
And the privateKey path could look something like this:
/home/users/username/.ssh/id_rsa
For more insights on how to publish artifacts in Gradle, look here: Publishing artifacts
And then look here for Maven specifics: The Maven Plugin

R Gastmeier
- 101
- 6