Files
kotlin-css-generator/publish/publish-mavencentral.gradle
rnentjes 4137427989 v. 1.0.0
Took 1 hour 52 minutes
2021-10-03 13:18:00 +02:00

122 lines
4.2 KiB
Groovy

apply plugin: 'maven-publish'
apply plugin: 'signing'
task publishSourcesJar(type: Jar) {
archiveClassifier.set('sources')
// For pure Kotlin libraries, in case you have them
from sourceSets.main.java.srcDirs
//from sourceSets.main.kotlin.srcDirs
}
task packageJavadoc(type: Jar) {
from javadoc
classifier = 'javadoc'
}
artifacts {
archives publishSourcesJar
}
File secretPropsFile = project.rootProject.file('local.properties')
ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.secretKeyRingFile"] = ''
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
ext["sonatypeStagingProfileId"] = ''
if (secretPropsFile.exists()) {
Properties p = new Properties()
new FileInputStream(secretPropsFile).withCloseable { is ->
p.load(is)
}
p.each { name, value ->
ext[name] = value
}
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
// The coordinates of the library, being set from variables that
// we'll set up later
groupId PUBLISH_GROUP_ID
artifactId PUBLISH_ARTIFACT_ID
version PUBLISH_VERSION
// Two artifacts, the `aar` (or `jar`) and the sources
if (project.plugins.findPlugin("com.android.library")) {
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
} else {
artifact("$buildDir/libs/${project.getName()}-${version}.jar")
}
artifact publishSourcesJar
artifact packageJavadoc
// Mostly self-explanatory metadata
pom {
name = PUBLISH_ARTIFACT_ID
description = 'Simple JDBC wrapper for query statistics'
url = 'https://github.com/rnentjes/Simple-jdbc-statistics'
licenses {
license {
name = 'MIT License'
url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt'
}
}
developers {
developer {
id = 'rnentjes'
name = 'Rien Nentjes'
email = 'info@nentjes.com'
}
// Add all other devs here...
}
// Version control info - if you're using GitHub, follow the format as seen here
scm {
connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git'
developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git'
url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main'
}
// A slightly hacky fix so that your POM will include any transitive dependencies
// that your library builds upon
/*
witXml {
def dependenciesNode = asNode().appendNode('dependencies')
project.configurations.implementation.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}*/
}
}
}
// The repository to publish to, Sonatype/MavenCentral
repositories {
maven {
// This is an arbitrary name, you may also use "mavencentral" or
// any other name that's descriptive for you
name = "sonatype"
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username ossrhUsername
password ossrhPassword
}
}
}
}
}
signing {
sign publishing.publications
}