Skip to content

Commit

Permalink
Lazily register localizer task
Browse files Browse the repository at this point in the history
Move task dependency assertion to GradleTestKit test now that it is lazy
  • Loading branch information
sghill committed Nov 22, 2019
1 parent 1e376b5 commit ef8b7de
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,15 @@ class JpiPlugin implements Plugin<Project> {
JavaPluginConvention javaConvention = project.convention.getPlugin(JavaPluginConvention)
JpiExtension jpiExtension = project.extensions.getByType(JpiExtension)

LocalizerTask localizer = project.tasks.create(LocalizerTask.TASK_NAME, LocalizerTask)
localizer.description = 'Generates the Java source for the localizer.'
localizer.group = BasePlugin.BUILD_GROUP
localizer.sourceDirs = javaConvention.sourceSets.main.resources.srcDirs
localizer.conventionMapping.map('destinationDir') {
jpiExtension.localizerOutputDir
def localizer = project.tasks.register(LocalizerTask.TASK_NAME, LocalizerTask) {
it.description = 'Generates the Java source for the localizer.'
it.group = BasePlugin.BUILD_GROUP
it.sourceDirs = javaConvention.sourceSets.main.resources.srcDirs
it.conventionMapping.map('destinationDir') {
jpiExtension.localizerOutputDir
}
}
javaConvention.sourceSets.main.java.srcDir { localizer.destinationDir }
javaConvention.sourceSets.main.java.srcDir { localizer.get().destinationDir }
project.tasks.named(javaConvention.sourceSets.main.compileJavaTaskName).configure {
it.dependsOn(localizer)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class JpiIntegrationSpec extends IntegrationSpec {
'processTestResources' | ':resolveTestDependencies' | TaskOutcome.NO_SOURCE
'jpi' | ':war' | TaskOutcome.SUCCESS
'compileTestJava' | ':insertTest' | TaskOutcome.SKIPPED
'compileJava' | ':localizer' | TaskOutcome.SUCCESS
}

@Unroll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ class JpiPluginSpec extends Specification {
localizerTask != null
localizerTask.destinationDir == new File(project.rootDir, expectedOutputDir)
localizerTask.sourceDirs == javaConvention.sourceSets.main.resources.srcDirs
project.tasks.compileJava.dependsOn.contains(localizerTask)
javaConvention.sourceSets.main.java.srcDirs.contains(localizerTask.destinationDir)

where:
Expand Down

0 comments on commit ef8b7de

Please sign in to comment.