diff --git a/libraries/tools/kotlin-maven-plugin/pom.xml b/libraries/tools/kotlin-maven-plugin/pom.xml index d1b41c98d02..2c2b19d64d4 100644 --- a/libraries/tools/kotlin-maven-plugin/pom.xml +++ b/libraries/tools/kotlin-maven-plugin/pom.xml @@ -45,6 +45,12 @@ kotlin-jdk-annotations ${project.version} + + org.codehaus.groovy + groovy-all + 2.4.4 + test + @@ -80,6 +86,29 @@ + + maven-invoker-plugin + 2.0.0 + + ${project.build.directory}/it + src/it/settings.xml + ${project.build.directory}/local-repo + verify + + + + integration-test + + install + run + + + + verify + + + + diff --git a/libraries/tools/kotlin-maven-plugin/src/it/settings.xml b/libraries/tools/kotlin-maven-plugin/src/it/settings.xml new file mode 100644 index 00000000000..4d6edd35ac6 --- /dev/null +++ b/libraries/tools/kotlin-maven-plugin/src/it/settings.xml @@ -0,0 +1,35 @@ + + + + + it-repo + + true + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + \ No newline at end of file diff --git a/libraries/tools/kotlin-maven-plugin/src/it/simple/expected.log b/libraries/tools/kotlin-maven-plugin/src/it/simple/expected.log new file mode 100644 index 00000000000..569766bbdb8 --- /dev/null +++ b/libraries/tools/kotlin-maven-plugin/src/it/simple/expected.log @@ -0,0 +1,9 @@ +[INFO] Kotlin Compiler version @snapshot@ +[INFO] Compiling Kotlin sources from [/src/main/kotlin] +[INFO] Classes directory is /target/classes +[INFO] Classpath: /target/classes +[INFO] Classes directory is /target/classes +[INFO] Using kotlin annotations from /local-repo/org/jetbrains/kotlin/kotlin-jdk-annotations/0.1-SNAPSHOT/kotlin-jdk-annotations-0.1-SNAPSHOT.jar +[INFO] PERF: INIT: Compiler initialized in LLL ms +[INFO] PERF: ANALYZE: 1 files (2 lines) in LLL ms +[INFO] PERF: GENERATE: 1 files (2 lines) in LLL ms \ No newline at end of file diff --git a/libraries/tools/kotlin-maven-plugin/src/it/simple/pom.xml b/libraries/tools/kotlin-maven-plugin/src/it/simple/pom.xml new file mode 100644 index 00000000000..5329d298257 --- /dev/null +++ b/libraries/tools/kotlin-maven-plugin/src/it/simple/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + + test-group + test-project + test-project + 1.0 + + + + junit + junit + 4.12 + test + + + + + + src/main/kotlin + + + + org.jetbrains.kotlin + kotlin-maven-plugin + 0.1-SNAPSHOT + + + + compile + + compile + + + + + + + + \ No newline at end of file diff --git a/libraries/tools/kotlin-maven-plugin/src/it/simple/src/main/kotlin/yo.kt b/libraries/tools/kotlin-maven-plugin/src/it/simple/src/main/kotlin/yo.kt new file mode 100644 index 00000000000..174d4dd3644 --- /dev/null +++ b/libraries/tools/kotlin-maven-plugin/src/it/simple/src/main/kotlin/yo.kt @@ -0,0 +1,2 @@ +fun main(vararg args: String) { +} \ No newline at end of file diff --git a/libraries/tools/kotlin-maven-plugin/src/it/simple/verify.groovy b/libraries/tools/kotlin-maven-plugin/src/it/simple/verify.groovy new file mode 100644 index 00000000000..98249b0f788 --- /dev/null +++ b/libraries/tools/kotlin-maven-plugin/src/it/simple/verify.groovy @@ -0,0 +1,58 @@ +import java.util.regex.Pattern + +class State { + def currentPlugin = "" + def lines = [] +} + +def removePaths(String path, File basedir) { + while (basedir.parentFile != null) { + path = path.replace(basedir.absolutePath, "").replace(basedir.path, "") + basedir = basedir.parentFile + } + + return path +} + +def pattern = Pattern.compile(/\[INFO\] --- ([^:]+):.*:\S+ \([^)]+\) @ test-project ---/) +State state = new File(basedir, "build.log").readLines().inject(new State()) { acc, line -> + def m = pattern.matcher(line) + if (m.find()) { + acc.currentPlugin = m.group(1) + } else if (line.startsWith("[INFO] Downloaded:") || line.startsWith("[INFO] Downloading:")) { + // ignore line + } else if (acc.currentPlugin == "kotlin-maven-plugin") { + def filtered = removePaths(line, basedir).replace("\\", "/").replaceAll(/[0-9]+\s*ms/, "LLL ms").trim().replaceAll(/^\[[A-Z]+\]$/, "") + if (filtered != "") { + acc.lines << filtered + } + } + + acc +} + +def expectedLog = new File(basedir, "expected.log").readLines().join("\n").trim() +def actualLog = state.lines.join("\n").trim() + +if (expectedLog != actualLog) { + println "Expected and actual log differs!" + println "" + + println "Actual log:" + println actualLog + println "" + println "Expected log (from ${new File(basedir, "expected.log").absolutePath}):" + println expectedLog + println "" + return false +} else { + println "Log comparison succeeded" +} + +def classes = new File(basedir, "target/classes").listFiles()?.toList() ?: [] +if (classes.isEmpty()) { + println "No classes were produced" + return false +} + +return true diff --git a/libraries/tools/kotlin-maven-plugin/src/test/java/org/jetbrains/kotlin/maven/MojoTest.java b/libraries/tools/kotlin-maven-plugin/src/test/java/org/jetbrains/kotlin/maven/MojoTest.java deleted file mode 100644 index be60712a176..00000000000 --- a/libraries/tools/kotlin-maven-plugin/src/test/java/org/jetbrains/kotlin/maven/MojoTest.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010-2013 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.kotlin.maven; - -import org.junit.Test; - -public class MojoTest { - @Test - public void dummy() { - - } -}