Hi @Willem,
Great question! I've recently optimized the official scaffolding tool to make creating Answer plugins much easier. Let me show you how to create a minimal Route plugin with the improved tool.
The optimized scaffolding tool now handles everything automatically, making plugin creation much simpler:
# Install the tool (package name is create-answer-plugin)
npm install -g create-answer-plugin@beta
# or use npx (recommended)
npx create-answer-plugin@beta create hello-routeNote: The package name is create-answer-plugin, but you can use either create-answer-plugin or answer-plugin as the command (both work!).
The tool automatically:
- β Generates all required files with correct structure
- β Creates the Go wrapper file (required for registration)
- β
Sets up proper
go.modwith all dependencies - β Generates i18n files with correct structure
- β Installs the plugin to your Answer project
- β Handles all the boilerplate code
This makes creating plugins much faster and eliminates common setup errors!
Using the scaffolding tool is the recommended and easiest way:
# 1. Create the plugin (both commands work)
npx create-answer-plugin@beta create hello-route
# or: npx answer-plugin@beta create hello-route
# Select: Standard UI Plugin β Route
# Enter route path: /hello
# 2. Navigate to your Answer project
cd /path/to/answer
# 3. Install the plugin (automatically handles registration)
npx create-answer-plugin@beta install hello-route
# or: npx answer-plugin@beta install hello-route
# The install command automatically:
# - Adds plugin import to main.go
# - Adds replace directive to go.mod
# - Runs go mod tidy
# - Merges i18n resources
# 4. Install frontend dependencies and build
cd /path/to/answer/ui
pnpm pre-install
pnpm build
# 5. Build and run Answer
cd /path/to/answer
go run ./cmd/answer/main.go run -C ./answer-dataThe plugin will be available at http://localhost:80/hello (or your configured port).
-
Plugin not showing up:
- Ensure it's in
ui/src/plugins/(plural) - Check that the Go wrapper file exists
- Verify the plugin is imported in
main.go
- Ensure it's in
-
Route not accessible:
- Verify
routefield ininfo.yamlstarts with/ - Check i18n resources are merged:
go run ./cmd/answer/main.go i18n
- Verify
-
Build errors:
- Ensure
go.modhas correct dependencies - Run
go mod tidyafter adding the plugin
- Ensure
- Scaffolding Tool: https://www.npmjs.com/package/create-answer-plugin (use
@betafor v2.0.0-beta.2 with all new features) - GitHub: https://github.com/answerdev/create-answer-plugin
- Documentation: https://answer.apache.org/docs/development/plugins
- Example Plugins: https://github.com/apache/answer-plugins
The optimized scaffolding tool (create-answer-plugin or answer-plugin) handles all the complex setup automatically, including:
- Correct file structure and paths
- Go wrapper generation
- Plugin registration
- Dependency management
- i18n configuration
This makes creating Answer plugins much easier and faster. I'd strongly recommend using it - it will save you a lot of time!
Let me know if you need any clarification or run into issues! π