diff --git a/README.md b/README.md index b33e922..76294a9 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ Available configuration fields: | `outputJson` | `"licenses.json"` | The file name of the output of the `generateLicenseJson` task | | `ignoredGroups` | `[]` (empty array) | An array of group names the plugin will ignore (useful for internal dependencies with missing .pom files) | | `ignoredProjects` | `[]` (empty array) | An array of project names the plugin will ignore (To ignore particular internal projects like custom lint) | +| `customStyles` | `""` | The additional style of the output of the `generateLicensePage` task HTML file. | ## DataSet Format diff --git a/plugin/src/main/java/com/cookpad/android/plugin/license/LicenseToolsPluginExtension.kt b/plugin/src/main/java/com/cookpad/android/plugin/license/LicenseToolsPluginExtension.kt index 8c6ca5a..2649239 100644 --- a/plugin/src/main/java/com/cookpad/android/plugin/license/LicenseToolsPluginExtension.kt +++ b/plugin/src/main/java/com/cookpad/android/plugin/license/LicenseToolsPluginExtension.kt @@ -14,6 +14,8 @@ open class LicenseToolsPluginExtension { var ignoredProjects = emptySet() + var customStyles = "" + companion object { const val NAME = "licenseTools" } diff --git a/plugin/src/main/java/com/cookpad/android/plugin/license/Templates.kt b/plugin/src/main/java/com/cookpad/android/plugin/license/Templates.kt index 732956e..ada5cc7 100644 --- a/plugin/src/main/java/com/cookpad/android/plugin/license/Templates.kt +++ b/plugin/src/main/java/com/cookpad/android/plugin/license/Templates.kt @@ -63,11 +63,12 @@ object Templates { } } - fun wrapWithLayout(content: CharSequence): String { + fun wrapWithLayout(content: CharSequence, customStyle: String): String { val templateFile = "template/layout.html" val map = LinkedHashMap(1) map["content"] = makeIndent(content, 4) + map["custom_css"] = customStyle return templateEngine.createTemplate( readResourceContent( templateFile diff --git a/plugin/src/main/java/com/cookpad/android/plugin/license/task/GenerateLicensePage.kt b/plugin/src/main/java/com/cookpad/android/plugin/license/task/GenerateLicensePage.kt index 3ef084e..3c8bea4 100644 --- a/plugin/src/main/java/com/cookpad/android/plugin/license/task/GenerateLicensePage.kt +++ b/plugin/src/main/java/com/cookpad/android/plugin/license/task/GenerateLicensePage.kt @@ -41,6 +41,9 @@ object GenerateLicensePage { throw GradleException("generateLicensePage: more than one library isn't enough information") } - return Templates.wrapWithLayout(licenseHtml) + return Templates.wrapWithLayout( + licenseHtml, + project.extensions.getByType(LicenseToolsPluginExtension::class.java).customStyles.trimIndent() + ) } } diff --git a/plugin/src/main/resources/template/layout.html b/plugin/src/main/resources/template/layout.html index 1de747b..27a1b0b 100644 --- a/plugin/src/main/resources/template/layout.html +++ b/plugin/src/main/resources/template/layout.html @@ -72,6 +72,7 @@ input:checked ~ .license { max-height: none; } + ${custom_css} diff --git a/sample/build.gradle b/sample/build.gradle index e2534ce..d3432aa 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -55,6 +55,8 @@ licenseTools { ignoredProjects = [ 'plugin', ] + + customStyles = file('custom_style.css').text } dependencies { diff --git a/sample/custom_style.css b/sample/custom_style.css new file mode 100644 index 0000000..e7c06cc --- /dev/null +++ b/sample/custom_style.css @@ -0,0 +1,3 @@ +body{ + background-color: pink; + } \ No newline at end of file diff --git a/sample/src/main/assets/licenses.html b/sample/src/main/assets/licenses.html index 58f8a0a..e61bb80 100644 --- a/sample/src/main/assets/licenses.html +++ b/sample/src/main/assets/licenses.html @@ -72,6 +72,9 @@ input:checked ~ .license { max-height: none; } + body{ + background-color: pink; + }