Publishing artifact to remote maven repository on s3 using Gradle

2.1k views Asked by At

I've been researching and trying to find examples for the above and found the following:

For Android Projects:

Hosting a Private Maven Repo on Amazon S3

gradle maven push project

These plugin however expects certain Android properties specified and throws errors like Could not find property 'android' on task ':androidJavadocs'.

For Remote repositories over SFTP, there is maven-publish.

Besides, it seems to be possible to do this in Maven.

Would be great if anyone can point me to an example of how to do this.

2

There are 2 answers

0
jguerinet On

I've slightly modified the code from your second link (here) for Java-based projects. The only problematic sections are at the bottom of the file, where the source and javadoc jars are being created since he is directly referencing Android. If you replace the final tasks (line 95 onwards) with the following it should resolve your problem:

task sourcesJar(type: Jar) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

// Makes the Javadocs
task javadocs(type: Javadoc) {
    // I set this to false here since I reference third party classes in my Javadocs 
    //   which fails the Javadoc generation, but this can be removed
    failOnError  false
    source = sourceSets.main.java.srcDirs
}

task javadocJar(type: Jar, dependsOn: javadocs) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives sourcesJar
    archives javadocJar
}
0
iCrus On

Gradle has a plugin to do this now however it is in incubating state and yet to be released.

https://docs.gradle.org/current/userguide/publishing_maven.html