Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix for GRAILS-5713 "Package by convention for new artefacts"
  • Loading branch information
graemerocher committed Mar 23, 2010
1 parent 390419b commit d9f2b98
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
33 changes: 19 additions & 14 deletions scripts/_GrailsCreateArtifacts.groovy
Expand Up @@ -23,6 +23,8 @@ import grails.util.GrailsNameUtils
* @author Peter Ledbrook
*/

includeTargets << grailsScript("_GrailsPackage")

createArtifact = { Map args = [:] ->
def suffix = args["suffix"]
def type = args["type"]
Expand All @@ -37,25 +39,23 @@ createArtifact = { Map args = [:] ->
if (pos != -1) {
pkg = name[0..<pos]
name = name[(pos + 1)..-1]
if(pkg.startsWith("~")) {
pkg = pkg.replace("~", createRootPackage())
}
}
else {
pkg = createRootPackage()
}

// Convert the package into a file path.
def pkgPath = ''
if (pkg) {
pkgPath = pkg.replace('.' as char, '/' as char)
def pkgPath = pkg.replace('.' as char, '/' as char)

// Make sure that the package path exists! Otherwise we won't
// be able to create a file there.
ant.mkdir(dir: "${basedir}/${artifactPath}/${pkgPath}")
// Make sure that the package path exists! Otherwise we won't
// be able to create a file there.
ant.mkdir(dir: "${basedir}/${artifactPath}/${pkgPath}")

// Future use of 'pkgPath' requires a trailing slash.
pkgPath += '/'
}
else if(!args.skipPackagePrompt && isInteractive) {
if(!confirmInput("WARNING: You have not specified a package. It is good practise to place classes in packages (eg. mycompany.Book). Do you want to continue?", "no.package.warning")) {
exit(1)
}
}
// Future use of 'pkgPath' requires a trailing slash.
pkgPath += '/'

// Convert the given name into class name and property name
// representations.
Expand Down Expand Up @@ -102,6 +102,11 @@ createArtifact = { Map args = [:] ->
event("CreatedArtefact", [ type, className])
}

private createRootPackage() {
compile()
createConfig()
return (config.grails.project.groupId ?: grailsAppName).replace('-','.').toLowerCase()
}
createIntegrationTest = { Map args = [:] ->
def superClass = args["superClass"] ?: "GrailsUnitTestCase"
createArtifact(name: args["name"], suffix: "${args['suffix']}Tests", type: "Tests", path: "test/integration", superClass: superClass)
Expand Down
4 changes: 4 additions & 0 deletions scripts/_GrailsPackage.groovy
Expand Up @@ -32,6 +32,10 @@ import groovyx.gpars.Asynchronizer
* @since 0.4
*/

if (getBinding().variables.containsKey("_grails_package_called")) return
_grails_package_called = true


includeTargets << grailsScript("_GrailsCompile")
includeTargets << grailsScript("_PackagePlugins")

Expand Down
3 changes: 3 additions & 0 deletions scripts/_PluginDependencies.groovy
Expand Up @@ -42,6 +42,9 @@ import org.codehaus.groovy.grails.plugins.GrailsPluginManager
*
* @since 1.1
*/
if (getBinding().variables.containsKey("_plugin_dependencies_called")) return
_plugin_dependencies_called = true


includeTargets << grailsScript("_GrailsClean")
includeTargets << grailsScript("_GrailsArgParsing")
Expand Down
2 changes: 2 additions & 0 deletions src/grails/grails-app/conf/Config.groovy
Expand Up @@ -9,6 +9,8 @@
// if(System.properties["${appName}.config.location"]) {
// grails.config.locations << "file:" + System.properties["${appName}.config.location"]
// }

grails.project.groupId = appName // change this to alter the default package name and Maven publishing destination
grails.mime.file.extensions = true // enables the parsing of file extensions from URLs into the request format
grails.mime.use.accept.header = false
grails.mime.types = [ html: ['text/html','application/xhtml+xml'],
Expand Down

0 comments on commit d9f2b98

Please sign in to comment.