diff --git a/build.xml b/build.xml index b09bbef90dd..42efe246a54 100644 --- a/build.xml +++ b/build.xml @@ -1073,7 +1073,7 @@ - + @@ -1118,6 +1118,7 @@ + @@ -1130,7 +1131,7 @@ - + diff --git a/libraries/pom.xml b/libraries/pom.xml index 35fbdc850b2..d30938d2369 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -52,6 +52,8 @@ ${kotlin-dist}/kotlinc ${env.JDK_16} + 1.1 + 1.6 1.6 diff --git a/libraries/stdlib/common/pom.xml b/libraries/stdlib/common/pom.xml index 05f37f1ba27..80b30f544a9 100644 --- a/libraries/stdlib/common/pom.xml +++ b/libraries/stdlib/common/pom.xml @@ -108,6 +108,18 @@ + + org.apache.maven.plugins + maven-jar-plugin + + + + ${kotlin.language.version} + Core + + + + diff --git a/libraries/stdlib/jre7/pom.xml b/libraries/stdlib/jre7/pom.xml index 5d844692192..e12e03c0823 100644 --- a/libraries/stdlib/jre7/pom.xml +++ b/libraries/stdlib/jre7/pom.xml @@ -78,6 +78,19 @@ + + org.apache.maven.plugins + maven-jar-plugin + + + + ${kotlin.language.version} + Core + + + + + maven-surefire-plugin diff --git a/libraries/stdlib/jre8/pom.xml b/libraries/stdlib/jre8/pom.xml index 6e8f4075a95..a0b73dcc84e 100644 --- a/libraries/stdlib/jre8/pom.xml +++ b/libraries/stdlib/jre8/pom.xml @@ -79,6 +79,19 @@ + + org.apache.maven.plugins + maven-jar-plugin + + + + ${kotlin.language.version} + Core + + + + + maven-surefire-plugin diff --git a/libraries/stdlib/pom.xml b/libraries/stdlib/pom.xml index f94dbdbe19c..7ed4e60b448 100644 --- a/libraries/stdlib/pom.xml +++ b/libraries/stdlib/pom.xml @@ -68,6 +68,20 @@ + + + org.apache.maven.plugins + maven-jar-plugin + + + + ${kotlin.language.version} + Core + + + + + maven-surefire-plugin diff --git a/libraries/tools/kotlin-maven-plugin-test/pom.xml b/libraries/tools/kotlin-maven-plugin-test/pom.xml index 28cd8b7a7b7..396095d2d52 100644 --- a/libraries/tools/kotlin-maven-plugin-test/pom.xml +++ b/libraries/tools/kotlin-maven-plugin-test/pom.xml @@ -38,6 +38,21 @@ kotlin-js-library ${project.version} + + org.jetbrains.kotlin + kotlin-stdlib-jre7 + ${project.version} + + + org.jetbrains.kotlin + kotlin-stdlib-jre8 + ${project.version} + + + org.jetbrains.kotlin + kotlin-stdlib-common + ${project.version} + diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kotlin-version-in-manifest/pom.xml b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kotlin-version-in-manifest/pom.xml new file mode 100644 index 00000000000..ff1dc7b8f18 --- /dev/null +++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kotlin-version-in-manifest/pom.xml @@ -0,0 +1,90 @@ + + + 4.0.0 + + org.jetbrains.kotlin + test-kotlin-version-in-manifest + 1.0-SNAPSHOT + + + + junit + junit + 4.9 + + + org.jetbrains.kotlin + kotlin-reflect + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-stdlib-common + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-stdlib-jre7 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-stdlib-jre8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-script-runtime + ${kotlin.version} + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + org.apache.maven.plugins + maven-source-plugin + 2.1.2 + + + + + ${project.basedir}/src/main/kotlin + + + kotlin-maven-plugin + org.jetbrains.kotlin + ${kotlin.version} + + + compile + process-sources + + compile + + + + test-compile + process-test-sources + + test-compile + + + + + + + + \ No newline at end of file diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kotlin-version-in-manifest/src/main/kotlin/test.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kotlin-version-in-manifest/src/main/kotlin/test.kt new file mode 100644 index 00000000000..e9a0d08b46d --- /dev/null +++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kotlin-version-in-manifest/src/main/kotlin/test.kt @@ -0,0 +1,74 @@ +package test + +import java.net.URL +import java.util.jar.Attributes +import java.util.jar.Manifest + +// "Kotlin Reflect" and "Kotlin Script Runtime" are different because unlike other libraries which are built with Maven, they're copied from dist +val LIBRARIES = listOf( + "kotlin-runtime", + "kotlin-stdlib", + "kotlin-stdlib-common", + "kotlin-stdlib-jre7", + "kotlin-stdlib-jre8", + "Kotlin Reflect", + "Kotlin Script Runtime" +) + +const val KOTLIN_VERSION = "Kotlin-Version" +const val KOTLIN_RUNTIME_COMPONENT = "Kotlin-Runtime-Component" +const val KOTLIN_RUNTIME_COMPONENT_VALUE = "Core" +val KOTLIN_VERSION_VALUE = with(KotlinVersion.CURRENT) { "$major.$minor" } + +fun main(args: Array) { + val implementationTitles = arrayListOf() + + val versionValues = hashMapOf() + val runtimeComponentValues = hashMapOf() + + for (resource in object {}.javaClass.classLoader.getResources("META-INF/MANIFEST.MF")) { + val manifest = resource.openStream().use(::Manifest).mainAttributes + val title = manifest.getValue(Attributes.Name.IMPLEMENTATION_TITLE) ?: continue + if ("kotlin" !in title.toLowerCase()) continue + + implementationTitles.add(title) + versionValues[resource] = manifest.getValue(KOTLIN_VERSION) + runtimeComponentValues[resource] = manifest.getValue(KOTLIN_RUNTIME_COMPONENT) + } + + val errors = StringBuilder() + + val uncheckedLibraries = LIBRARIES - implementationTitles + if (uncheckedLibraries.isNotEmpty()) { + errors.appendln("These libraries are not found in the dependencies of this test project, thus their manifests cannot be checked. " + + "Please ensure they are listed in the section in the corresponding pom.xml:\n$uncheckedLibraries") + errors.appendln("(all found libraries: $implementationTitles)") + errors.appendln() + } + + fun renderEntry(entry: Map.Entry) = buildString { + val (url, value) = entry + append(url) + if (value != null) append(" (actual value: $value)") + else append(" (attribute is not found)") + } + + val incorrectVersionValues = versionValues.filterValues { it != KOTLIN_VERSION_VALUE } + if (incorrectVersionValues.isNotEmpty()) { + errors.appendln("Manifests at these locations do not have the correct value of the $KOTLIN_VERSION attribute ($KOTLIN_VERSION_VALUE). " + + "Please ensure that kotlin.language.version in libraries/pom.xml corresponds to the value in kotlin.KotlinVersion:") + incorrectVersionValues.entries.joinTo(errors, "\n", transform = ::renderEntry) + errors.appendln() + errors.appendln() + } + + val incorrectRuntimeComponentValues = runtimeComponentValues.filterValues { it != KOTLIN_RUNTIME_COMPONENT_VALUE } + if (incorrectRuntimeComponentValues.isNotEmpty()) { + errors.appendln("Manifests at these locations do not have the correct value of the $KOTLIN_RUNTIME_COMPONENT attribute ($KOTLIN_RUNTIME_COMPONENT_VALUE):") + incorrectRuntimeComponentValues.entries.joinTo(errors, "\n", transform = ::renderEntry) + } + + if (errors.isNotEmpty()) { + throw AssertionError(errors) + } +} diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kotlin-version-in-manifest/src/test/java/org/jetbrains/TestKotlinVersionInManifest.java b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kotlin-version-in-manifest/src/test/java/org/jetbrains/TestKotlinVersionInManifest.java new file mode 100644 index 00000000000..1efdd5d38ca --- /dev/null +++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kotlin-version-in-manifest/src/test/java/org/jetbrains/TestKotlinVersionInManifest.java @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains; + +import org.junit.Test; + +public class TestKotlinVersionInManifest { + @Test + public void greeting() { + test.TestKt.main(new String[0]); + } +} diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kotlin-version-in-manifest/verify.bsh b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kotlin-version-in-manifest/verify.bsh new file mode 100644 index 00000000000..0eabd96f958 --- /dev/null +++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kotlin-version-in-manifest/verify.bsh @@ -0,0 +1,6 @@ +import java.io.*; + +File file = new File(basedir, "target/test-kotlin-version-in-manifest-1.0-SNAPSHOT.jar"); +if (!file.exists() || !file.isFile()) { + throw new FileNotFoundException("Could not find generated JAR: " + file); +} diff --git a/libraries/tools/runtime/pom.xml b/libraries/tools/runtime/pom.xml index 62f98a5e46b..3ab4c0cae25 100644 --- a/libraries/tools/runtime/pom.xml +++ b/libraries/tools/runtime/pom.xml @@ -107,6 +107,19 @@ + + org.apache.maven.plugins + maven-jar-plugin + + + + ${kotlin.language.version} + Core + + + + + org.jetbrains.kotlin kotlin-maven-plugin