liquibase / liquibase-gradle-plugin

A Gradle plugin for Liquibase
Other
197 stars 57 forks source link

Problem with using the Liquibase block in build.gradle #122

Open DavidNovo opened 1 year ago

DavidNovo commented 1 year ago

Take a look at this fragment of build.gradle:

` import org.liquibase.gradle.LiquibaseTask

buildscript { ext { . . . . } }

plugins { id 'org.liquibase.gradle' version '2.2.0' id 'org.springframework.boot' version "${springBootVersion}" id 'io.spring.dependency-management' version "${springDependencyManagementVersion}" id 'war' id 'jacoco' id 'idea' id 'org.sonarqube' version "${sonarVersion}" id 'com.adarshr.test-logger' version '2.1.1' id 'application' }

version = "$proj_version"

sourceSets { test { java { srcDirs = ['src/test/java'] } } }

dependencies {

implementation project(':task-common')

// spring
implementation "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"
implementation "org.springframework.boot:spring-boot-starter-aop:$springBootVersion"
implementation "org.springframework.boot:spring-boot-starter-data-jdbc:$springBootVersion"
implementation "org.springframework.boot:spring-boot-starter-jdbc:$springBootVersion"
implementation "org.springframework.boot:spring-boot-starter-security:$springBootVersion"
implementation "org.springframework.boot:spring-boot-starter-validation:$springBootVersion"
implementation "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
implementation "org.springframework.boot:spring-boot-starter-quartz:$springBootVersion"
implementation "org.springframework.boot:spring-boot-starter-activemq:$springBootVersion"
compileOnly "org.springframework.boot:spring-boot-configuration-processor:$springBootVersion"

// datadog
implementation 'com.datadoghq:dd-trace-api:0.90.0'

//logging
implementation 'net.logstash.logback:logstash-logback-encoder:7.2'

//jdbc drivers
runtimeOnly 'com.oracle.database.jdbc:ojdbc10:19.18.0.0'

//openapi
implementation 'org.springdoc:springdoc-openapi-ui:1.6.13'
implementation 'org.springdoc:springdoc-openapi-security:1.6.13'

//testing
testImplementation "org.springframework.boot:spring-boot-starter-test:$springBootVersion"

// for Liquidbase
implementation 'org.liquibase:liquibase-core:4.8.0'
liquibaseRuntime 'org.liquibase:liquibase-gradle-plugin:2.0.1'
liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:2.0.2'
liquibaseRuntime 'com.h2database:h2'
runtimeOnly 'com.h2database:h2'

}

liquibase { activities { main { changelogFile 'src/main/resources/db/changelog/db.changelog-master.yaml' url 'jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1' username 'sa' password '' } } } ...} IntelliJ is giving me warnings that the 'main' in 'build' cannot be applied to '(groovy.lang.Closure)' . I ca still run and build the project but I still get that warning from IntelliJ. When I try to add a task to the build.gradle file like this: tasks.register('updateDatabase', LiquibaseTask) { group = 'liquibase' description = 'Update the database with the latest changes.' activities.main.action = 'update' }`

I can run 'gradle clan build' but if I try to run ' gradle rollbackDatabase' I get this error: `> Could not create task ':task-dispatcher-service:rollbackDatabase'.

Could not get unknown property 'activities' for task ':task-dispatcher-service:rollbackDatabase' of type org.liquibase.gradle.LiquibaseTask. ` Any way to fix this?

stevesaliman commented 9 months ago

I get that warning too. I've never figured out why :-)

I haven't spent a lot of time on it because, as you said, it doesn't affect anything with the build, it is just an annoying squiggly line in the IDE.