Created
August 24, 2020 13:23
-
-
Save antweiss/9dbfcd1e674b0892aa17e42677a1cd0b to your computer and use it in GitHub Desktop.
generate android javadoc with gradle and publish javadoc site to Nexus OSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.github.httpbuilderng.http.HttpTask | |
import groovyx.net.http.ApacheEncoders | |
import static groovyx.net.http.MultipartContent.multipart | |
import static groovy.io.FileType.FILES | |
plugins { | |
id "io.github.http-builder-ng.http-plugin" version "0.1.1" | |
} | |
task javadoc(type: Javadoc) { | |
source = android.sourceSets.main.java.sourceFiles | |
classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) | |
classpath += configurations.compile | |
project.android.libraryVariants.all { v -> | |
classpath += v.javaCompile.classpath | |
} | |
} | |
//provide Nexus creds with `gradle publishJavaDoc -Pusername=<username> -Ppassword=<password> | |
task publishJavaDoc(type: HttpTask, dependsOn: javadoc){ | |
config { | |
request.uri = 'https://nexus.mycompany.com' | |
request.encoder('multipart/form-data', ApacheEncoders.&multipart) | |
} | |
javadoc.destinationDir.eachFileRecurse(FILES) { file -> | |
def relative = file.absolutePath - javadoc.destinationDir.absolutePath | |
put { | |
request.uri.path = '/repository/android-sdk-javadoc/' + relative | |
request.auth.basic(project.getProperty('username'), project.getProperty('password')) | |
request.body = file.text | |
request.contentType = 'text/plain' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment