publish.gradle (2943B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 import groovy.transform.Memoized 6 7 def libLicense = properties.libLicense 8 def libLicenseUrl = properties.libLicenseUrl 9 10 static def getLocalPublicationTimestamp() { 11 def date = new Date() 12 return date.format('yyyyMMddHHmmss') 13 } 14 15 ext.configurePublish = { groupIdArg, artifactIdArg, descriptionArg -> 16 apply plugin: 'maven-publish' 17 18 tasks.register('sourcesJar', Jar) { 19 from android.sourceSets.main.java.srcDirs 20 archiveClassifier = 'sources' 21 } 22 23 android { 24 publishing { 25 singleVariant("release") { 26 withSourcesJar() 27 } 28 } 29 } 30 31 afterEvaluate { 32 publishing { 33 publications { 34 release(MavenPublication) { 35 from components.release 36 37 groupId = groupIdArg 38 artifactId = artifactIdArg 39 // 'local' is for streamlining local publication workflow. 40 version = config.componentsVersion + (project.hasProperty('local') ? '-local' + project.property('local') : '') 41 42 pom { 43 description = descriptionArg 44 45 licenses { 46 license { 47 name = libLicense 48 url = libLicenseUrl 49 } 50 } 51 52 developers { 53 developer { 54 name = 'Mozilla Android Components Team' 55 email = 'android-components@lists.mozilla.org' 56 } 57 } 58 59 scm { 60 if (gradle.mozconfig.substs.MOZ_INCLUDE_SOURCE_INFO) { 61 // URL is like "https://hg.mozilla.org/mozilla-central/rev/1e64b8a0c546a49459d404aaf930d5b1f621246a". 62 connection = "scm:hg:${gradle.mozconfig.source_repo.MOZ_SOURCE_REPO}" 63 url = gradle.mozconfig.source_repo.MOZ_SOURCE_URL 64 tag = gradle.mozconfig.source_repo.MOZ_SOURCE_STAMP 65 } else { 66 // Default to mozilla-central. 67 connection = 'scm:hg:https://hg.mozilla.org/mozilla-central/' 68 url = 'https://hg.mozilla.org/mozilla-central/' 69 } 70 } 71 } 72 } 73 } 74 repositories { 75 maven { 76 url = "${gradle.mozconfig.topobjdir}/gradle/maven" 77 } 78 } 79 } 80 } 81 }