Bug 1506601 - Add dependencies to GeckoView's pom file. r=nalexander

This adds GeckoView dependencies to the Maven pom file by iterating through the
"implementation" dependencies and adding them manually to the pom XML.

This workaround can be removed when issue [0] is fixed.

This also moves the publishing from the old 'maven' plugin to the new
'maven-publishing' see also [1] and [2].

[0]: https://github.com/gradle/gradle/issues/1842
[1]: https://docs.gradle.org/current/userguide/maven_plugin.html
[2]: https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven

Differential Revision: https://phabricator.services.mozilla.com/D13113

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Agi Sferro 2018-11-29 19:39:11 +00:00
Родитель 85e7888e4d
Коммит 37e85f9edf
2 изменённых файлов: 59 добавлений и 31 удалений

Просмотреть файл

@ -288,31 +288,70 @@ android.libraryVariants.all { variant ->
configureLibraryVariantWithJNIWrappers(variant, "Generated")
}
apply plugin: 'maven'
apply plugin: 'maven-publish'
uploadArchives {
repositories.mavenDeployer {
pom.groupId = 'org.mozilla.geckoview'
version = computeVersionNumber()
if (mozconfig.substs.MOZ_UPDATE_CHANNEL == 'release') {
// release artifacts don't specify the channel, for the sake of simplicity
pom.artifactId = "geckoview-${mozconfig.substs.ANDROID_CPU_ARCH}"
} else {
pom.artifactId = "geckoview-${mozconfig.substs.MOZ_UPDATE_CHANNEL}-${mozconfig.substs.ANDROID_CPU_ARCH}"
}
publishing {
publications {
android.libraryVariants.all { variant ->
"${variant.name}"(MavenPublication) {
pom {
groupId = 'org.mozilla.geckoview'
pom.version = computeVersionNumber()
if (mozconfig.substs.MOZ_UPDATE_CHANNEL == 'release') {
// release artifacts don't specify the channel, for the sake of simplicity
artifactId = "geckoview-${mozconfig.substs.ANDROID_CPU_ARCH}"
} else {
artifactId = "geckoview-${mozconfig.substs.MOZ_UPDATE_CHANNEL}-${mozconfig.substs.ANDROID_CPU_ARCH}"
}
pom.project {
licenses {
license {
name 'The Mozilla Public License, v. 2.0'
url 'http://mozilla.org/MPL/2.0/'
distribution 'repo'
url = 'https://wiki.mozilla.org/Mobile/GeckoView'
licenses {
license {
name = 'The Mozilla Public License, v. 2.0'
url = 'http://mozilla.org/MPL/2.0/'
distribution = 'repo'
}
}
scm {
connection = 'scm::hg::https://hg.mozilla.org/mozilla-central/'
url = 'https://hg.mozilla.org/mozilla-central/'
}
// Unfortunately Gradle does not provide a way to expose dependencies for custom
// project types like Android plugins. So we need to add them manually to the POM
// XML here, or use a plugin that achieves the same (like
// https://github.com/wupdigital/android-maven-publish). We elect to do this
// manually since our dependencies are simple and plugins increase our complexity
// surface. This workaround can be removed after this issue is fixed:
// https://github.com/gradle/gradle/issues/1842
withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.getByName("implementation").dependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
artifact tasks["bundle${variant.name.capitalize()}"]
// Javadoc and sources for developer ergononomics.
artifact tasks["javadocJar${variant.name.capitalize()}"]
artifact tasks["sourcesJar${variant.name.capitalize()}"]
}
}
repository(url: "file://${project.buildDir}/maven")
}
repositories {
maven {
url = "${project.buildDir}/maven"
}
}
}
@ -334,14 +373,6 @@ afterEvaluate {
def Configuration archivesConfig = project.getConfigurations().getByName('archives')
archivesConfig.artifacts.removeAll { it.extension.equals('aar') }
artifacts {
// Instead of default (release) configuration, publish one with Gecko binaries.
archives bundleWithGeckoBinariesRelease
// Javadoc and sources for developer ergononomics.
archives javadocJarWithGeckoBinariesRelease
archives sourcesJarWithGeckoBinariesRelease
}
// For now, ensure Kotlin is only used in tests.
android.sourceSets.all { sourceSet ->
if (sourceSet.name.startsWith('test') || sourceSet.name.startsWith('androidTest')) {

Просмотреть файл

@ -265,7 +265,7 @@ def gradle_android_archive_geckoview_tasks(build_config):
'geckoview:assemble{geckoview.variant.name}AndroidTest'.format(geckoview=build_config.geckoview),
'geckoview_example:assemble{geckoview_example.variant.name}'.format(geckoview_example=build_config.geckoview_example),
'geckoview_example:assemble{geckoview_example.variant.name}AndroidTest'.format(geckoview_example=build_config.geckoview_example),
'geckoview:uploadArchives',
'geckoview:publish{geckoview.variant.name}PublicationToMavenRepository'.format(geckoview=build_config.geckoview),
]
set_config('GRADLE_ANDROID_ARCHIVE_GECKOVIEW_TASKS', gradle_android_archive_geckoview_tasks)
@ -329,10 +329,7 @@ def gradle_android_dependencies_tasks(*tasks):
def withoutGeckoBinaries(task):
return task.replace('withGeckoBinaries', 'withoutGeckoBinaries')
def isUploadArchives(task):
return 'uploadArchives' in task
return list(ifilterfalse(isUploadArchives, imap(withoutGeckoBinaries, chain(*tasks))))
return list(imap(withoutGeckoBinaries, chain(*tasks)))
set_config('GRADLE_ANDROID_DEPENDENCIES_TASKS', gradle_android_dependencies_tasks)