Issue with code being overwritten while packaging a plugin

Viewed 111

I followed the guide from https://answer.apache.org/blog/how-to-package-and-deploy-answer-plugins/.
The original answer binary runs correctly as expected, but after rebuilding with the plugins, some of the modified code appears to have been overwritten or replaced unexpectedly.

1. make clean  
2. make ui  
3. make build  (everything works as expected)  

4. ./answer build \
   --with github.com/apache/answer-plugins/search-meilisearch  
   → After this step, the local code changes are missing or not reflected.

Added placeholder for content editor
image.png
After build plugins
image.png

You can start the binary file you built in locally and check whether the changes have been built in.

Thank you — I’ve confirmed that my changes were correctly included in the first build without plugins.
But when rebuilding with the plugins, the modified code appears to have been unexpectedly overridden or ignored.
It’s unclear why this is happening.

1 Answers

It looks like you are trying to package the plugin in a binary way. So there are two methods you can try to see.
Method 1, try specifying the working directory by setting ANSWER_MODULE.

ANSWER_MODULE=/your-local-answer-source-code-path/answer ./answer build --with .....

Method 2: Specify the plugin you want directly in main.go, and then make build directly to get the binary with the plugin. You don't need to answer build once more.

import (
	answercmd "github.com/apache/answer/cmd"
	_ "github.com/apache/answer-plugins/search-meilisearch"
)

The second method solved my problem. Thanks again for the clear explanation and support!