Skip to content

Commit

Permalink
Merged fix for GRAILS-6381 "Remove redundant artifact suffixes when u…
Browse files Browse the repository at this point in the history
…sing the scripts "grails create-xxxxx""
  • Loading branch information
graemerocher committed Jul 28, 2010
1 parent 09bd010 commit 0cf1a03
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion scripts/CreateController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ target ('default': "Creates a new controller") {
promptForName(type: type)

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

def viewsDir = "${basedir}/grails-app/views/${propertyName}"
ant.mkdir(dir:viewsDir)
Expand Down
1 change: 1 addition & 0 deletions scripts/CreateFilters.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ target ('default': "Creates a new filters class") {
promptForName(type: type)

def name = argsMap["params"][0]
name = purgeRedundantArtifactSuffix(name, type)
createArtifact(name: name, suffix: type, type: type, path: "grails-app/conf")
createUnitTest(name: name, suffix: type)
}
1 change: 1 addition & 0 deletions scripts/CreateIntegrationTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ target ('default': "Creates a new Grails integration test which loads the whole
promptForName(type: "Integration test")

def name = argsMap["params"][0]
name = purgeRedundantArtifactSuffix(name, type)
createIntegrationTest(name: name, suffix: "")
}
5 changes: 3 additions & 2 deletions scripts/CreateService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ target ('default': "Creates a new service class") {
promptForName(type: type)

def name = argsMap["params"][0]
createArtifact(name: name, suffix: type, type: type, path: "grails-app/services")
createUnitTest(name: name, suffix: type)
name = purgeRedundantArtifactSuffix(name, type)
createArtifact(name: name, suffix: type, type: type, path: "grails-app/services")
createUnitTest(name: name, suffix: type)
}
5 changes: 3 additions & 2 deletions scripts/CreateTagLib.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ target ('default': "Creates a new tag library") {
promptForName(type: type)

def name = argsMap["params"][0]
createArtifact(name: name, suffix: type, type: type, path: "grails-app/taglib")
createUnitTest(name: name, suffix: type, superClass: "TagLibUnitTestCase")
name = purgeRedundantArtifactSuffix(name, type)
createArtifact(name: name, suffix: type, type: type, path: "grails-app/taglib")
createUnitTest(name: name, suffix: type, superClass: "TagLibUnitTestCase")
}
1 change: 1 addition & 0 deletions scripts/CreateUnitTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ target ('default': "Creates a new Grails unit test. A unit test requires that yo
promptForName(type: "Unit test")

def name = argsMap["params"][0]
name = purgeRedundantArtifactSuffix(name, type)
createUnitTest(name: name, suffix: "")
}
9 changes: 9 additions & 0 deletions scripts/_GrailsCreateArtifacts.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,12 @@ promptForName = { Map args = [:] ->
argsMap["params"] << ant.antProject.properties."artifact.name"
}
}

purgeRedundantArtifactSuffix = { name, suffix ->
if (name && suffix) {
if (name =~ /.+$suffix$/) {
name = name.replaceAll(/$suffix$/, "")
}
}
name
}

0 comments on commit 0cf1a03

Please sign in to comment.