I have such maven-metadata.xml file content:
<groupId>com.ifact</groupId>
<artifactId>xxxx-exporter</artifactId>
<versioning>
<latest>0.0.21</latest>
<release>0.0.21</release>
<versions>
<version>0.0.1</version>
<version>0.0.2</version>
<version>0.0.3</version>
<version>0.0.4</version>
<version>0.0.5</version>
<version>0.0.6</version>
<version>0.0.7</version>
<version>0.0.8</version>
<version>0.0.9</version>
<version>0.0.10</version>
<version>0.0.11</version>
<version>0.0.12</version>
<version>0.0.13</version>
<version>0.0.14</version>
<version>0.0.15</version>
<version>0.0.16</version>
<version>0.0.17</version>
<version>0.0.18</version>
<version>0.0.19</version>
<version>0.0.20</version>
<version>0.0.20-1</version>
<version>0.0.20-2</version>
<version>0.0.21</version>
</versions>
<lastUpdated>20191206104706</lastUpdated>
</versioning>
</metadata>
And we saw that 0.0.21 is the latest artifact version. (was created Sun Dec 01 2019 13:28:29 GMT+0200)
AND
0.0.20-1 (was created Fri Dec 06 2019 12:47:03 GMT+0200)
0.0.20-2 (was created Fri Dec 06 2019 12:46:21 GMT+0200)
So maven-metadata.xml sort files not by creation date, it sort by version.
But I need to get the last updated/uploaded artifact and I cannot rely on the contents of the maven-metadata.xml file.
I try to use API call:
http://127.0.0.1:8081/service/rest/v1/search/assets?sort=&repository=xxxx-exporter-release&maven.extension=jar
And saw a correct out:
"items": [
{
"downloadUrl": "http://127.0.0.1:8081/repository/xxxx-exporter-release/com/ifact/xxxx-exporter/0.0.21/xxxx-exporter-0.0.21.jar",
"path": "com/ifact/xxxx-exporter/0.0.21/xxxx-exporter-0.0.21.jar",
"id": "Yml6aWJveC1leHBvcnRlci1yZWxlYXNlOmExMTg4MWU5MDBiZWQyNTYzMWJhOThlMDJjNTczM2Zi",
"repository": "xxxx-exporter-release",
"format": "maven2",
"checksum": {
"sha1": "3c775285fa2f86aabe4d7ddc42ee0a5092fa4029",
"md5": "066e78dbfcc1dc682fdbbe0241acca5a"
}
},
{
"downloadUrl": "http://127.0.0.1:8081/repository/xxxx-exporter-release/com/ifact/xxxx-exporter/0.0.20-2/xxxx-exporter-0.0.20-2.jar",
"path": "com/ifact/xxxx-exporter/0.0.20-2/xxxx-exporter-0.0.20-2.jar",
"id": "Yml6aWJveC1leHBvcnRlci1yZWxlYXNlOmExMTg4MWU5MDBiZWQyNTYwZmQ0OWMxY2M4MDhhYjhh",
"repository": "xxxx-exporter-release",
"format": "maven2",
"checksum": {
"sha1": "667138ef9d6c956b38c4691f415c1aea3451f492",
"md5": "742607e475560ef2718d8c73c9659a2a"
}
},
{
"downloadUrl": "http://127.0.0.1:8081/repository/xxxx-exporter-release/com/ifact/xxxx-exporter/0.0.20-1/xxxx-exporter-0.0.20-1.jar",
"path": "com/ifact/xxxx-exporter/0.0.20-1/xxxx-exporter-0.0.20-1.jar",
"id": "Yml6aWJveC1leHBvcnRlci1yZWxlYXNlOmExMTg4MWU5MDBiZWQyNTY4YTJmYzM3MWI5MDY2OTcz",
"repository": "xxxx-exporter-release",
"format": "maven2",
"checksum": {
"sha1": "7a5a77bef08f798d36a4e1eefe36d9e122690f2b",
"md5": "77b35b49278a30141afcb3675c66c26a"
}
}
],
"continuationToken": null
}
API sort them by creation time or last uploaded. But if we download an artifact that mark latest 0.0.21 in maven-metadata.xml. And after this make API call again
http://127.0.0.1:8081/service/rest/v1/search/assets?sort=&repository=xxxx-exporter-release&maven.extension=jar
At response we saw:
"items": [
"downloadUrl": "http://127.0.0.1:8081/repository/xxxx-exporter-release/com/ifact/xxxx-exporter/0.0.20/xxxx-exporter-0.0.20.jar",
"path": "com/ifact/xxxx-exporter/0.0.20/xxxx-exporter-0.0.20.jar",
"id": "Yml6aWJveC1leHBvcnRlci1yZWxlYXNlOmExMTg4MWU5MDBiZWQyNTZkZDkxNWE5MWVjMTUzZDdj",
"repository": "xxxx-exporter-release",
"format": "maven2",
"checksum": {
"sha1": "393741a956166b3354700ec647fd1f075e86b515",
"md5": "aeacbd02eb39da06732bfb80beb7dd64"
}
},
{
"downloadUrl": "http://127.0.0.1:8081/repository/xxxx-exporter-release/com/ifact/xxxx-exporter/0.0.20-2/xxxx-exporter-0.0.20-2.jar",
"path": "com/ifact/xxxx-exporter/0.0.20-2/xxxx-exporter-0.0.20-2.jar",
"id": "Yml6aWJveC1leHBvcnRlci1yZWxlYXNlOmExMTg4MWU5MDBiZWQyNTYwZmQ0OWMxY2M4MDhhYjhh",
"repository": "xxxx-exporter-release",
"format": "maven2",
"checksum": {
"sha1": "667138ef9d6c956b38c4691f415c1aea3451f492",
"md5": "742607e475560ef2718d8c73c9659a2a"
}
},
{
"downloadUrl": "http://127.0.0.1:8081/repository/xxxx-exporter-release/com/ifact/xxxx-exporter/0.0.20-1/xxxx-exporter-0.0.20-1.jar",
"path": "com/ifact/xxxx-exporter/0.0.20-1/xxxx-exporter-0.0.20-1.jar",
"id": "Yml6aWJveC1leHBvcnRlci1yZWxlYXNlOmExMTg4MWU5MDBiZWQyNTY4YTJmYzM3MWI5MDY2OTcz",
"repository": "xxxx-exporter-release",
"format": "maven2",
"checksum": {
"sha1": "7a5a77bef08f798d36a4e1eefe36d9e122690f2b",
"md5": "77b35b49278a30141afcb3675c66c26a"
}
},
{
"downloadUrl": "http://127.0.0.1:8081/repository/xxxx-exporter-release/com/ifact/xxxx-exporter/0.0.21/xxxx-exporter-0.0.21.jar",
"path": "com/ifact/xxxx-exporter/0.0.21/xxxx-exporter-0.0.21.jar",
"id": "Yml6aWJveC1leHBvcnRlci1yZWxlYXNlOmExMTg4MWU5MDBiZWQyNTYzMWJhOThlMDJjNTczM2Zi",
"repository": "xxxx-exporter-release",
"format": "maven2",
"checksum": {
"sha1": "3c775285fa2f86aabe4d7ddc42ee0a5092fa4029",
"md5": "066e78dbfcc1dc682fdbbe0241acca5a"
}
}
],
"continuationToken": null
}
The last downloaded artifact becomes the latest in API response.
How can I get the last updated/uploaded artifact?
Nexus version is Sonatype Nexus Repository ManagerOSS 3.19.1-01