Skip to content

Commit 0cf1a03

Browse files
committed
Merged fix for GRAILS-6381 "Remove redundant artifact suffixes when using the scripts "grails create-xxxxx""
1 parent 09bd010 commit 0cf1a03

File tree

7 files changed

+20
-5
lines changed

7 files changed

+20
-5
lines changed

scripts/CreateController.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ target ('default': "Creates a new controller") {
3232
promptForName(type: type)
3333

3434
def name = argsMap["params"][0]
35-
createArtifact(name: name, suffix: type, type: type, path: "grails-app/controllers")
35+
name = purgeRedundantArtifactSuffix(name, type)
36+
createArtifact(name: name, suffix: type, type: type, path: "grails-app/controllers")
3637

3738
def viewsDir = "${basedir}/grails-app/views/${propertyName}"
3839
ant.mkdir(dir:viewsDir)

scripts/CreateFilters.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ target ('default': "Creates a new filters class") {
3434
promptForName(type: type)
3535

3636
def name = argsMap["params"][0]
37+
name = purgeRedundantArtifactSuffix(name, type)
3738
createArtifact(name: name, suffix: type, type: type, path: "grails-app/conf")
3839
createUnitTest(name: name, suffix: type)
3940
}

scripts/CreateIntegrationTest.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ target ('default': "Creates a new Grails integration test which loads the whole
3131
promptForName(type: "Integration test")
3232

3333
def name = argsMap["params"][0]
34+
name = purgeRedundantArtifactSuffix(name, type)
3435
createIntegrationTest(name: name, suffix: "")
3536
}

scripts/CreateService.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ target ('default': "Creates a new service class") {
3434
promptForName(type: type)
3535

3636
def name = argsMap["params"][0]
37-
createArtifact(name: name, suffix: type, type: type, path: "grails-app/services")
38-
createUnitTest(name: name, suffix: type)
37+
name = purgeRedundantArtifactSuffix(name, type)
38+
createArtifact(name: name, suffix: type, type: type, path: "grails-app/services")
39+
createUnitTest(name: name, suffix: type)
3940
}

scripts/CreateTagLib.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ target ('default': "Creates a new tag library") {
3232
promptForName(type: type)
3333

3434
def name = argsMap["params"][0]
35-
createArtifact(name: name, suffix: type, type: type, path: "grails-app/taglib")
36-
createUnitTest(name: name, suffix: type, superClass: "TagLibUnitTestCase")
35+
name = purgeRedundantArtifactSuffix(name, type)
36+
createArtifact(name: name, suffix: type, type: type, path: "grails-app/taglib")
37+
createUnitTest(name: name, suffix: type, superClass: "TagLibUnitTestCase")
3738
}

scripts/CreateUnitTest.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ target ('default': "Creates a new Grails unit test. A unit test requires that yo
3131
promptForName(type: "Unit test")
3232

3333
def name = argsMap["params"][0]
34+
name = purgeRedundantArtifactSuffix(name, type)
3435
createUnitTest(name: name, suffix: "")
3536
}

scripts/_GrailsCreateArtifacts.groovy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,12 @@ promptForName = { Map args = [:] ->
123123
argsMap["params"] << ant.antProject.properties."artifact.name"
124124
}
125125
}
126+
127+
purgeRedundantArtifactSuffix = { name, suffix ->
128+
if (name && suffix) {
129+
if (name =~ /.+$suffix$/) {
130+
name = name.replaceAll(/$suffix$/, "")
131+
}
132+
}
133+
name
134+
}

0 commit comments

Comments
 (0)