Support "ssh" protocol for "maven-publish" just like "maven"

plugins

(Jared Burrows) #1

Similar questions:


Currently the “maven” plugin supports many protocols: SCP, SSH, FTP, etc (https://docs.gradle.org/current/userguide/maven_plugin.html#sec:deploying_to_a_maven_repository)

Can we add the same support to the “maven-publish” plugin?


(Mark Vieira) #2

SFTP is supported. One limitation though is it only supports authentication via username/password. That means no private key auth at the moment if using ‘maven-publish’.


(Dimitar Dimitrov) #3

Is there a JIRA we can vote for private key? Also, client certificates for https may be useful for automating push to production repositories.


(Mark Vieira) #4

@ddimitrov I’ve created GRADLE-3472 and GRADLE-3473 to track this.


(Jared Burrows) #5

@mark_vieira Thanks for creating those issues.


(Dmodoomsirius) #6

I agree. can you put on the maven-publish plugin page on how to scp as some people like myself until i found this issue will not know that maven-publish plugin supports scp.


(Dmodoomsirius) #7
publishing {
    publications {
        mavenJava(MavenPublication)
        {
            artifact shadowJar
            //from components.java
        }
    }

    repositories {
        maven {
        //checks for a the local property as a gradle argument and if exists outputs to a local dir.
            if (project.hasProperty("local") && project.getProperty("local") == "true")
                url "file:" + projectDir.path + "/build/maven"
            elseif (project.hasProperty("BBMuser")
                url: "sftp://builtbroken.com:22767"
                    credentials {
                        username project.BBMuser
                        password project.BBMpassword
                    }
        }
    }
}

* Where:
Build file 'C:\Users\Myahm\Desktop\coding\git\MC\github\oblivion\Launcher\launcher\build.gradle' line: 64

* What went wrong:
Could not compile build file 'C:\Users\Myahm\Desktop\coding\git\MC\github\oblivion\Launcher\launcher\build.gradle'.
> startup failed:
  build file 'C:\Users\Myahm\Desktop\coding\git\MC\github\oblivion\Launcher\launcher\build.gradle': 64: unexpected token: url @ line 64, column 17.
                 url: "sftp://builtbroken.com:22767"
                 ^

  1 error

any clues what i am doing wrong?


(Mark Vieira) #8

Should be url = "sftp://..." or alternatively you can omit the = operator but colons (:) are used in Groovy to define a Map not to perform assignment.


(Dmodoomsirius) #9
    publishing {
        publications {
            mavenJava(MavenPublication)
            {
                artifact shadowJar
                //from components.java
            }
        }

        repositories {
            maven {
            //checks for a the local property as a gradle argument and if exists outputs to a local dir.
                if (project.hasProperty("local") && project.getProperty("local") == "true")
                    url "file:" + projectDir.path + "/build/maven"
                elseif (project.hasProperty("BBMuser")
                    url = "sftp:///builtbroken.com:22767"
                        credentials {
                            username project.BBMuser
                            password project.BBMpassword
                        }
            }
        }
    }

Build file 'C:\Users\Myahm\Desktop\coding\git\MC\github\oblivion\Launcher\launcher\build.gradle' line: 66

* What went wrong:
Could not compile build file 'C:\Users\Myahm\Desktop\coding\git\MC\github\oblivion\Launcher\launcher\build.gradle'.
> startup failed:
  build file 'C:\Users\Myahm\Desktop\coding\git\MC\github\oblivion\Launcher\launcher\build.gradle': 66: unexpected token: url @ line 66, column 17.
                     url = "sftp:///builtbroken.com:22767"
                     ^

  1 error


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

still the same error. I am now confused as to what is causing it.


(Dmodoomsirius) #10

can you also add a working example to https://docs.gradle.org/current/userguide/publishing_maven.html so it’s easier for people to understand how it works?


(Dmodoomsirius) #11

any updates on how to get this working?


(Mark Vieira) #12

You cannot omit braces when using elseif. You’ll have to add the curly braces.

if (project.hasProperty("local") && project.getProperty("local") == "true") {
    url "file:" + projectDir.path + "/build/maven"
} elseif (project.hasProperty("BBMuser") {
    url = "sftp:///builtbroken.com:22767"
    credentials {
        username project.BBMuser
        password project.BBMpassword
    }
}