Files

106 lines
3.0 KiB
Groovy

apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'org.jetbrains.dokka'
tasks.withType(Jar).configureEach {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.register('androidSourcesJar', Jar) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
// For Android libraries
from android.sourceSets.main.kotlin.srcDirs
from android.sourceSets.main.java.srcDirs
} else {
// For pure Kotlin libraries, in case you have them
from sourceSets.main.java.srcDirs
from sourceSets.main.kotlin.srcDirs
}
}
tasks.withType(dokkaHtmlPartial.getClass()).configureEach {
pluginsMapConfiguration.set(
["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
)
}
tasks.register('javadocJar', Jar) {
dependsOn dokkaJavadoc
archiveClassifier.set("javadoc")
from dokkaJavadoc.outputDirectory
}
tasks.register('htmldocJar', Jar) {
dependsOn dokkaHtml
archiveClassifier.set("htmldoc")
from dokkaHtml.outputDirectory
}
artifacts {
archives androidSourcesJar
archives javadocJar
archives htmldocJar
}
group = GROUP_ID
version = VERSION_NAME
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
tasks.named("generateMetadataFileForReleasePublication").configure {dependsOn(androidSourcesJar)}
groupId GROUP_ID
artifactId ARTIFACT_ID
version VERSION_NAME
// Two artifacts, the `aar` (or `jar`) and the sources
if (project.plugins.findPlugin("com.android.library")) {
from components.release
} else {
from components.java
}
artifact javadocJar
artifact htmldocJar
// artifact androidSourcesJar
// Mostly self-explanatory metadata
pom {
name = ARTIFACT_ID
description = POM_DESCRIPTION
url = POM_URL
licenses {
license {
name = POM_LICENCE_NAME
url = POM_LICENCE_URL
}
}
developers {
developer {
id = POM_DEVELOPER_ID
name = POM_DEVELOPER_NAME
}
}
// Version control info - if you're using GitHub, follow the
// format as seen here
scm {
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEV_CONNECTION
url = POM_SCM_URL
}
}
}
}
}
}
signing {
sign publishing.publications
}