renanfranca / renanfranca.github.io

3 stars 0 forks source link

[Draft for jhipster] Implement the option to add new instructions at the end of `tasks.test` in the `build.gradle.kts` #23

Closed renanfranca closed 4 months ago

renanfranca commented 4 months ago

I suggest changing the existing GradleConfiguration API.

from:

.gradleConfigurations()
  .configuration()
.and()

to:

.configurations()
  .newConfigurarion("")
  .addTasksTestInstruction("")
.and()

Here is how the changes will affect the existing code:

At LocalProfileModuleFactory from:

.gradleConfigurations()
  .configuration(
    """
    tasks.build {
      dependsOn("processResources")
    }

    tasks.processResources {
      filesMatching("**/*.yml") {
        filter { it.replace("@spring.profiles.active@", springProfilesActive) }
      }
      filesMatching("**/*.properties") {
        filter { it.replace("@spring.profiles.active@", springProfilesActive) }
      }
    }
    """
  )

to:

.gradleConfigurations()
  .newConfigurarion(
    """
    tasks.build {
      dependsOn("processResources")
    }

    tasks.processResources {
      filesMatching("**/*.yml") {
        filter { it.replace("@spring.profiles.active@", springProfilesActive) }
      }
      filesMatching("**/*.properties") {
        filter { it.replace("@spring.profiles.active@", springProfilesActive) }
      }
    }
    """
  )

At JacocoModuleFactory from:

 .optionalReplacements()
  .in(path("build.gradle.kts"))
  .add(EXISTING_BUILD_GRADLE_TASK_TEST_NEEDLE, ADD_JACOCO_BUILD_GRADLE_TASK_TEST)
  .and()
.and()

to:

.configurations()
  .addTasksTestInstruction("""finalizedBy("jacocoTestReport")""")
.and()

The goal of this issue is to make this possible. Implement the option to add new configurations at the end of tasks.test in the build.gradle.kts