@@ -13,10 +13,10 @@ import kotlinx.coroutines.runBlocking
1313import kotlinx.coroutines.withContext
1414import kotlinx.serialization.decodeFromString
1515import kotlinx.serialization.encodeToString
16+ import nmcp.internal.task.Artifact
1617import nmcp.internal.task.ArtifactMetadata
1718import nmcp.internal.task.Gav
1819import nmcp.internal.task.VersionMetadata
19- import nmcp.internal.task.Artifact
2020import nmcp.internal.task.xml
2121import okio.ByteString.Companion.toByteString
2222
@@ -172,23 +172,18 @@ private fun publishGav(
172172 check(index != - 1 ) {
173173 " Nmcp: invalid gav path: '$gavPath '"
174174 }
175+
175176 val artifactMetadataPath = " ${gavPath.substring(0 , index)} /maven-metadata.xml"
176- val localArtifactMetadataFile = allFiles.firstOrNull { it.normalizedPath == artifactMetadataPath }
177- val localArtifactMetadata = if (localArtifactMetadataFile == null ) {
178- // The publisher did not artifact level metadata, let's
179- ArtifactMetadata (
177+ val artifactMetadata = ArtifactMetadata (
180178 groupId = gav.groupId,
181179 artifactId = gav.artifactId,
182180 versioning = ArtifactMetadata .Versioning (
183- latest = gav.baseVersion ,
184- release = gav.baseVersion ,
181+ latest = " TODO " ,
182+ release = " TODO " ,
185183 versions = emptyList(),
186- lastUpdated = lastUpdated.asTimestamp( false ) ,
184+ lastUpdated = " TODO " ,
187185 ),
188186 )
189- } else {
190- xml.decodeFromString<ArtifactMetadata >(localArtifactMetadataFile.file.readText())
191- }
192187
193188 val remoteArtifactMetadata = transport.get(artifactMetadataPath)
194189
@@ -207,9 +202,19 @@ private fun publishGav(
207202 if (versions.none { it == gav.baseVersion }) {
208203 versions.add(gav.baseVersion)
209204 }
210- val newArtifactMetadata = localArtifactMetadata.copy(
211- versioning = localArtifactMetadata.versioning.copy(
212- versions = versions,
205+ val newArtifactMetadata = artifactMetadata.copy(
206+ // Patch the
207+ versioning = artifactMetadata.versioning.copy(
208+ latest = gav.baseVersion,
209+ /* *
210+ * XXX: this is not correct, but doing this correctly would require parsing semantic versioning here
211+ * to get the highest non-SNAPSHOT version.
212+ * I am not too keen on introducing that complexity here, and in general cases, repositories shouldn't
213+ * mix snapshots and releases, so I'm hoping this is all fine.
214+ */
215+ release = gav.baseVersion,
216+ lastUpdated = lastUpdated.asTimestamp(false ),
217+ versions = versions.sorted(),
213218 ),
214219 )
215220
0 commit comments