Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

running go mod tidy under mvngolang-wrapper not update go.mod and go.sum file #102

Open
dantran opened this issue Aug 2, 2024 · 1 comment

Comments

@dantran
Copy link

dantran commented Aug 2, 2024

I have the following maven profile

<profile>
  <id>go-mod-tidy</id>
  <build>
    <defaultGoal>initialize</defaultGoal>
    <plugins>
      <plugin>
        <groupId>com.igormaznitsa</groupId>
        <artifactId>mvn-golang-wrapper</artifactId>
        <executions>
          <execution>
            <id>go-mod</id>
            <phase>initialize</phase>
            <goals>
              <goal>mod</goal>
            </goals>
            <configuration>
              <command>tidy</command>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>

Then I run mvn -Pgo-mod-tidy at any maven golang module, somehow the log show some type of dependency resolution, but go.mod does not get updated

[INFO] --- mvn-golang-wrapper:2.3.10:mod (go-mod) @ deploypatch ---
[INFO] Scanning maven dependencies
[INFO] mvn-golang dependency: com.xxxx.dpsg.search.client:search-client-common:mvn-golang:19.18.0-1-SNAPSHOT:compile
[INFO] Module mode is activated
[INFO] Dependencies are not added into GOPATH because module mode is on
[INFO] Executable file detected : /home/trand8/.mvnGoLang/go1.22.5.linux-amd64/bin/go
[INFO] Prepared command line : bin/go mod tidy
[INFO] Detected module folder '/home/trand8/dev/sources/search-client/golang/deploy-patch/src' in use as working folder
[INFO] Working directory: /home/trand8/dev/sources/search-client/golang/deploy-patch/src
[INFO]
[INFO] ....Environment vars....
[INFO]  $GOROOT = /home/trand8/.mvnGoLang/go1.22.5.linux-amd64
[INFO]  $GOPATH = /home/trand8/dev/sources/search-client/golang/deploy-patch/.external-resources/goPath:/home/trand8/dev/sources/search-client/golang/deploy-patch
[INFO]  $GOBIN = /home/trand8/dev/sources/search-client/golang/deploy-patch/target
[INFO]  $GOCACHE = /home/trand8/dev/sources/search-client/golang/deploy-patch/.external-resources/goCache
[INFO]  $PATH = /home/trand8/.mvnGoLang/go1.22.5.linux-amd64/bin:/home/trand8/.mvnGoLang/go1.22.5.linux-amd64/bin:/home/trand8/.mvnGoLang/go1.22.5.linux-amd64/bin:/home/trand8/dev/tools/bin:/home/trand8/dev/tools/mvnd/maven-mvnd/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program:/home/trand8/dev/sources/search-client/golang/deploy-patch/target:/home/trand8/dev/sources/search-client/golang/deploy-patch/target
[INFO]  $GOMODCACHE = /home/trand8/dev/sources/search-client/golang/deploy-patch/.external-resources/goModCache
[INFO]  $GOPROXY = https://dps.artifactory.cec.lab.xxxx.com/artifactory/dps-go-public
[INFO]  $GOSUMDB = sum.golang.org ap.drm.ops.lab.xxxxx.com/artifactory/golang-sum
[WARNING] Forcing 'GO111MODULE = on' because module mode is activated
[INFO]  $GO111MODULE = on
[INFO] ........................
[WARNING]
[WARNING] ---------Exec.Err---------
[WARNING] go: finding module for package github.com/stretchr/testify/assert
[WARNING] go: finding module for package github.com/pkg/sftp
[WARNING] go: finding module for package golang.org/x/crypto/ssh
[WARNING] go: found github.com/pkg/sftp in github.com/pkg/sftp v1.13.6
[WARNING] go: found golang.org/x/crypto/ssh in golang.org/x/crypto v0.23.0
[WARNING] go: found github.com/stretchr/testify/assert in github.com/stretchr/testify v1.9.0
[WARNING]

however, If I run 'go mod tidy' command directly, with proper env setup. it works. go.mod updated

I intend to run mvn -Pgo-mod on maven multi-modules build, so that it can auto-update my go.mod and go.sum

@dantran
Copy link
Author

dantran commented Aug 2, 2024

I found a solution via debug log and read up the source , and have this property in my pom.xml

  <properties>
    <mvn.golang.restore.go.mod>false</mvn.golang.restore.go.mod>
  </properties>  

However, doing so, it leaves .#go.mod.mvn.orig file at the source. Can this plugin remove this file?

@dantran dantran closed this as completed Aug 2, 2024
@dantran dantran reopened this Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant