callbacks/maoni-slack/build.gradle

Summary

Maintainability
Test Coverage
/*
 * Copyright (c) 2017 Armel Soro
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
final homePath = System.properties['user.home']


apply plugin: 'com.android.library'
apply plugin: "kotlin-android"
//apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'

final VERSION_NAME = maoni_version
final VERSION_CODE = VERSION_NAME.replace('.', '').toInteger()

group = maoni_group
version = VERSION_NAME

android {
    compileSdkVersion 32

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 32
        versionCode VERSION_CODE
        versionName VERSION_NAME
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
//        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

dependencies {
    api project(':maoni-common')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.13.2'

    implementation 'io.karn:khttp-android:0.1.2'
    implementation "org.jetbrains.anko:anko-sdk27:$anko_version"
}

task generateSourcesJar(type: Jar) {
    classifier 'sources'
}

task generateJavadocs(type: Javadoc) {
    failOnError false
}

task generateJavadocsJar(type: Jar) {
    from generateJavadocs.destinationDir
    classifier 'javadoc'
}

generateJavadocsJar.dependsOn generateJavadocs

artifacts {
    archives generateJavadocsJar
    archives generateSourcesJar
}

publishing {
    publications {
        release(MavenPublication) {
            // The coordinates of the library, being set from variables that
            // we'll set up later
            groupId maoni_group
            artifactId 'maoni-slack'
            version maoni_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 generateSourcesJar
            artifact generateJavadocsJar

            // Mostly self-explanatory metadata
            pom {
                name = 'maoni-slack'
                description = 'Handler for Maoni that sends user feedback to a Slack channel'
                url = 'https://github.com/rm3l/maoni/tree/master/callbacks/maoni-slack'
                licenses {
                    license {
                        name = 'MIT License'
                        url = 'https://github.com/rm3l/maoni/blob/master/LICENSE'
                    }
                }
                developers {
                    developer {
                        id = 'rm3l'
                        name = 'Armel Soro'
                        email = 'armel@rm3l.org'
                    }
                    // 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:rm3l/maoni.git'
                    developerConnection = 'scm:git:ssh://github.com/rm3l/maoni.git'
                    url = 'https://github.com/rm3l/maoni/tree/master/callbacks/maoni-slack'
                }
                // A slightly hacky fix so that your POM will include any transitive dependencies
                // that your library builds upon
                withXml {
                    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://oss.sonatype.org/service/local/staging/deploy/maven2/"
            credentials {
                username rootProject.ext.has('ossrhUsername') ? rootProject.ext.ossrhUsername : ''
                password rootProject.ext.has('ossrhPassword') ? rootProject.ext.ossrhPassword : ''
            }
        }
    }
}

signing {
    sign publishing.publications
}