Skip to content

Conversation

@codeconsole
Copy link
Contributor

@codeconsole codeconsole commented Nov 20, 2025

Commands

grails create-domain-class testapp.Book
grails create-domain-class testapp.Car

./gradlew runCommand "-Pargs=create-scaffold-controller testapp.Book"
./gradlew runCommand "-Pargs=create-scaffold-controller testapp.Book --namespace=admin"
./gradlew runCommand "-Pargs=create-scaffold-service testapp.Book"
./gradlew runCommand "-Pargs=generate-scaffold-all testapp.Car"
./gradlew runCommand "-Pargs=create-scaffold-controller testapp.Car --service --namespace=admin"

# With custom superclass
./gradlew runCommand "-Pargs=create-scaffold-service testapp.Book --extends=com.example.MyCustomService"
./gradlew runCommand "-Pargs=create-scaffold-controller testapp.Book --extends=com.example.MyCustomController"
./gradlew runCommand "-Pargs=generate-scaffold-all testapp.Car --serviceExtends=com.example.MyService
--controllerExtends=com.example.MyController"

Generated Files

Domain Classes

testapp/Book.groovy

package testapp

class Book {

    static constraints = {
    }
}

testapp/Car.groovy

package testapp

class Car {

    static constraints = {
    }
}

Controllers

testapp/BookController.groovy (basic)

package testapp

import grails.plugin.scaffolding.annotation.Scaffold

@Scaffold(Book)
class BookController {
}

testapp/admin/BookController.groovy (with namespace)

package testapp.admin

import testapp.Book

import grails.plugin.scaffolding.annotation.Scaffold

@Scaffold(Book)
class BookController {
    static namespace = 'admin'
}

testapp/CarController.groovy (from generate-scaffold-all)

package testapp

import grails.plugin.scaffolding.annotation.Scaffold
import grails.plugin.scaffolding.RestfulServiceController

@Scaffold(RestfulServiceController<Car>)
class CarController {
}

testapp/admin/CarController.groovy (with --service and --namespace)

package testapp.admin

import testapp.Car

import grails.plugin.scaffolding.annotation.Scaffold
import grails.plugin.scaffolding.RestfulServiceController

@Scaffold(RestfulServiceController<Car>)
class CarController {
    static namespace = 'admin'
}

Services

testapp/BookService.groovy

package testapp

import grails.plugin.scaffolding.annotation.Scaffold

@Scaffold(Book)
class BookService {
}

testapp/CarService.groovy (from generate-scaffold-all)

package testapp

import grails.plugin.scaffolding.annotation.Scaffold

@Scaffold(Car)
class CarService {
}

With --extends Flag

testapp/BookService.groovy (custom superclass)

package testapp

import grails.plugin.scaffolding.annotation.Scaffold
import com.example.MyCustomService

@Scaffold(MyCustomService<Book>)
class BookService {
}

testapp/BookController.groovy (custom superclass)

package testapp

import grails.plugin.scaffolding.annotation.Scaffold
import com.example.MyCustomController

@Scaffold(MyCustomController<Book>)
class BookController {
}

Command Options

Command Flag Description
create-scaffold-controller --force Overwrite existing files
--namespace Set the controller namespace
--service Use grails.plugin.scaffolding.RestfulServiceController instead of
grails.rest.RestfulController
--extends Specify a custom superclass (default: grails.rest.RestfulController)
create-scaffold-service --force Overwrite existing files
--extends Specify a custom superclass (default: grails.plugin.scaffolding.GormService)
generate-scaffold-all --force Overwrite existing files
--namespace Set the controller namespace
--serviceExtends Specify a custom superclass for the service (default:
grails.plugin.scaffolding.GormService)
--controllerExtends Specify a custom superclass for the controller (default:
grails.plugin.scaffolding.RestfulServiceController)

@codeconsole codeconsole marked this pull request as draft November 20, 2025 18:22
@codeconsole codeconsole marked this pull request as ready for review November 25, 2025 02:28
Copy link
Contributor

@jdaugherty jdaugherty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concern is there's no documentation for all of this and there's a whole section of the guide related to scaffolding.

@codeconsole codeconsole changed the title 7.1.x scaffold service controller 7.1.x @Scaffold Services and Controllers Nov 29, 2025
@codeconsole codeconsole force-pushed the 7.1.x-scaffold-service-controller branch from 3fbe3e2 to bb6540a Compare November 29, 2025 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants