diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/pom.xml b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/pom.xml
new file mode 100644
index 00000000000..ca7fbd34d3e
--- /dev/null
+++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/pom.xml
@@ -0,0 +1,163 @@
+
+
+
+ 4.0.0
+
+ org.jetbrains.kotlin.examples
+ dagger-maven-example
+ 1.0-SNAPSHOT
+
+
+ 4.12
+ coffee.CoffeeApp
+ UTF-8
+
+
+
+
+ com.google.dagger
+ dagger
+ 2.9
+
+
+ org.jetbrains.kotlin
+ kotlin-stdlib
+ ${kotlin.version}
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+
+
+
+
+ kotlin-maven-plugin
+ org.jetbrains.kotlin
+ ${kotlin.version}
+
+
+
+ all-open
+
+
+
+
+
+
+
+
+ org.jetbrains.kotlin
+ kotlin-maven-allopen
+ ${kotlin.version}
+
+
+
+
+
+ kapt
+
+ kapt
+
+
+
+ src/main/kotlin
+ src/main/java
+
+
+
+ com.google.dagger
+ dagger-compiler
+ 2.9
+
+
+
+
+
+ compile
+
+ compile
+
+
+
+ src/main/kotlin
+ src/main/java
+
+
+
+
+ test-kapt
+
+ test-kapt
+
+
+
+ src/test/kotlin
+ src/test/java
+
+
+
+ com.google.dagger
+ dagger-compiler
+ 2.9
+
+
+
+
+
+ test-compile
+
+ test-compile
+
+
+
+ src/test/kotlin
+ src/test/java
+ target/generated-sources/kapt/test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.5.1
+
+ none
+ 1.6
+ 1.6
+
+
+
+
+ default-compile
+ none
+
+
+
+ default-testCompile
+ none
+
+
+ java-compile
+ compile
+
+ compile
+
+
+
+ java-test-compile
+ test-compile
+ testCompile
+
+
+
+
+
+
diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/AllOpenTest.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/AllOpenTest.kt
new file mode 100644
index 00000000000..1c924f086a8
--- /dev/null
+++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/AllOpenTest.kt
@@ -0,0 +1,8 @@
+package coffee
+
+annotation class AllOpen
+
+@AllOpen
+class MyClass
+
+class MyClass2 : MyClass()
\ No newline at end of file
diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/CoffeeApp.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/CoffeeApp.kt
new file mode 100755
index 00000000000..9e1d910ef48
--- /dev/null
+++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/CoffeeApp.kt
@@ -0,0 +1,18 @@
+package coffee
+
+import dagger.Component
+import javax.inject.Singleton
+
+object CoffeeApp {
+ @Singleton
+ @Component(modules = arrayOf(DripCoffeeModule::class))
+ interface Coffee {
+ fun maker(): CoffeeMaker
+ }
+
+ @JvmStatic
+ fun main(args: Array) {
+ val coffee = DaggerCoffeeApp_Coffee.builder().build()
+ coffee.maker().brew()
+ }
+}
diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/CoffeeMaker.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/CoffeeMaker.kt
new file mode 100755
index 00000000000..58e9de6e830
--- /dev/null
+++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/CoffeeMaker.kt
@@ -0,0 +1,17 @@
+package coffee
+
+import dagger.Lazy
+import javax.inject.Inject
+
+class CoffeeMaker @Inject constructor(
+ private val heater: Lazy,
+ private val pump: Pump
+) {
+
+ fun brew() {
+ heater.get().on()
+ pump.pump()
+ println(" [_]P coffee! [_]P ")
+ heater.get().off()
+ }
+}
diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/DripCoffeeModule.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/DripCoffeeModule.kt
new file mode 100755
index 00000000000..a8c1dae2071
--- /dev/null
+++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/DripCoffeeModule.kt
@@ -0,0 +1,13 @@
+package coffee
+
+import dagger.Module
+import dagger.Provides
+import javax.inject.Singleton
+
+@Module(includes = arrayOf(PumpModule::class))
+class DripCoffeeModule {
+ @Provides @Singleton
+ fun provideHeater(): Heater {
+ return ElectricHeater()
+ }
+}
diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/ElectricHeater.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/ElectricHeater.kt
new file mode 100755
index 00000000000..6c1f1586a40
--- /dev/null
+++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/ElectricHeater.kt
@@ -0,0 +1,14 @@
+package coffee
+
+open class ElectricHeater : Heater {
+ override var isHot: Boolean = false
+
+ override fun on() {
+ println("~ ~ ~ heating ~ ~ ~")
+ this.isHot = true
+ }
+
+ override fun off() {
+ this.isHot = false
+ }
+}
diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/Heater.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/Heater.kt
new file mode 100755
index 00000000000..f2ec5dabcc8
--- /dev/null
+++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/Heater.kt
@@ -0,0 +1,7 @@
+package coffee
+
+interface Heater {
+ fun on()
+ fun off()
+ val isHot: Boolean
+}
diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/Pump.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/Pump.kt
new file mode 100755
index 00000000000..5c454538984
--- /dev/null
+++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/Pump.kt
@@ -0,0 +1,5 @@
+package coffee
+
+interface Pump {
+ fun pump()
+}
diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/PumpModule.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/PumpModule.kt
new file mode 100755
index 00000000000..a892e2b7700
--- /dev/null
+++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/PumpModule.kt
@@ -0,0 +1,10 @@
+package coffee
+
+import dagger.Binds
+import dagger.Module
+
+@Module
+abstract class PumpModule {
+ @Binds
+ abstract fun providePump(pump: Thermosiphon): Pump
+}
diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/Thermosiphon.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/Thermosiphon.kt
new file mode 100755
index 00000000000..09c84cff056
--- /dev/null
+++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/main/kotlin/Thermosiphon.kt
@@ -0,0 +1,12 @@
+package coffee
+
+import javax.inject.Inject
+
+class Thermosiphon @Inject
+constructor(private val heater: Heater) : Pump {
+ override fun pump() {
+ if (heater.isHot) {
+ println("=> => pumping => =>")
+ }
+ }
+}
diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/test/kotlin/hello/tests/ExampleTest.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/test/kotlin/hello/tests/ExampleTest.kt
new file mode 100644
index 00000000000..9b3f523e866
--- /dev/null
+++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/src/test/kotlin/hello/tests/ExampleTest.kt
@@ -0,0 +1,39 @@
+package hello.tests
+
+import coffee.*
+import dagger.Component
+import dagger.Module
+import dagger.Provides
+import junit.framework.TestCase
+import javax.inject.Singleton
+
+private var executed = false
+
+class ExampleTest : TestCase() {
+ @Singleton
+ @Component(modules = arrayOf(TestCoffeeModule::class))
+ interface Coffee {
+ fun maker(): CoffeeMaker
+ }
+
+ @Module(includes = arrayOf(PumpModule::class))
+ class TestCoffeeModule {
+ @Provides @Singleton
+ fun provideHeater(): Heater {
+ return object: ElectricHeater() {
+ override fun on() {
+ println("~ psh ~ psh ~ psh ~")
+ println("(from tests)")
+ executed = true
+ super.on()
+ }
+ }
+ }
+ }
+
+ fun testAssert() {
+ val coffee = DaggerExampleTest_Coffee.builder().build()
+ coffee.maker().brew()
+ assert(executed)
+ }
+}
diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/verify.bsh b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/verify.bsh
new file mode 100644
index 00000000000..9171c19b590
--- /dev/null
+++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-kapt-allopen/verify.bsh
@@ -0,0 +1,11 @@
+import java.io.*;
+
+File file = new File(basedir, "target/dagger-maven-example-1.0-SNAPSHOT.jar");
+if (!file.exists() || !file.isFile()) {
+ throw new FileNotFoundException("Could not find generated JAR: " + file);
+}
+
+File generatedFile = new File(baseDir, "target/generated-sources/kapt/compile/coffee/CoffeeMaker_Factory.java");
+if (!generatedFile.exists() || !generatedFile.isFile()) {
+ throw new FileNotFoundException("Kapt was not executed, file is absent: " + generatedFile);
+}
\ No newline at end of file
diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java
index 041b04bdc48..9ba073433e2 100644
--- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java
+++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java
@@ -51,6 +51,8 @@ import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import static org.jetbrains.kotlin.maven.Util.joinArrays;
+
public abstract class KotlinCompileMojoBase extends AbstractMojo {
@Component
protected PlexusContainer container;
@@ -494,7 +496,9 @@ public abstract class KotlinCompileMojoBase e
getLog().debug("Plugin options are: " + Joiner.on(", ").join(pluginArguments));
}
- arguments.setPluginOptions(pluginArguments.toArray(new String[pluginArguments.size()]));
+ arguments.setPluginOptions(joinArrays(
+ arguments.getPluginOptions(),
+ pluginArguments.toArray(new String[pluginArguments.size()])));
}
}
diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/Util.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/Util.java
index 7a7f89d3fab..0d3214cf29d 100644
--- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/Util.java
+++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/Util.java
@@ -16,6 +16,9 @@
package org.jetbrains.kotlin.maven;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
import java.io.File;
import java.util.List;
import java.util.stream.Collectors;
@@ -26,4 +29,21 @@ public class Util {
new File(s).exists() || new File(basedir, s).exists()
).collect(Collectors.toList());
}
+
+ @NotNull
+ public static String[] joinArrays(@Nullable String[] first, @Nullable String[] second) {
+ if (first == null) {
+ first = new String[0];
+ }
+ if (second == null) {
+ second = new String[0];
+ }
+
+ String[] result = new String[first.length + second.length];
+
+ System.arraycopy(first, 0, result, 0, first.length);
+ System.arraycopy(second, 0, result, first.length, second.length);
+
+ return result;
+ }
}
diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/kapt/KaptJVMCompilerMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/kapt/KaptJVMCompilerMojo.java
index d33b369bc2a..be8b64f14e1 100644
--- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/kapt/KaptJVMCompilerMojo.java
+++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/kapt/KaptJVMCompilerMojo.java
@@ -31,6 +31,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
+import static org.jetbrains.kotlin.maven.Util.joinArrays;
import static org.jetbrains.kotlin.maven.kapt.AnnotationProcessingManager.*;
/** @noinspection UnusedDeclaration */
@@ -182,23 +183,6 @@ public class KaptJVMCompilerMojo extends K2JVMCompileMojo {
return result;
}
- @NotNull
- private String[] joinArrays(@Nullable String[] first, @Nullable String[] second) {
- if (first == null) {
- first = new String[0];
- }
- if (second == null) {
- second = new String[0];
- }
-
- String[] result = new String[first.length + second.length];
-
- System.arraycopy(first, 0, result, 0, first.length);
- System.arraycopy(second, 0, result, first.length, second.length);
-
- return result;
- }
-
@Override
protected boolean isIncremental() {
return false;