diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml
index c29464bea0a..1262650d1e4 100644
--- a/gradle/verification-metadata.xml
+++ b/gradle/verification-metadata.xml
@@ -6909,12 +6909,6 @@
-
-
-
-
-
-
diff --git a/repo/artifacts-tests/build.gradle.kts b/repo/artifacts-tests/build.gradle.kts
index cb2cf8195af..43098010a26 100644
--- a/repo/artifacts-tests/build.gradle.kts
+++ b/repo/artifacts-tests/build.gradle.kts
@@ -1,18 +1,24 @@
+import java.nio.file.Paths
+
plugins {
kotlin("jvm")
id("jps-compatible")
}
dependencies {
- testApi(kotlinStdlib("jdk8"))
+ testImplementation(kotlinStdlib("jdk8"))
testImplementation(project(":kotlin-test:kotlin-test-junit5"))
testApiJUnit5()
- testImplementation("org.apache.maven:maven-model:3.8.7")
+ testImplementation(projectTests(":compiler:tests-common-new"))
}
projectTest(jUnitMode = JUnitMode.JUnit5) {
workingDir = rootDir
useJUnitPlatform { }
+ doFirst {
+ val defaultMavenLocal = Paths.get(System.getProperty("user.home"), ".m2", "repository").toAbsolutePath()
+ val mavenLocal = System.getProperty("maven.repo.local") ?: defaultMavenLocal
+ systemProperty("maven.repo.local", mavenLocal)
+ systemProperty("kotlin.version", version)
+ }
}
-
-testsJar()
diff --git a/repo/artifacts-tests/src/test/kotlin/org/jetbrains/kotlin/code/ArtifactsTest.kt b/repo/artifacts-tests/src/test/kotlin/org/jetbrains/kotlin/code/ArtifactsTest.kt
new file mode 100644
index 00000000000..2ce3007041a
--- /dev/null
+++ b/repo/artifacts-tests/src/test/kotlin/org/jetbrains/kotlin/code/ArtifactsTest.kt
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
+ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
+ */
+
+package org.jetbrains.kotlin.code
+
+import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertEqualsToFile
+import org.jetbrains.kotlin.test.services.JUnit5Assertions.isTeamCityBuild
+import java.nio.file.Files
+import java.nio.file.Path
+import java.nio.file.Paths
+import java.nio.file.attribute.BasicFileAttributes
+import kotlin.test.Test
+import kotlin.test.assertTrue
+import kotlin.test.fail
+
+class ArtifactsTest {
+
+ private val kotlinVersion = System.getProperty("kotlin.version")
+ private val mavenLocal = System.getProperty("maven.repo.local")
+ private val localRepoPath = Paths.get(mavenLocal, "org/jetbrains/kotlin")
+ private val expectedRepoPath = Paths.get("repo/artifacts-tests/src/test/resources/org/jetbrains/kotlin")
+
+ private val excludedProjects = setOf(
+ "annotation-processor-example",
+ "android-test-fixes",
+ "org.jetbrains.kotlin.gradle-subplugin-example.gradle.plugin",
+ "gradle-warnings-detector",
+ "kotlin-compiler-args-properties",
+ "kotlin-gradle-plugin-kpm-android",
+ "kotlin-gradle-plugin-tcs-android",
+ "kotlin-gradle-subplugin-example",
+ "kotlin-java-example",
+ "kotlin-maven-plugin-test",
+ "org.jetbrains.kotlin.test.fixes.android.gradle.plugin",
+ "org.jetbrains.kotlin.test.gradle-warnings-detector.gradle.plugin",
+ "org.jetbrains.kotlin.test.kotlin-compiler-args-properties.gradle.plugin",
+ )
+
+ @Test
+ fun verifyArtifactFiles() {
+ val visitedPoms = mutableSetOf()
+ val actualPoms = Files.find(
+ localRepoPath,
+ Integer.MAX_VALUE,
+ { path: Path, fileAttributes: BasicFileAttributes ->
+ fileAttributes.isRegularFile
+ && "${path.fileName}".endsWith(".pom", ignoreCase = true)
+ && path.contains(Paths.get(kotlinVersion))
+ })
+ actualPoms.forEach { actual ->
+ val expectedPomPath = actual.toExpectedPath()
+ if ("${expectedPomPath.parent.fileName}" !in excludedProjects) {
+ val actualString = actual.toFile().readText().replace(kotlinVersion, "ArtifactsTest.version")
+ assertEqualsToFile(expectedPomPath, actualString)
+ visitedPoms.add(expectedPomPath)
+ } else {
+ if (isTeamCityBuild) fail("Excluded project in actual artifacts: $actual")
+ }
+ }
+
+ val expectedPoms = Files.find(
+ expectedRepoPath,
+ Integer.MAX_VALUE,
+ { path: Path, fileAttributes: BasicFileAttributes ->
+ fileAttributes.isRegularFile
+ && "${path.fileName}".endsWith(".pom", ignoreCase = true)
+ })
+ expectedPoms.forEach {
+ assertTrue(it in visitedPoms, "Missing actual pom for expected pom: $it")
+ }
+ }
+
+ /**
+ * convert:
+ * ${mavenLocal}/org/jetbrains/kotlin/artifact/version/artifact-version.pom
+ * to:
+ * ${expectedRepository}/org/jetbrains/kotlin/artifact/artifact.pom
+ */
+ private fun Path.toExpectedPath(): Path {
+ val artifactDirPath = localRepoPath.relativize(this).parent.parent
+ val expectedFileName = "${artifactDirPath.fileName}.pom"
+ return expectedRepoPath.resolve(artifactDirPath.resolve(expectedFileName))
+ }
+}
\ No newline at end of file