#5731 Add license information to generated POM files

This commit is contained in:
toxicbakery 2019-04-04 15:39:19 -04:00 committed by Ian Thomas
parent 9dc22c3086
commit 70530cd1e6
2 changed files with 33 additions and 0 deletions

View File

@ -44,6 +44,7 @@ allprojects {
}
buildDir = "${externalBuildDir}/${project.name}"
}
group = 'com.google.android.exoplayer'
}
apply from: 'javadoc_combined.gradle'

View File

@ -23,6 +23,20 @@ if (project.ext.has("exoplayerPublishEnabled")
groupId = 'com.google.android.exoplayer'
website = 'https://github.com/google/ExoPlayer'
}
gradle.taskGraph.whenReady { taskGraph ->
project.tasks
.findAll { task -> task.name.contains("generatePomFileFor") }
.forEach { task ->
task.doLast {
task.outputs.files
.filter { File file ->
file.path.contains("publications") && file.name.matches("^pom-.+\\.xml\$")
}
.forEach { File file -> addLicense(file) }
}
}
}
}
def getBintrayRepo() {
@ -30,3 +44,21 @@ def getBintrayRepo() {
property('publicRepo').toBoolean()
return publicRepo ? 'exoplayer' : 'exoplayer-test'
}
static void addLicense(File pom) {
def licenseNode = new Node(null, "license")
licenseNode.append(new Node(null, "name", "The Apache Software License, Version 2.0"))
licenseNode.append(new Node(null, "url", "http://www.apache.org/licenses/LICENSE-2.0.txt"))
licenseNode.append(new Node(null, "distribution", "repo"))
def licensesNode = new Node(null, "licenses")
licensesNode.append(licenseNode)
def xml = new XmlParser().parse(pom)
xml.append(licensesNode)
def writer = new PrintWriter(new FileWriter(pom))
def printer = new XmlNodePrinter(writer)
printer.preserveWhitespace = true
printer.print(xml)
writer.close()
}