org.jetbrains.kotlin
kotlin-gradle-subplugin-example
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/SimpleKotlinGradleIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/SimpleKotlinGradleIT.kt
index af44201ec1b..87ae90d1567 100644
--- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/SimpleKotlinGradleIT.kt
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/SimpleKotlinGradleIT.kt
@@ -1,6 +1,9 @@
package org.jetbrains.kotlin.gradle
+import org.jetbrains.kotlin.gradle.util.checkBytecodeContains
import org.junit.Test
+import java.io.File
+import kotlin.test.assertTrue
class SimpleKotlinGradleIT : BaseGradleIT() {
@@ -99,4 +102,46 @@ class SimpleKotlinGradleIT : BaseGradleIT() {
assertContains("GreeterTest PASSED")
}
}
+
+ @Test
+ fun testAllOpenPlugin() {
+ Project("allOpenSimple", GRADLE_VERSION).build("build") {
+ assertSuccessful()
+
+ val classesDir = File(project.projectDir, "build/classes/main")
+ val openClass = File(classesDir, "test/OpenClass.class")
+ val closedClass = File(classesDir, "test/ClosedClass.class")
+ assertTrue(openClass.exists())
+ assertTrue(closedClass.exists())
+
+ checkBytecodeContains(openClass,
+ "public class test/OpenClass {",
+ "public method()V")
+
+ checkBytecodeContains(closedClass,
+ "public final class test/ClosedClass {",
+ "public final method()V")
+ }
+ }
+
+ @Test
+ fun testKotlinSpringPlugin() {
+ Project("allOpenSpring", GRADLE_VERSION).build("build") {
+ assertSuccessful()
+
+ val classesDir = File(project.projectDir, "build/classes/main")
+ val openClass = File(classesDir, "test/OpenClass.class")
+ val closedClass = File(classesDir, "test/ClosedClass.class")
+ assertTrue(openClass.exists())
+ assertTrue(closedClass.exists())
+
+ checkBytecodeContains(openClass,
+ "public class test/OpenClass {",
+ "public method()V")
+
+ checkBytecodeContains(closedClass,
+ "public final class test/ClosedClass {",
+ "public final method()V")
+ }
+ }
}
\ No newline at end of file
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSimple/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSimple/build.gradle
new file mode 100644
index 00000000000..3fe5b66753e
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSimple/build.gradle
@@ -0,0 +1,28 @@
+buildscript {
+ repositories {
+ mavenLocal()
+ }
+ dependencies {
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
+ }
+}
+
+apply plugin: "kotlin"
+apply plugin: "kotlin-allopen"
+
+repositories {
+ mavenLocal()
+}
+
+sourceSets {
+ main.kotlin.srcDir 'src'
+}
+
+allOpen {
+ annotation("lib.AllOpen")
+}
+
+dependencies {
+ compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
+}
\ No newline at end of file
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSimple/src/annotations.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSimple/src/annotations.kt
new file mode 100644
index 00000000000..b3b21ba837a
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSimple/src/annotations.kt
@@ -0,0 +1,5 @@
+package lib
+
+annotation class AllOpen
+
+annotation class AllClose
\ No newline at end of file
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSimple/src/test.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSimple/src/test.kt
new file mode 100644
index 00000000000..d33c0c3a094
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSimple/src/test.kt
@@ -0,0 +1,13 @@
+package test
+
+import lib.*
+
+@AllOpen
+class OpenClass {
+ fun method() {}
+}
+
+@AllClose // effectively does nothing
+class ClosedClass {
+ fun method() {}
+}
\ No newline at end of file
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSpring/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSpring/build.gradle
new file mode 100644
index 00000000000..85f3bf457cc
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSpring/build.gradle
@@ -0,0 +1,24 @@
+buildscript {
+ repositories {
+ mavenLocal()
+ }
+ dependencies {
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
+ }
+}
+
+apply plugin: "kotlin"
+apply plugin: "kotlin-spring"
+
+repositories {
+ mavenLocal()
+}
+
+sourceSets {
+ main.kotlin.srcDir 'src'
+}
+
+dependencies {
+ compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
+}
\ No newline at end of file
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSpring/src/org/springframework/stereotype/Component.java b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSpring/src/org/springframework/stereotype/Component.java
new file mode 100644
index 00000000000..dda67f42e26
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSpring/src/org/springframework/stereotype/Component.java
@@ -0,0 +1,60 @@
+/**
+ * This file was copied from the spring framework:
+ * https://github.com/spring-projects/spring-framework
+ */
+
+/*
+ * Copyright 2002-2007 the original author or authors.
+ *
+ * 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.springframework.stereotype;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Indicates that an annotated class is a "component".
+ * Such classes are considered as candidates for auto-detection
+ * when using annotation-based configuration and classpath scanning.
+ *
+ * Other class-level annotations may be considered as identifying
+ * a component as well, typically a special kind of component:
+ * e.g. the {@link Repository @Repository} annotation or AspectJ's
+ * {@link org.aspectj.lang.annotation.Aspect @Aspect} annotation.
+ *
+ * @ author Mark Fisher
+ * @since 2.5
+ * @see Repository
+ * @see Service
+ * @see Controller
+ * @see org.springframework.context.annotation.ClassPathBeanDefinitionScanner
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Indexed
+public @interface Component {
+
+ /**
+ * The value may indicate a suggestion for a logical component name,
+ * to be turned into a Spring bean in case of an autodetected component.
+ * @return the suggested component name, if any
+ */
+ String value() default "";
+
+}
\ No newline at end of file
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSpring/src/test.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSpring/src/test.kt
new file mode 100644
index 00000000000..1ed4250b66b
--- /dev/null
+++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSpring/src/test.kt
@@ -0,0 +1,12 @@
+package test
+
+import org.springframework.stereotype.Component
+
+@Component
+class OpenClass {
+ fun method() {}
+}
+
+class ClosedClass {
+ fun method() {}
+}
\ No newline at end of file
diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/util/bytecodeUtils.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/util/bytecodeUtils.kt
index e7d6812924d..126873b1d2d 100644
--- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/util/bytecodeUtils.kt
+++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/util/bytecodeUtils.kt
@@ -13,6 +13,10 @@ fun classFileBytecodeString(classFile: File): String {
return out.toString()
}
+fun checkBytecodeContains(classFile: File, vararg strings: String) {
+ checkBytecodeContains(classFile, strings.toList())
+}
+
fun checkBytecodeContains(classFile: File, strings: Iterable) {
val bytecode = classFileBytecodeString(classFile)
for (string in strings) {