Repository: calcite
Updated Branches:
  refs/heads/master 6770e2b21 -> 55d86646f


[CALCITE-2458] Add Kotlin as a test dependency


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/55d86646
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/55d86646
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/55d86646

Branch: refs/heads/master
Commit: 55d86646fe598d215bd53dbeac2bbbf32a9506f9
Parents: 6770e2b
Author: Vladimir Sitnikov <[email protected]>
Authored: Thu Aug 9 22:20:38 2018 +0300
Committer: Vladimir Sitnikov <[email protected]>
Committed: Tue Sep 25 00:21:48 2018 +0300

----------------------------------------------------------------------
 core/pom.xml                                    | 50 ++++++++++++++++
 .../org/apache/calcite/test/CalciteSuite.java   |  2 +
 .../kotlin/org/apache/calcite/TestKtTest.kt     | 13 ++++
 pom.xml                                         | 63 ++++++++++++++++++++
 4 files changed, 128 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/55d86646/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 3410e37..86c384d 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -106,6 +106,21 @@ limitations under the License.
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.jetbrains.kotlin</groupId>
+      <artifactId>kotlin-stdlib</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jetbrains.kotlin</groupId>
+      <artifactId>kotlin-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jetbrains.kotlin</groupId>
+      <artifactId>kotlin-test-junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>mysql</groupId>
       <artifactId>mysql-connector-java</artifactId>
       <scope>test</scope>
@@ -211,8 +226,43 @@ limitations under the License.
         </executions>
       </plugin>
       <plugin>
+        <groupId>org.jetbrains.kotlin</groupId>
+        <artifactId>kotlin-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
+        <!-- 
http://kotlinlang.org/docs/reference/using-maven.html#compiling-kotlin-and-java-sources
+             Ensure kotlin-compile comes before maven-compiler-plugin, so 
Kotlin files
+             can be used in Java code (this especially important so 
CalciteSuite.java
+             can include Kotlin tests as well)
+         -->
+        <executions>
+          <!-- Replacing default-compile as it is treated specially by maven 
-->
+          <execution>
+            <id>default-compile</id>
+            <phase>none</phase>
+          </execution>
+          <!-- Replacing default-testCompile as it is treated specially by 
maven -->
+          <execution>
+            <id>default-testCompile</id>
+            <phase>none</phase>
+          </execution>
+          <execution>
+            <id>java-compile</id>
+            <phase>compile</phase>
+            <goals>
+              <goal>compile</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>java-test-compile</id>
+            <phase>test-compile</phase>
+            <goals>
+              <goal>testCompile</goal>
+            </goals>
+          </execution>
+        </executions>
         <configuration>
           <source>8</source>
           <target>8</target>

http://git-wip-us.apache.org/repos/asf/calcite/blob/55d86646/core/src/test/java/org/apache/calcite/test/CalciteSuite.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/CalciteSuite.java 
b/core/src/test/java/org/apache/calcite/test/CalciteSuite.java
index 2c16620..27c7b1b 100644
--- a/core/src/test/java/org/apache/calcite/test/CalciteSuite.java
+++ b/core/src/test/java/org/apache/calcite/test/CalciteSuite.java
@@ -16,6 +16,7 @@
  */
 package org.apache.calcite.test;
 
+import org.apache.calcite.TestKtTest;
 import org.apache.calcite.adapter.clone.ArrayTableTest;
 import org.apache.calcite.jdbc.CalciteRemoteDriverTest;
 import org.apache.calcite.plan.RelOptPlanReaderTest;
@@ -81,6 +82,7 @@ import org.junit.runners.Suite;
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
     // very fast tests (under 0.1s)
+    TestKtTest.class,
     ArrayTableTest.class,
     BitSetsTest.class,
     ImmutableBitSetTest.class,

http://git-wip-us.apache.org/repos/asf/calcite/blob/55d86646/core/src/test/kotlin/org/apache/calcite/TestKtTest.kt
----------------------------------------------------------------------
diff --git a/core/src/test/kotlin/org/apache/calcite/TestKtTest.kt 
b/core/src/test/kotlin/org/apache/calcite/TestKtTest.kt
new file mode 100644
index 0000000..7d8e4fa
--- /dev/null
+++ b/core/src/test/kotlin/org/apache/calcite/TestKtTest.kt
@@ -0,0 +1,13 @@
+package org.apache.calcite
+
+import org.junit.Test
+import kotlin.test.assertEquals
+import kotlin.test.junit.JUnitAsserter
+
+class TestKtTest {
+    @Test
+    fun `a test to verify how Kotlin test passes in CI`() {
+        JUnitAsserter.hashCode() // make maven-dependency-plugin happy
+        assertEquals("Hello, world", "Hello, world", message = "42")
+    }
+}

http://git-wip-us.apache.org/repos/asf/calcite/blob/55d86646/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 3ab3658..3e3e249 100644
--- a/pom.xml
+++ b/pom.xml
@@ -106,6 +106,7 @@ limitations under the License.
     <jmh.version>1.12</jmh.version>
     <jsoup.version>1.11.3</jsoup.version>
     <junit.version>4.12</junit.version>
+    <kotlin.version>1.2.71</kotlin.version>
     <checkstyle.version>7.8.2</checkstyle.version>
     <maven-checkstyle-plugin.version>3.0.0</maven-checkstyle-plugin.version>
     <maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version>
@@ -249,6 +250,30 @@ limitations under the License.
         <version>${cassandra.version}</version>
       </dependency>
       <dependency>
+        <groupId>org.jetbrains.kotlin</groupId>
+        <artifactId>kotlin-stdlib</artifactId>
+        <version>${kotlin.version}</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.jetbrains.kotlin</groupId>
+        <artifactId>kotlin-stdlib-jdk8</artifactId>
+        <version>${kotlin.version}</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.jetbrains.kotlin</groupId>
+        <artifactId>kotlin-test</artifactId>
+        <version>${kotlin.version}</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.jetbrains.kotlin</groupId>
+        <artifactId>kotlin-test-junit</artifactId>
+        <version>${kotlin.version}</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
         <groupId>com.esri.geometry</groupId>
         <artifactId>esri-geometry-api</artifactId>
         <version>${esri-geometry-api.version}</version>
@@ -980,6 +1005,44 @@ limitations under the License.
           <artifactId>git-commit-id-plugin</artifactId>
           <version>${git-commit-id-plugin.version}</version>
         </plugin>
+        <plugin>
+          <groupId>org.jetbrains.kotlin</groupId>
+          <artifactId>kotlin-maven-plugin</artifactId>
+          <version>${kotlin.version}</version>
+          <executions>
+            <!-- Kotlin is supposed to be used in test code only for now,
+                 that is why compile execution is commented. -->
+            <!--<execution>
+              <id>compile</id>
+              <phase>compile</phase>
+              <goals>
+                <goal>compile</goal>
+              </goals>
+              <configuration>
+                <sourceDirs>
+                  <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
+                  <sourceDir>${project.basedir}/src/main/java</sourceDir>
+                </sourceDirs>
+              </configuration>
+            </execution>-->
+            <execution>
+              <id>test-compile</id>
+              <phase>test-compile</phase>
+              <goals>
+                <goal>test-compile</goal>
+              </goals>
+              <configuration>
+                <sourceDirs>
+                  <sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
+                  <sourceDir>${project.basedir}/src/test/java</sourceDir>
+                </sourceDirs>
+              </configuration>
+            </execution>
+          </executions>
+          <configuration>
+            <jvmTarget>1.8</jvmTarget>
+          </configuration>
+        </plugin>
       </plugins>
     </pluginManagement>
   </build>

Reply via email to