Skip to content

Commit

Permalink
Merge pull request #654 from mikepenz/feature/651
Browse files Browse the repository at this point in the history
Lazy gradle task registration
  • Loading branch information
mikepenz authored May 28, 2021
2 parents 4ec59a0 + e37dcb0 commit 5526797
Showing 1 changed file with 29 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ class AboutLibrariesPlugin implements Plugin<Project> {
project.extensions.create('aboutLibraries', AboutLibrariesExtension)

// task for cleaning
def cleanupTask = project.tasks.create("aboutLibrariesClean", AboutLibrariesCleanTask)
cleanupTask.description = "Cleans the generated data from the AboutLibraries plugin"
cleanupTask.group = 'Build'
cleanupTask.dependencies = project.file("$project.buildDir/generated/aboutlibraries/")
project.tasks.register("aboutLibrariesClean", AboutLibrariesCleanTask) {
it.description = "Cleans the generated data from the AboutLibraries plugin"
it.group = 'Build'
it.dependencies = project.file("$project.buildDir/generated/aboutlibraries/")
}
// project.tasks.findByName("clean").dependsOn(cleanupTask)
// doing a clean will regardless delete the dir containing the files

Expand All @@ -29,14 +30,16 @@ class AboutLibrariesPlugin implements Plugin<Project> {
}

// task to output library names with ids for further actions
AboutLibrariesIdTask taskId = project.tasks.create("findLibraries", AboutLibrariesIdTask)
taskId.description = "Writes the relevant meta data for the AboutLibraries plugin to display dependencies"
taskId.group = 'Help'
project.tasks.register("findLibraries", AboutLibrariesIdTask) {
it.description = "Writes the relevant meta data for the AboutLibraries plugin to display dependencies"
it.group = 'Help'
}

// task to output libraries, and their license in CSV format to the CLI
AboutLibrariesExportTask exportTaskId = project.tasks.create("exportLibraries", AboutLibrariesExportTask)
exportTaskId.description = "Writes all libraries and their license in CSV format to the CLI"
exportTaskId.group = 'Help'
project.tasks.register("exportLibraries", AboutLibrariesExportTask) {
it.description = "Writes all libraries and their license in CSV format to the CLI"
it.group = 'Help'
}
}

private static void createAboutLibrariesTask(Project project, def variant) {
Expand Down Expand Up @@ -74,22 +77,25 @@ class AboutLibrariesPlugin implements Plugin<Project> {
}

// task to generate libraries, and their license into the build folder (not hooked to the build task)
AboutLibrariesTask generateTask = project.tasks.create("generateLibraryDefinitions${variant.name.capitalize()}", AboutLibrariesTask)
generateTask.description = "Manually write meta data for the AboutLibraries plugin"
generateTask.group = 'Build'
generateTask.setDependencies(project.file("$project.buildDir/generated/aboutlibraries/${variant.name}/res/"))
generateTask.setVariant(variant.name)
project.tasks.register("generateLibraryDefinitions${variant.name.capitalize()}", AboutLibrariesTask) {
it.description = "Manually write meta data for the AboutLibraries plugin"
it.group = 'Build'
it.setDependencies(project.file("$project.buildDir/generated/aboutlibraries/${variant.name}/res/"))
it.setVariant(variant.name)
}

// task to output libraries, and their license in CSV format to the CLI
AboutLibrariesExportTask exportTaskId = project.tasks.create("exportLibraries${variant.name.capitalize()}", AboutLibrariesExportTask)
exportTaskId.description = "Writes all libraries and their license in CSV format to the CLI"
exportTaskId.group = 'Help'
exportTaskId.setVariant(variant.name)
project.tasks.register("exportLibraries${variant.name.capitalize()}", AboutLibrariesExportTask) {
it.description = "Writes all libraries and their license in CSV format to the CLI"
it.group = 'Help'
it.setVariant(variant.name)
}

// task to output libraries, their license in CSV format and source to a given location
AboutLibrariesExportComplianceTask exportComplianceTaskId = project.tasks.create("exportComplianceLibraries${variant.name.capitalize()}", AboutLibrariesExportComplianceTask)
exportComplianceTaskId.description = "Writes all libraries with their source and their license in CSV format to the configured directory"
exportComplianceTaskId.group = 'Help'
exportComplianceTaskId.setVariant(variant.name)
project.tasks.register("exportComplianceLibraries${variant.name.capitalize()}", AboutLibrariesExportComplianceTask) {
it.description = "Writes all libraries with their source and their license in CSV format to the configured directory"
it.group = 'Help'
it.setVariant(variant.name)
}
}
}

0 comments on commit 5526797

Please sign in to comment.