This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch fix/1.3.6/build
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git

commit 7ad8a83f8c05e95bf9bb505293970037033ba999
Author: LinkinStars <[email protected]>
AuthorDate: Mon Jun 24 17:38:54 2024 +0800

    fix(build): get specific version of plugins
---
 internal/cli/build.go | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/internal/cli/build.go b/internal/cli/build.go
index 244249a5..2e59ca58 100644
--- a/internal/cli/build.go
+++ b/internal/cli/build.go
@@ -183,11 +183,14 @@ func createMainGoFile(b *buildingMaterial) (err error) {
        }
 
        for _, p := range b.plugins {
-               if len(p.Path) == 0 {
-                       continue
+               // If user set a path, use it to replace the module with local 
path
+               if len(p.Path) > 0 {
+                       replacement := fmt.Sprintf("%s@%s=%s", p.Name, 
p.Version, p.Path)
+                       err = b.newExecCmd("go", "mod", "edit", "-replace", 
replacement).Run()
+               } else if len(p.Version) > 0 {
+                       // If user specify a version, use it to get specific 
version of the module
+                       err = b.newExecCmd("go", "get", fmt.Sprintf("%s@%s", 
p.Name, p.Version)).Run()
                }
-               replacement := fmt.Sprintf("%s@v%s=%s", p.Name, p.Version, 
p.Path)
-               err = b.newExecCmd("go", "mod", "edit", "-replace", 
replacement).Run()
                if err != nil {
                        return err
                }

Reply via email to