Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 56c646a

Browse files
authored
Merge pull request #993 from grails/use-GrailsStringUtils-trimToNull
use GrailsStringUtils.trimToNull() instead of apache commons version
2 parents 5901ff4 + 8f7cdb7 commit 56c646a

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

grails-database-migration/build.gradle

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,21 @@ dependencies {
2929
exclude group: 'com.h2database', module: 'h2'
3030
exclude group: 'org.liquibase', module: 'liquibase-commercial'
3131
}
32-
api 'org.apache.commons:commons-lang3'
32+
3333
api('org.grails:grails-shell') {
3434
exclude group: 'org.slf4j', module: 'slf4j-simple'
3535
}
3636

3737
compileOnly "org.springframework.boot:spring-boot-starter-logging"
3838
compileOnly "org.springframework.boot:spring-boot-autoconfigure"
3939
compileOnly "org.grails.plugins:hibernate5"
40+
compileOnly "org.grails:grails-core"
4041
compileOnly "org.apache.groovy:groovy-sql"
4142
compileOnly "org.apache.groovy:groovy-xml"
4243

4344
testImplementation "org.springframework.boot:spring-boot-starter-tomcat"
4445
testImplementation "org.grails.plugins:hibernate5"
46+
testImplementation "org.grails:grails-core"
4547
testImplementation "org.grails:grails-gorm-testing-support"
4648
testImplementation "org.grails:grails-web-testing-support"
4749
testImplementation "com.h2database:h2"

grails-database-migration/src/main/groovy/org/grails/plugins/databasemigration/liquibase/GroovyDiffToChangeLogCommandStep.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import liquibase.database.ObjectQuotingStrategy
2828
import liquibase.diff.DiffResult
2929
import liquibase.diff.output.DiffOutputControl
3030
import liquibase.serializer.ChangeLogSerializerFactory
31-
import org.apache.commons.lang3.StringUtils
31+
import grails.util.GrailsStringUtils
3232

3333
@CompileStatic
3434
class GroovyDiffToChangeLogCommandStep extends DiffChangelogCommandStep {
@@ -55,7 +55,7 @@ class GroovyDiffToChangeLogCommandStep extends DiffChangelogCommandStep {
5555

5656
try {
5757
referenceDatabase.setObjectQuotingStrategy(ObjectQuotingStrategy.QUOTE_ALL_OBJECTS);
58-
if (StringUtils.trimToNull(changeLogFile) == null) {
58+
if (GrailsStringUtils.trimToNull(changeLogFile) == null) {
5959
createDiffToChangeLogObject(diffResult, diffOutputControl, false).print(outputStream, ChangeLogSerializerFactory.instance.getSerializer('groovy'))
6060
} else {
6161
createDiffToChangeLogObject(diffResult, diffOutputControl, false).print(changeLogFile, ChangeLogSerializerFactory.instance.getSerializer(changeLogFile))

grails-database-migration/src/main/groovy/org/grails/plugins/databasemigration/liquibase/GroovyGenerateChangeLogCommandStep.groovy

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import liquibase.diff.DiffResult
3030
import liquibase.diff.output.DiffOutputControl
3131
import liquibase.diff.output.changelog.DiffToChangeLog
3232
import liquibase.serializer.ChangeLogSerializerFactory
33-
import org.apache.commons.lang3.StringUtils
33+
import grails.util.GrailsStringUtils
3434

3535
@CompileStatic
3636
class GroovyGenerateChangeLogCommandStep extends GenerateChangelogCommandStep {
@@ -46,7 +46,7 @@ class GroovyGenerateChangeLogCommandStep extends GenerateChangelogCommandStep {
4646
void run(CommandResultsBuilder resultsBuilder) throws Exception {
4747
CommandScope commandScope = resultsBuilder.getCommandScope();
4848

49-
String changeLogFile = StringUtils.trimToNull(commandScope.getArgumentValue(CHANGELOG_FILE_ARG));
49+
String changeLogFile = GrailsStringUtils.trimToNull(commandScope.getArgumentValue(CHANGELOG_FILE_ARG));
5050
if (changeLogFile != null && changeLogFile.toLowerCase().endsWith(".sql")) {
5151
Scope.getCurrentScope().getUI().sendMessage("\n" + INFO_MESSAGE + "\n");
5252
Scope.getCurrentScope().getLog(getClass()).info("\n" + INFO_MESSAGE + "\n");
@@ -71,7 +71,7 @@ class GroovyGenerateChangeLogCommandStep extends GenerateChangelogCommandStep {
7171
ObjectQuotingStrategy originalStrategy = referenceDatabase.getObjectQuotingStrategy();
7272
try {
7373
referenceDatabase.setObjectQuotingStrategy(ObjectQuotingStrategy.QUOTE_ALL_OBJECTS);
74-
if (StringUtils.trimToNull(changeLogFile) != null) {
74+
if (GrailsStringUtils.trimToNull(changeLogFile) != null) {
7575
changeLogWriter.print(changeLogFile, ChangeLogSerializerFactory.instance.getSerializer(changeLogFile))
7676
} else {
7777
PrintStream outputStream = new PrintStream(resultsBuilder.getOutputStream());
@@ -82,7 +82,7 @@ class GroovyGenerateChangeLogCommandStep extends GenerateChangelogCommandStep {
8282
}
8383

8484
}
85-
if (StringUtils.trimToNull(changeLogFile) != null) {
85+
if (GrailsStringUtils.trimToNull(changeLogFile) != null) {
8686
Scope.getCurrentScope().getUI().sendMessage("Generated changelog written to " + new File(changeLogFile).getAbsolutePath());
8787
}
8888
} finally {

0 commit comments

Comments
 (0)