Skip to content

Commit 627f9cd

Browse files
committed
Extended support for snapshot policy for resolver in Maven Projects
1 parent 5b6a23a commit 627f9cd

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

common/build/buildinfoproperties.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ const Repo = "repo"
4545
const SnapshotRepo = "snapshotRepo"
4646
const ReleaseRepo = "releaseRepo"
4747

48+
const EnableSnapshots = "enableSnapshots"
49+
const SnapshotsUpdatePolicy = "snapshotsUpdatePolicy"
50+
4851
const ServerId = "serverId"
4952
const Url = "url"
5053
const Username = "username"
@@ -123,6 +126,8 @@ var mavenConfigMapping = map[string]string{
123126
"buildInfoConfig.artifactoryResolutionEnabled": "buildInfoConfig.artifactoryResolutionEnabled",
124127
"resolve.repoKey": ResolverPrefix + ReleaseRepo,
125128
"resolve.downSnapshotRepoKey": ResolverPrefix + SnapshotRepo,
129+
"resolve.snapshots.enabled": ResolverPrefix + EnableSnapshots,
130+
"resolve.snapshots.updatePolicy": ResolverPrefix + SnapshotsUpdatePolicy,
126131
"publish.repoKey": DeployerPrefix + ReleaseRepo,
127132
"publish.snapshot.repoKey": DeployerPrefix + SnapshotRepo,
128133
"publish.includePatterns": DeployerPrefix + IncludePatterns,

common/commands/configfile.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ const (
3939
deploymentSnapshotsRepo = "repo-deploy-snapshots"
4040
includePatterns = "include-patterns"
4141
excludePatterns = "exclude-patterns"
42+
enableSnapshots = "enable-snapshots"
43+
snapshotsUpdatePolicy = "snapshots-update-policy"
4244

4345
// Gradle flags
4446
usesPlugin = "uses-plugin"
@@ -251,14 +253,20 @@ func WithDeployerRepo(repoId string) ConfigOption {
251253
// Populate Maven related configuration from cli flags
252254
func (configFile *ConfigFile) populateMavenConfigFromFlags(c *cli.Context) {
253255
configFile.Resolver.SnapshotRepo = c.String(resolutionSnapshotsRepo)
256+
// set to false only when user explicitly sets it
257+
configFile.Resolver.EnableSnapshots = true
258+
if c.IsSet(enableSnapshots) {
259+
configFile.Resolver.EnableSnapshots = c.Bool(enableSnapshots)
260+
}
261+
configFile.Resolver.SnapshotsUpdatePolicy = c.String(snapshotsUpdatePolicy)
254262
configFile.Resolver.ReleaseRepo = c.String(resolutionReleasesRepo)
255263
configFile.Deployer.SnapshotRepo = c.String(deploymentSnapshotsRepo)
256264
configFile.Deployer.ReleaseRepo = c.String(deploymentReleasesRepo)
257265
configFile.Deployer.IncludePatterns = c.String(includePatterns)
258266
configFile.Deployer.ExcludePatterns = c.String(excludePatterns)
259267
configFile.UseWrapper = c.Bool(useWrapper)
260268
configFile.Interactive = configFile.Interactive && !isAnyFlagSet(c, resolutionSnapshotsRepo, resolutionReleasesRepo,
261-
deploymentSnapshotsRepo, deploymentReleasesRepo, includePatterns, excludePatterns)
269+
enableSnapshots, snapshotsUpdatePolicy, deploymentSnapshotsRepo, deploymentReleasesRepo, includePatterns, excludePatterns)
262270
}
263271

264272
func WithResolverSnapshotRepo(repoId string) ConfigOption {

common/project/projectconfig.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,19 @@ func (mre *MissingResolverErr) Error() string {
9696
}
9797

9898
type Repository struct {
99-
Repo string `yaml:"repo,omitempty"`
100-
ServerId string `yaml:"serverId,omitempty"`
101-
SnapshotRepo string `yaml:"snapshotRepo,omitempty"`
102-
ReleaseRepo string `yaml:"releaseRepo,omitempty"`
103-
DeployMavenDesc bool `yaml:"deployMavenDescriptors,omitempty"`
104-
DeployIvyDesc bool `yaml:"deployIvyDescriptors,omitempty"`
105-
IvyPattern string `yaml:"ivyPattern,omitempty"`
106-
ArtifactsPattern string `yaml:"artifactPattern,omitempty"`
107-
NugetV2 bool `yaml:"nugetV2,omitempty"`
108-
IncludePatterns string `yaml:"includePatterns,omitempty"`
109-
ExcludePatterns string `yaml:"excludePatterns,omitempty"`
99+
Repo string `yaml:"repo,omitempty"`
100+
ServerId string `yaml:"serverId,omitempty"`
101+
SnapshotRepo string `yaml:"snapshotRepo,omitempty"`
102+
EnableSnapshots bool `yaml:"enableSnapshots"`
103+
SnapshotsUpdatePolicy string `yaml:"snapshotsUpdatePolicy,omitempty"`
104+
ReleaseRepo string `yaml:"releaseRepo,omitempty"`
105+
DeployMavenDesc bool `yaml:"deployMavenDescriptors,omitempty"`
106+
DeployIvyDesc bool `yaml:"deployIvyDescriptors,omitempty"`
107+
IvyPattern string `yaml:"ivyPattern,omitempty"`
108+
ArtifactsPattern string `yaml:"artifactPattern,omitempty"`
109+
NugetV2 bool `yaml:"nugetV2,omitempty"`
110+
IncludePatterns string `yaml:"includePatterns,omitempty"`
111+
ExcludePatterns string `yaml:"excludePatterns,omitempty"`
110112
}
111113

112114
type RepositoryConfig struct {

0 commit comments

Comments
 (0)