Skip to content

Commit

Permalink
fix: Remove dependency on grails-shell
Browse files Browse the repository at this point in the history
Grails-shell is deprecated for removal.
  • Loading branch information
matrei committed Mar 7, 2024
1 parent 50c2ca8 commit daa3392
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 72 deletions.
3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ dependencies {
exclude group: 'org.liquibase', module: 'liquibase-test-harness'
exclude group: 'com.h2database', module: 'h2'
}
api("org.grails:grails-shell") {
exclude group: 'org.slf4j', module: 'slf4j-simple'
}
compileOnly "org.hibernate:hibernate-core:5.6.15.Final"

compileOnly 'org.springframework.boot:spring-boot-starter-logging'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015 original authors
* Copyright 2015-2024 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,39 +19,14 @@ import grails.config.ConfigMap
import grails.util.Environment
import grails.util.GrailsNameUtils
import groovy.transform.CompileStatic
import liquibase.parser.ChangeLogParser
import liquibase.parser.ChangeLogParserFactory
import org.grails.cli.profile.ExecutionContext
import org.grails.config.CodeGenConfig
import org.grails.plugins.databasemigration.EnvironmentAwareCodeGenConfig
import org.grails.plugins.databasemigration.liquibase.GroovyChangeLogParser

import static org.grails.plugins.databasemigration.PluginConstants.DEFAULT_DATASOURCE_NAME

@CompileStatic
trait ScriptDatabaseMigrationCommand implements DatabaseMigrationCommand {

ConfigMap config
ConfigMap sourceConfig
ExecutionContext executionContext

void handle(ExecutionContext executionContext) {
this.executionContext = executionContext
setConfig(executionContext.config)

this.commandLine = executionContext.commandLine
this.contexts = optionValue('contexts')
this.defaultSchema = optionValue('defaultSchema')
this.dataSource = optionValue('dataSource') ?: DEFAULT_DATASOURCE_NAME

configureLiquibase()
handle()
}

void configureLiquibase() {
GroovyChangeLogParser groovyChangeLogParser = ChangeLogParserFactory.instance.parsers.find { ChangeLogParser changeLogParser -> changeLogParser instanceof GroovyChangeLogParser } as GroovyChangeLogParser
groovyChangeLogParser.config = config
}

abstract void handle()

Expand Down
17 changes: 0 additions & 17 deletions src/main/scripts/dbm-changelog-to-groovy.groovy

This file was deleted.

16 changes: 0 additions & 16 deletions src/main/scripts/dbm-create-changelog.groovy

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015 original authors
* Copyright 2015-2024 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,10 +15,6 @@
*/
package org.grails.plugins.databasemigration.command

import grails.util.GrailsNameUtils
import org.grails.build.parsing.CommandLineParser
import org.grails.cli.GrailsCli
import org.grails.cli.profile.ExecutionContext
import org.grails.config.CodeGenConfig
import org.h2.Driver

Expand Down Expand Up @@ -48,9 +44,4 @@ abstract class ScriptDatabaseMigrationCommandSpec extends DatabaseMigrationComma

abstract protected Class<ScriptDatabaseMigrationCommand> getCommandClass()

protected ExecutionContext getExecutionContext(String... args) {
def executionContext = new GrailsCli.ExecutionContextImpl(config)
executionContext.commandLine = new CommandLineParser().parse(([GrailsNameUtils.getScriptName(GrailsNameUtils.getLogicalName(commandClass.name, 'Command'))] + args.toList()) as String[])
executionContext
}
}

0 comments on commit daa3392

Please sign in to comment.