diff --git a/build.gradle b/build.gradle index 568d0343..ab0f5d0f 100644 --- a/build.gradle +++ b/build.gradle @@ -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' diff --git a/src/main/groovy/org/grails/plugins/databasemigration/command/ScriptDatabaseMigrationCommand.groovy b/src/main/groovy/org/grails/plugins/databasemigration/command/ScriptDatabaseMigrationCommand.groovy index 61e90f90..54d9c83d 100644 --- a/src/main/groovy/org/grails/plugins/databasemigration/command/ScriptDatabaseMigrationCommand.groovy +++ b/src/main/groovy/org/grails/plugins/databasemigration/command/ScriptDatabaseMigrationCommand.groovy @@ -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. @@ -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() diff --git a/src/main/scripts/dbm-changelog-to-groovy.groovy b/src/main/scripts/dbm-changelog-to-groovy.groovy deleted file mode 100644 index 101c8e48..00000000 --- a/src/main/scripts/dbm-changelog-to-groovy.groovy +++ /dev/null @@ -1,17 +0,0 @@ -import org.grails.plugins.databasemigration.DatabaseMigrationException -import org.grails.plugins.databasemigration.command.DbmChangelogToGroovy - -description('Converts a changelog file to a Groovy DSL file') { - usage 'grails [environment] dbm-changelog-to-groovy [src_file_name] [dest_file_name]' - flag name: 'src_file_name', description: 'The name and path of the changelog file to convert' - flag name: 'dest_file_name', description: 'The name and path of the Groovy file' - flag name: 'dataSource', description: 'if provided will run the script for the specified dataSource creating a file named changelog-dataSource.groovy if a filename is not given. Not needed for the default dataSource' - flag name: 'force', description: 'Whether to overwrite existing files' - flag name: 'add', description: 'if provided will run the script for the specified dataSource. Not needed for the default dataSource.' -} - -try { - new DbmChangelogToGroovy().handle(executionContext) -} catch (DatabaseMigrationException e) { - error e.message, e -} diff --git a/src/main/scripts/dbm-create-changelog.groovy b/src/main/scripts/dbm-create-changelog.groovy deleted file mode 100644 index 252a5b7a..00000000 --- a/src/main/scripts/dbm-create-changelog.groovy +++ /dev/null @@ -1,16 +0,0 @@ -import org.grails.plugins.databasemigration.DatabaseMigrationException -import org.grails.plugins.databasemigration.command.DbmCreateChangelog - -description('Creates an empty changelog file') { - usage 'grails [environment] dbm-create-changelog [filename]' - flag name: 'filename', description: 'The path to the output file to write to' - flag name: 'dataSource', description: 'if provided will run the script for the specified dataSource creating a file named changelog-dataSource.groovy if a filename is not given. Not needed for the default dataSource' - flag name: 'force', description: 'Whether to overwrite existing files' - flag name: 'add', description: 'if provided will run the script for the specified dataSource. Not needed for the default dataSource.' -} - -try { - new DbmCreateChangelog().handle(executionContext) -} catch (DatabaseMigrationException e) { - error e.message, e -} diff --git a/src/test/groovy/org/grails/plugins/databasemigration/command/ScriptDatabaseMigrationCommandSpec.groovy b/src/test/groovy/org/grails/plugins/databasemigration/command/ScriptDatabaseMigrationCommandSpec.groovy index 398dc1af..0874fb94 100644 --- a/src/test/groovy/org/grails/plugins/databasemigration/command/ScriptDatabaseMigrationCommandSpec.groovy +++ b/src/test/groovy/org/grails/plugins/databasemigration/command/ScriptDatabaseMigrationCommandSpec.groovy @@ -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. @@ -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 @@ -48,9 +44,4 @@ abstract class ScriptDatabaseMigrationCommandSpec extends DatabaseMigrationComma abstract protected Class 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 - } }