Liquibase changesets are not running in bootRepackage gradle task - spring

I have created liquibase changesets, in the Spring boot application. If I execute bootRun task then changesets get executed however, if I run bootRepackage changesets are not executed.
What additional configuration I need to do in order to run changesets with bootRepackage.

I suggest that you add the task tree plugin to your script
plugins {
id "com.dorongold.task-tree" version "1.3"
}
And then run
gradle bootRun bootRepackage taskTree
You should then see which tasks are run by the bootRun task which are not run by the bootRepackage task.
You'd then likely add a task dependency in build.gradle
bootRepackage {
dependsOn someLiquibaseTask
}

Related

How can I create a gradle task to generate exploded war with Sprint boot "bootWar" plugin?

I use the "org.springframework.boot" plugin and use the bootWar task to generate a war file of my spring boot project.
I would like to have a task that creates an exploded version of this war file.
The standard way to do that with the 'war' plugin is :
task explodedWar(type: Sync) {
into "${war.archivePath.parentFile.getAbsolutePath()}/exploded/${war.archivePath.name}"
with war
}
How can i do the same thing with the spring-boot/bootWar plugin?
Try with:
task explodeBootWar(type: Sync) {
dependsOn bootWar
into "$buildDir/boot_war_exploded"
from project.zipTree(bootWar.archiveFile)
}
You can use the with method on the normal war task because it is basically just a copySpec. However, the bootWar task does some additional things, so you have to build and unzip the actual archive.

gradle composite build execute tasks transitively

When executing gradle build in a composite gradle build only compileJava task is executed transitively. Others, like the test task are not.
How can I enforce that my tests are also run on build?
I tried:
build.dependsOn gradle.includedBuilds*.task(':build')
but that did not work.
https://docs.gradle.org/current/userguide/composite_builds.html
here is the gist:
// settings
if (file('../myModule').exists()) {
includeBuild('../myModule')
}
// build1
dependencies {
compile 'mygroup:MyModule:1.0.0'
}

Execute a Task of a sub-module of a Gradle multiproject

I have the following multiproject structure:
settings.gradle
rootProject.name = 'toolbox-backend'
include 'toolbox-components-rest'
include 'toolbox-components-executor'
include 'toolbox-components-toolsyncer'
I'd love to create a task in my root build.gradle which will call the clean, build, install (application) and finally the run task of the toolbox-components-rest submodule.
task startREST() {
dependsOn ':toolbox-components-rest:clean'
dependsOn ':toolbox-components-rest:build'
dependsOn ':toolbox-components-rest:bootRun'
println "[Toolbox $version] Starting REST interface..."
}
This does work - BUT the bootRun task is running before build which runs before clean. I'd like to have it exactly the other way around
Fixed the above with
bootRun.mustRunAfter build
build.mustRunAfter clean
in the gradle.build of the toolbox-components-rest submodule

Gradle - run testReport task after test phase of all submodules

I have a simple project with subprojects and I want to generate aggregate report for all tests when I execute gradle test command.
I have followed the gradle documentation and added following:
task testReport(type: TestReport) {
// make sure this task is run after all subproject test tasks
mustRunAfter subprojects*.test
destinationDir = file("$buildDir/reports/allTests")
// Include the results from the `test` task in all subprojects
reportOn subprojects*.test
}
This works when I execute gradle test testReport, but when I execute gradle test or gradle build in the root project - the task testReport is not run.
How do make gradle to run the task without specifying it every time?
Add: test.finalizedBy 'testReport' to your build.gradle; just at the root level, doesn't have to be inside any closure.
taskX.finalizedBy taskY
Will run taskY everytime taskX completes execution successfully.

Why is uploadArchives not listed at the tasks list?

i thought uploadArchives is a task which is provided by the java plugin.
In my build.gradle i use the java plugin:
apply plugin: 'java'
But if i invoke gradle tasks on command line, i can't see the uploadArchives task.
Even not with gradle gradle tasks --all
The uploadArchives task is listed in the gradle java plugin documentation
see http://www.gradle.org/java_plugin (table 11).
I use gradle version 1.0-milestone-6.
I can invoke gradle uploadArchives without error, but the task is not listed.
The uploadArchives task is added as a Rule to your build script and not explicitly by name. In the output of "gradle tasks" you should see this line:
Pattern: upload<ConfigurationName>: Assembles and uploads the artifacts belonging to a configuration.
This means, that for each configuration in your build file, an according uploadTask exist. The java plugin adds an configuration named archives to your build script. By adding the configuration "archives" to your build script explicitly by the java plugin, the uploadArchives task is added implicitly too.
There are scenarios, where gradle can't know what tasks need to be materialized by a rule.
E.g.
tasks.addRule("Pattern: ping<ID>") { String taskName ->
if (taskName.startsWith("ping")) {
task(taskName) << {
println "Pinging: " + (taskName - 'ping')
}
}
}
There is no way to figure out which ping tasks should be shown as they are just materialized when triggered from commandline via 'gradle pingServer1 pingServer2 pingServer3'
regards,
René
The uploadArchives task is a part of the maven-plugin. You have to add:
apply plugin: 'maven'

Resources