Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions common/build/buildinfoproperties.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion common/commands/configfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -251,14 +253,16 @@ 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)
configFile.Deployer.IncludePatterns = c.String(includePatterns)
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 {
Expand Down
46 changes: 46 additions & 0 deletions common/commands/flag_test.go
Original file line number Diff line number Diff line change
@@ -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)
})
}
}
24 changes: 13 additions & 11 deletions common/project/projectconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
Loading