Skip to content

Commit c0bdd1c

Browse files
authored
feat(datasource/maven): set latest tag ignored by default (#37541)
1 parent f59de33 commit c0bdd1c

File tree

9 files changed

+101
-5
lines changed

9 files changed

+101
-5
lines changed

docs/usage/configuration-options.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4250,6 +4250,12 @@ For `npm` manager when `replacementApproach=alias` then instead of replacing `"f
42504250
Similar to `ignoreUnstable`, this option controls whether to update to versions that are greater than the version tagged as `latest` in the repository.
42514251
By default, `renovate` will update to a version greater than `latest` only if the current version is itself past latest.
42524252

4253+
<!-- prettier-ignore -->
4254+
!!! note
4255+
By default, respectLatest will be set to `false` for Maven results if a `latest` tag is found.
4256+
This is because many Maven registries don't have a reliable `latest` tag - it just means whatever was last published.
4257+
You need to override this to `respectLatest=true` in `packageRules` in order to use it.
4258+
42534259
## reviewers
42544260

42554261
Must be valid usernames.

lib/modules/datasource/clojure/__snapshots__/index.spec.ts.snap

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ exports[`modules/datasource/clojure/index > falls back to next registry url 1`]
3434
"version": "2.0.0",
3535
},
3636
],
37+
"respectLatest": false,
38+
"tags": {
39+
"latest": "2.0.0",
40+
"release": "2.0.0",
41+
},
3742
}
3843
`;
3944

@@ -101,6 +106,11 @@ exports[`modules/datasource/clojure/index > returns releases from custom reposit
101106
"version": "2.0.0",
102107
},
103108
],
109+
"respectLatest": false,
110+
"tags": {
111+
"latest": "2.0.0",
112+
"release": "2.0.0",
113+
},
104114
}
105115
`;
106116

@@ -138,6 +148,11 @@ exports[`modules/datasource/clojure/index > skips registry with invalid XML 1`]
138148
"version": "2.0.0",
139149
},
140150
],
151+
"respectLatest": false,
152+
"tags": {
153+
"latest": "2.0.0",
154+
"release": "2.0.0",
155+
},
141156
}
142157
`;
143158

@@ -175,5 +190,10 @@ exports[`modules/datasource/clojure/index > skips registry with invalid metadata
175190
"version": "2.0.0",
176191
},
177192
],
193+
"respectLatest": false,
194+
"tags": {
195+
"latest": "2.0.0",
196+
"release": "2.0.0",
197+
},
178198
}
179199
`;

lib/modules/datasource/maven/__snapshots__/index.spec.ts.snap

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ exports[`modules/datasource/maven/index > falls back to next registry url 1`] =
3434
"version": "2.0.0",
3535
},
3636
],
37+
"respectLatest": false,
38+
"tags": {
39+
"latest": "2.0.0",
40+
"release": "2.0.0",
41+
},
3742
}
3843
`;
3944

@@ -101,6 +106,11 @@ exports[`modules/datasource/maven/index > removes authentication header after re
101106
"version": "2.0.0",
102107
},
103108
],
109+
"respectLatest": false,
110+
"tags": {
111+
"latest": "2.0.0",
112+
"release": "2.0.0",
113+
},
104114
}
105115
`;
106116

@@ -138,6 +148,11 @@ exports[`modules/datasource/maven/index > returns releases 1`] = `
138148
"version": "2.0.0",
139149
},
140150
],
151+
"respectLatest": false,
152+
"tags": {
153+
"latest": "2.0.0",
154+
"release": "2.0.0",
155+
},
141156
}
142157
`;
143158

@@ -176,6 +191,11 @@ exports[`modules/datasource/maven/index > returns releases from custom repositor
176191
"version": "2.0.0",
177192
},
178193
],
194+
"respectLatest": false,
195+
"tags": {
196+
"latest": "2.0.0",
197+
"release": "2.0.0",
198+
},
179199
}
180200
`;
181201

@@ -213,6 +233,11 @@ exports[`modules/datasource/maven/index > skips registry with invalid XML 1`] =
213233
"version": "2.0.0",
214234
},
215235
],
236+
"respectLatest": false,
237+
"tags": {
238+
"latest": "2.0.0",
239+
"release": "2.0.0",
240+
},
216241
}
217242
`;
218243

@@ -250,5 +275,10 @@ exports[`modules/datasource/maven/index > skips registry with invalid metadata s
250275
"version": "2.0.0",
251276
},
252277
],
278+
"respectLatest": false,
279+
"tags": {
280+
"latest": "2.0.0",
281+
"release": "2.0.0",
282+
},
253283
}
254284
`;

lib/modules/datasource/maven/index.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ describe('modules/datasource/maven/index', () => {
162162
packageScope: 'org.example',
163163
registryUrl: 'https://repo.maven.apache.org/maven2',
164164
releases: [{ version: '1.0.3-SNAPSHOT' }],
165+
respectLatest: false,
166+
tags: {
167+
latest: '1.0.3-SNAPSHOT',
168+
release: '1.0.3-SNAPSHOT',
169+
},
165170
});
166171
});
167172

@@ -193,6 +198,11 @@ describe('modules/datasource/maven/index', () => {
193198
packageScope: 'org.example',
194199
registryUrl: 'https://repo.maven.apache.org/maven2',
195200
releases: [{ version: '1.0.3-SNAPSHOT' }],
201+
respectLatest: false,
202+
tags: {
203+
latest: '1.0.3-SNAPSHOT',
204+
release: '1.0.3-SNAPSHOT',
205+
},
196206
});
197207
});
198208

@@ -471,6 +481,11 @@ describe('modules/datasource/maven/index', () => {
471481
{ version: '1.0.5-SNAPSHOT' },
472482
{ version: '2.0.0' },
473483
],
484+
respectLatest: false,
485+
tags: {
486+
latest: '2.0.0',
487+
release: '2.0.0',
488+
},
474489
isPrivate: true,
475490
});
476491
expect(googleAuth).toHaveBeenCalledTimes(2);
@@ -516,6 +531,11 @@ describe('modules/datasource/maven/index', () => {
516531
{ version: '1.0.5-SNAPSHOT' },
517532
{ version: '2.0.0' },
518533
],
534+
respectLatest: false,
535+
tags: {
536+
latest: '2.0.0',
537+
release: '2.0.0',
538+
},
519539
isPrivate: true,
520540
});
521541
expect(googleAuth).toHaveBeenCalledTimes(2);

lib/modules/datasource/maven/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ function extractVersions(metadata: XmlDocument): MetadataResults {
4949
return res;
5050
}
5151
res.versions = elements.map((el) => el.val);
52+
const latest = metadata.descendantWithPath('versioning.latest');
53+
if (latest?.val) {
54+
res.tags ??= {};
55+
res.tags.latest = latest.val;
56+
}
57+
const release = metadata.descendantWithPath('versioning.release');
58+
if (release?.val) {
59+
res.tags ??= {};
60+
res.tags.release = release.val;
61+
}
5262

5363
return res;
5464
}
@@ -134,6 +144,10 @@ export class MavenDatasource extends Datasource {
134144
};
135145
if (metadata.tags) {
136146
result.tags = metadata.tags;
147+
if (result.tags.latest) {
148+
logger.debug(`Setting respectLatest=false for maven ${packageName}`);
149+
result.respectLatest = false;
150+
}
137151
}
138152

139153
if (!this.defaultRegistryUrls.includes(registryUrl)) {

lib/modules/datasource/maven/readme.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ For example:
3030

3131
#### latest and release tags
3232

33-
Although a package's `maven-metadata.xml` may contain `latest` and `release` tags, we do not map them to `tags.latest` or `tags.release` in Renovate internal data.
34-
The reason for not doing this is that Maven registries don't use these tags as an indicator of stability - `latest` essentially means "the most recent version which was published".
33+
When `latest` or `release` values are present in a package's `maven-metadata.xml`, Renovate will map these to its `tags` concept.
34+
This enables the use of Renovate's `followTag` feature.
3535

36-
For more information on this, see the analysis done in [Discussion #36927](https://github.com/renovatebot/renovate/discussions/36927).
37-
38-
As a result, neither `followTag` nor `respectLatest` concepts apply to Maven dependencies.
36+
However, Renovate will set `respectLatest=false` whenever the `latest` tag is found, because many Maven registries have been found to populate the tag unreliably.
37+
You should use `packageRules` to set `respectLatest=true` if you wish to use this feature.

lib/modules/datasource/maven/s3.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ describe('modules/datasource/maven/s3', () => {
6565
{ version: '1.0.2' },
6666
{ version: '1.0.3' },
6767
],
68+
respectLatest: false,
69+
tags: {
70+
latest: '1.0.2',
71+
release: '1.0.2',
72+
},
6873
isPrivate: true,
6974
});
7075
});

lib/modules/datasource/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export interface ReleaseResult {
9797
packageScope?: string;
9898
mostRecentTimestamp?: Timestamp;
9999
isAbandoned?: boolean;
100+
respectLatest?: boolean;
100101
}
101102

102103
export interface PostprocessReleaseConfig {

lib/workers/repository/process/lookup/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ export async function lookupUpdates(
205205
'packageScope',
206206
'mostRecentTimestamp',
207207
'isAbandoned',
208+
'respectLatest',
208209
]);
209210

210211
const latestVersion = dependency.tags?.latest;

0 commit comments

Comments
 (0)