| 
 | 1 | +apply plugin: 'maven-publish'  | 
 | 2 | +apply plugin: 'signing'  | 
 | 3 | + | 
 | 4 | +task androidSourcesJar(type: Jar) {  | 
 | 5 | +    archiveClassifier.set('sources')  | 
 | 6 | +    if (project.plugins.findPlugin("com.android.library")) {  | 
 | 7 | +        from android.sourceSets.main.java.srcDirs  | 
 | 8 | +    } else {  | 
 | 9 | +        from sourceSets.main.java.srcDirs  | 
 | 10 | +    }  | 
 | 11 | +}  | 
 | 12 | + | 
 | 13 | +artifacts {  | 
 | 14 | +    archives androidSourcesJar  | 
 | 15 | +}  | 
 | 16 | + | 
 | 17 | +group = PUBLISH_GROUP_ID  | 
 | 18 | +version = PUBLISH_VERSION  | 
 | 19 | + | 
 | 20 | +afterEvaluate {  | 
 | 21 | +    publishing {  | 
 | 22 | +        publications {  | 
 | 23 | +            release(MavenPublication) {  | 
 | 24 | +                // The coordinates of the library, being set from variables that  | 
 | 25 | +                // we'll set up later  | 
 | 26 | +                groupId PUBLISH_GROUP_ID  | 
 | 27 | +                artifactId PUBLISH_ARTIFACT_ID  | 
 | 28 | +                version PUBLISH_VERSION  | 
 | 29 | + | 
 | 30 | +                // Two artifacts, the `aar` (or `jar`) and the sources  | 
 | 31 | +                if (project.plugins.findPlugin("com.android.library")) {  | 
 | 32 | +                    //from components.release  | 
 | 33 | +                } else {  | 
 | 34 | +                    artifact("$buildDir/libs/${project.getName()}-${version}.jar")  | 
 | 35 | +                }  | 
 | 36 | + | 
 | 37 | +                artifact bundleReleaseAar  | 
 | 38 | + | 
 | 39 | +                // Mostly self-explanatory metadata  | 
 | 40 | +                pom {  | 
 | 41 | +                    name = PUBLISH_ARTIFACT_ID  | 
 | 42 | +                    description = PUBLISH_DESCRIPTION  | 
 | 43 | +                    url = PUBLISH_URL  | 
 | 44 | +                    licenses {  | 
 | 45 | +                        license {  | 
 | 46 | +                            name = PUBLISH_LICENSE_NAME  | 
 | 47 | +                            url = PUBLISH_LICENSE_URL  | 
 | 48 | +                        }  | 
 | 49 | +                    }  | 
 | 50 | +                    developers {  | 
 | 51 | +                        developer {  | 
 | 52 | +                            id = PUBLISH_DEVELOPER_ID  | 
 | 53 | +                            name = PUBLISH_DEVELOPER_NAME  | 
 | 54 | +                            email = PUBLISH_DEVELOPER_EMAIL  | 
 | 55 | +                        }  | 
 | 56 | +                    }  | 
 | 57 | + | 
 | 58 | +                    // Version control info - if you're using GitHub, follow the  | 
 | 59 | +                    // format as seen here  | 
 | 60 | +                    scm {  | 
 | 61 | +                        connection = PUBLISH_SCM_CONNECTION  | 
 | 62 | +                        developerConnection = PUBLISH_SCM_DEVELOPER_CONNECTION  | 
 | 63 | +                        url = PUBLISH_SCM_URL  | 
 | 64 | +                    }  | 
 | 65 | +                }  | 
 | 66 | +            }  | 
 | 67 | +        }  | 
 | 68 | +    }  | 
 | 69 | +}  | 
 | 70 | + | 
 | 71 | +ext["signing.keyId"] = rootProject.ext["signing.keyId"]  | 
 | 72 | +ext["signing.password"] = rootProject.ext["signing.password"]  | 
 | 73 | +ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"]  | 
 | 74 | + | 
 | 75 | +signing {  | 
 | 76 | +    sign publishing.publications  | 
 | 77 | +}  | 
0 commit comments