1+ import groovy.xml.MarkupBuilder
2+
13/*
24 * build.gradle
35 *
@@ -80,6 +82,76 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
8082 from javadoc. destinationDir
8183}
8284
85+ task gatherLicenses {
86+ doLast {
87+ file(" $buildDir /licenses.xml" ). withWriter { writer ->
88+ def xml = new MarkupBuilder (writer)
89+
90+ xml. doubleQuotes = true
91+ xml. mkp. xmlDeclaration(version : ' 1.0' , encoding : ' utf-8' )
92+
93+ xml. licenses() {
94+ license() {
95+ name(" pdf2htmlEX-Android" )
96+ url(" pdf2htmlEX-Android/LICENSE\n\n " + new File (" $projectDir /../LICENSE" ). getText(' UTF-8' ) + " \n\n " )
97+ distribution(' repo' )
98+ }
99+
100+ def addLicense = { depName , licenseFiles ->
101+ license {
102+ name(depName)
103+ def urlVal = new StringBuilder ()
104+ licenseFiles. each() { licenseFilename ->
105+ urlVal. append(" $depName /$licenseFilename \n\n " )
106+
107+ def licenseFile = new File (" $projectDir /../dependency-builder/.cxx/cmake/release/x86/$depName -prefix/src/$depName /$licenseFilename " )
108+ def licenseText = licenseFile. getText(' UTF-8' )
109+ // LGPL2.1 and GPLv2 licenses include form feed (page break) characters.
110+ // XML does not take kindly to form feed characters.
111+ if ((depName == " cairo" && licenseFilename == " COPYING-LGPL-2.1" ) ||
112+ (depName == " freetype" && licenseFilename == " docs/GPLv2.TXT" ) ||
113+ (depName == " glib-2.0" && licenseFilename == " COPYING" ) ||
114+ (depName == " fribidi" && licenseFilename == " COPYING" ) ||
115+ (depName == " iconv" && licenseFilename == " COPYING.LIB" ) ||
116+ (depName == " intl" && licenseFilename == " COPYING" ) ||
117+ (depName == " pango" && licenseFilename == " COPYING" )) {
118+ urlVal. append(licenseText. replace(" \u 000C" , " " ))
119+ } else {
120+ urlVal. append(licenseText)
121+ }
122+ urlVal. append(" \n\n " )
123+ }
124+ url(urlVal)
125+ }
126+ }
127+ addLicense(" pdf2htmlEX" , [" LICENSE" , " LICENSE_GPLv3" ])
128+ addLicense(" cairo" , [" COPYING" , " COPYING-LGPL-2.1" , " COPYING-MPL-1.1" ])
129+ addLicense(" fontconfig" , [" COPYING" ])
130+ addLicense(" freetype" , [" docs/LICENSE.TXT" , " docs/GPLv2.TXT" , " docs/FTL.TXT" ])
131+ addLicense(" fribidi" , [" COPYING" ])
132+ addLicense(" glib-2.0" , [" COPYING" ])
133+ addLicense(" harfbuzz" , [" COPYING" ])
134+ addLicense(" iconv" , [" README" , " COPYING" , " COPYING.LIB" ])
135+ addLicense(" intl" , [" COPYING" ])
136+ addLicense(" lcms2" , [" COPYING" ])
137+ addLicense(" libffi" , [" LICENSE" ])
138+ addLicense(" libfontforge" , [" LICENSE" , " COPYING.gplv3" ])
139+ addLicense(" libjpeg" , [" LICENSE.md" , " README.ijg" ])
140+ addLicense(" libopenjp2" , [" LICENSE" ])
141+ addLicense(" libpng" , [" LICENSE" ])
142+ addLicense(" libtiff-4" , [" COPYRIGHT" ])
143+ addLicense(" libtool" , [" COPYING" ])
144+ addLicense(" libuninameslist" , [" LICENSE" ])
145+ addLicense(" libxml-2.0" , [" Copyright" ])
146+ addLicense(" pango" , [" COPYING" ])
147+ addLicense(" pixman-1" , [" COPYING" ])
148+ addLicense(" poppler-data" , [" COPYING" , " COPYING.adobe" , " COPYING.gpl2" ])
149+ addLicense(" poppler" , [" COPYING" , " COPYING3" ])
150+ }
151+ }
152+ }
153+ }
154+
83155bintray {
84156 user = project. hasProperty(' bintrayUser' ) ? project. property(' bintrayUser' ) : System . getenv(' BINTRAY_USER' )
85157 key = project. hasProperty(' bintrayApiKey' ) ? project. property(' bintrayApiKey' ) : System . getenv(' BINTRAY_API_KEY' )
@@ -119,13 +191,6 @@ publishing{
119191 packaging = ' aar'
120192 url = ' https://github.com/ViliusSutkus89/pdf2htmlEX-Android'
121193 inceptionYear = ' 2019'
122- licenses {
123- license {
124- name = ' The GNU General Public License, Version 3'
125- url = ' https://www.gnu.org/licenses/gpl-3.0.txt'
126- distribution = ' repo'
127- }
128- }
129194 developers {
130195 developer {
131196 id = " ViliusSutkus89"
@@ -139,8 +204,21 @@ publishing{
139204 }
140205 }
141206 pom. withXml {
142- def dependenciesNode = asNode(). appendNode(' dependencies' )
143- // Iterate over the implementation dependencies (we don't want the test ones), adding a <dependency> node for each
207+ def node = asNode()
208+
209+ def licensesNode = node. appendNode(" licenses" )
210+ new XmlSlurper (). parse(" $buildDir /licenses.xml" ). license. each {
211+ def license = licensesNode. appendNode(' license' )
212+ license. appendNode(' name' , it. name)
213+ license. appendNode(' url' , it. url)
214+ if (it. distribution) {
215+ license. appendNode(' distribution' , it. distribution)
216+ }
217+ }
218+
219+ def dependenciesNode = node. appendNode(' dependencies' )
220+ // Iterate over the implementation dependencies (we don't want the test ones),
221+ // adding a <dependency> node for each
144222 configurations. implementation. allDependencies. each {
145223 // Ensure dependencies such as fileTree are not included in the pom.
146224 if (it. name != ' unspecified' ) {
0 commit comments