diff --git a/common/build/buildinfoproperties.go b/common/build/buildinfoproperties.go index afe7409a4..ea2a6aa1d 100644 --- a/common/build/buildinfoproperties.go +++ b/common/build/buildinfoproperties.go @@ -45,6 +45,9 @@ const Repo = "repo" const SnapshotRepo = "snapshotRepo" const ReleaseRepo = "releaseRepo" +const DisableSnapshots = "disableSnapshots" +const SnapshotsUpdatePolicy = "snapshotsUpdatePolicy" + const ServerId = "serverId" const Url = "url" const Username = "username" @@ -123,6 +126,8 @@ var mavenConfigMapping = map[string]string{ "buildInfoConfig.artifactoryResolutionEnabled": "buildInfoConfig.artifactoryResolutionEnabled", "resolve.repoKey": ResolverPrefix + ReleaseRepo, "resolve.downSnapshotRepoKey": ResolverPrefix + SnapshotRepo, + "resolve.snapshots.disabled": ResolverPrefix + DisableSnapshots, + "resolve.snapshots.updatePolicy": ResolverPrefix + SnapshotsUpdatePolicy, "publish.repoKey": DeployerPrefix + ReleaseRepo, "publish.snapshot.repoKey": DeployerPrefix + SnapshotRepo, "publish.includePatterns": DeployerPrefix + IncludePatterns, diff --git a/common/commands/configfile.go b/common/commands/configfile.go index d71455ead..637638bd3 100644 --- a/common/commands/configfile.go +++ b/common/commands/configfile.go @@ -39,6 +39,8 @@ const ( deploymentSnapshotsRepo = "repo-deploy-snapshots" includePatterns = "include-patterns" excludePatterns = "exclude-patterns" + disableSnapshots = "disable-snapshots" + snapshotsUpdatePolicy = "snapshots-update-policy" // Gradle flags usesPlugin = "uses-plugin" @@ -251,6 +253,8 @@ func WithDeployerRepo(repoId string) ConfigOption { // Populate Maven related configuration from cli flags func (configFile *ConfigFile) populateMavenConfigFromFlags(c *cli.Context) { configFile.Resolver.SnapshotRepo = c.String(resolutionSnapshotsRepo) + configFile.Resolver.DisableSnapshots = c.Bool(disableSnapshots) + configFile.Resolver.SnapshotsUpdatePolicy = c.String(snapshotsUpdatePolicy) configFile.Resolver.ReleaseRepo = c.String(resolutionReleasesRepo) configFile.Deployer.SnapshotRepo = c.String(deploymentSnapshotsRepo) configFile.Deployer.ReleaseRepo = c.String(deploymentReleasesRepo) @@ -258,7 +262,7 @@ func (configFile *ConfigFile) populateMavenConfigFromFlags(c *cli.Context) { configFile.Deployer.ExcludePatterns = c.String(excludePatterns) configFile.UseWrapper = c.Bool(useWrapper) configFile.Interactive = configFile.Interactive && !isAnyFlagSet(c, resolutionSnapshotsRepo, resolutionReleasesRepo, - deploymentSnapshotsRepo, deploymentReleasesRepo, includePatterns, excludePatterns) + disableSnapshots, snapshotsUpdatePolicy, deploymentSnapshotsRepo, deploymentReleasesRepo, includePatterns, excludePatterns) } func WithResolverSnapshotRepo(repoId string) ConfigOption { diff --git a/common/commands/flag_test.go b/common/commands/flag_test.go new file mode 100644 index 000000000..512b907e1 --- /dev/null +++ b/common/commands/flag_test.go @@ -0,0 +1,46 @@ +package commands + +import ( + "github.com/stretchr/testify/assert" + "testing" + + "github.com/urfave/cli" +) + +// This test demonstrates an existing bug in the urfave/cli library. +// It highlights that both BoolT and Bool flags have their default values set to false. +// Ideally, the BoolT flag should have a default value of true. +func TestBoolVsBoolTFlag(t *testing.T) { + tests := []struct { + name string + args []string + shouldUseBoolT bool + expectValue bool + }{ + {"Resolving flag value using Bool (default false)", []string{"cmd"}, false, false}, + {"Resolving flag value using Bool (default false)", []string{"cmd"}, true, false}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + app := &cli.App{ + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "myflag", + Usage: "Test boolean flag", + }, + }, + Action: func(c *cli.Context) error { + if tt.shouldUseBoolT { + assert.Equal(t, tt.expectValue, c.BoolT("myflag"), "Expected %v, got %v", tt.expectValue, c.BoolT("myflag")) + } else { + assert.Equal(t, tt.expectValue, c.Bool("myflag"), "Expected %v, got %v", tt.expectValue, c.Bool("myflag")) + } + return nil + }, + } + + _ = app.Run(tt.args) + }) + } +} diff --git a/common/project/projectconfig.go b/common/project/projectconfig.go index 646f014eb..9efd77da6 100644 --- a/common/project/projectconfig.go +++ b/common/project/projectconfig.go @@ -96,17 +96,19 @@ func (mre *MissingResolverErr) Error() string { } type Repository struct { - Repo string `yaml:"repo,omitempty"` - ServerId string `yaml:"serverId,omitempty"` - SnapshotRepo string `yaml:"snapshotRepo,omitempty"` - ReleaseRepo string `yaml:"releaseRepo,omitempty"` - DeployMavenDesc bool `yaml:"deployMavenDescriptors,omitempty"` - DeployIvyDesc bool `yaml:"deployIvyDescriptors,omitempty"` - IvyPattern string `yaml:"ivyPattern,omitempty"` - ArtifactsPattern string `yaml:"artifactPattern,omitempty"` - NugetV2 bool `yaml:"nugetV2,omitempty"` - IncludePatterns string `yaml:"includePatterns,omitempty"` - ExcludePatterns string `yaml:"excludePatterns,omitempty"` + Repo string `yaml:"repo,omitempty"` + ServerId string `yaml:"serverId,omitempty"` + SnapshotRepo string `yaml:"snapshotRepo,omitempty"` + DisableSnapshots bool `yaml:"disableSnapshots,omitempty"` + SnapshotsUpdatePolicy string `yaml:"snapshotsUpdatePolicy,omitempty"` + ReleaseRepo string `yaml:"releaseRepo,omitempty"` + DeployMavenDesc bool `yaml:"deployMavenDescriptors,omitempty"` + DeployIvyDesc bool `yaml:"deployIvyDescriptors,omitempty"` + IvyPattern string `yaml:"ivyPattern,omitempty"` + ArtifactsPattern string `yaml:"artifactPattern,omitempty"` + NugetV2 bool `yaml:"nugetV2,omitempty"` + IncludePatterns string `yaml:"includePatterns,omitempty"` + ExcludePatterns string `yaml:"excludePatterns,omitempty"` } type RepositoryConfig struct { diff --git a/go.mod b/go.mod index 2c369accc..49a68f806 100644 --- a/go.mod +++ b/go.mod @@ -116,6 +116,6 @@ require ( replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250221062042-87cb5136765e -// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20241121100855-e7a75ceee2bd +replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20250226091544-c803cbbc5495 // replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.3.3-0.20231223133729-ef57bd08cedc diff --git a/go.sum b/go.sum index 7ce4dd48c..fa206749b 100644 --- a/go.sum +++ b/go.sum @@ -108,8 +108,8 @@ github.com/jedib0t/go-pretty/v6 v6.6.5 h1:9PgMJOVBedpgYLI56jQRJYqngxYAAzfEUua+3N github.com/jedib0t/go-pretty/v6 v6.6.5/go.mod h1:Uq/HrbhuFty5WSVNfjpQQe47x16RwVGXIveNGEyGtHs= github.com/jfrog/archiver/v3 v3.6.1 h1:LOxnkw9pOn45DzCbZNFV6K0+6dCsQ0L8mR3ZcujO5eI= github.com/jfrog/archiver/v3 v3.6.1/go.mod h1:VgR+3WZS4N+i9FaDwLZbq+jeU4B4zctXL+gL4EMzfLw= -github.com/jfrog/build-info-go v1.10.9 h1:mdJ+wlLw2ReFsqC7rifJVlRYLEqYk38uXDYAOZASuGE= -github.com/jfrog/build-info-go v1.10.9/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE= +github.com/jfrog/build-info-go v1.8.9-0.20250226091544-c803cbbc5495 h1:5MMGDOs/Jd3CVjKZ9wvjiZ690ok/MxRs+TuPZ3pKLWY= +github.com/jfrog/build-info-go v1.8.9-0.20250226091544-c803cbbc5495/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE= github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s= github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4= github.com/jfrog/jfrog-client-go v1.28.1-0.20250221062042-87cb5136765e h1:SGKkXdFJtc5Rb32jh5E55SCLrHXtOTvc9YKy6QwWbzY=