Skip to content
This repository was archived by the owner on Apr 13, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ open class LicenseToolsPluginExtension {

var ignoredProjects = emptySet<String>()

var customStyles = ""

companion object {
const val NAME = "licenseTools"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String>(1)
map["content"] =
makeIndent(content, 4)
map["custom_css"] = customStyle
return templateEngine.createTemplate(
readResourceContent(
templateFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
}
}
1 change: 1 addition & 0 deletions plugin/src/main/resources/template/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
input:checked ~ .license {
max-height: none;
}
${custom_css}
</style>
</head>
<body>
Expand Down
2 changes: 2 additions & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ licenseTools {
ignoredProjects = [
'plugin',
]

customStyles = file('custom_style.css').text
}

dependencies {
Expand Down
3 changes: 3 additions & 0 deletions sample/custom_style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body{
background-color: pink;
}
3 changes: 3 additions & 0 deletions sample/src/main/assets/licenses.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
input:checked ~ .license {
max-height: none;
}
body{
background-color: pink;
}
</style>
</head>
<body>
Expand Down