move maven examples to https://github.com/JetBrains/kotlin-examples
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
# Kotlin hello-world example with maven
|
||||
|
||||
## Prerequisites to running the example
|
||||
|
||||
* download Maven directly from the [Apache Maven homepage](http://maven.apache.org/download.html)
|
||||
* install and configure your system as described in [the installation section](http://maven.apache.org/download.html#Installation)
|
||||
|
||||
## Compiling/Testing/Running the example
|
||||
|
||||
If you have maven on your path, simple type:
|
||||
|
||||
mvn test
|
||||
|
||||
It will compile:
|
||||
* src/main/kotlin/Hello.kt into target/classes/hello/namespace.class
|
||||
* src/main/kotlin/Hello.kt into target/test-classes/hello/tests/HelloTest.class
|
||||
|
||||
Then run tests, and finnaly run your man hello 'namespace'.
|
||||
|
||||
## Only running the example
|
||||
|
||||
Once you compiled the sources with previous 'mvn test' command, you can run the application by typing:
|
||||
|
||||
mvn exec:java
|
||||
|
||||
## Using commandline arguments
|
||||
|
||||
If you want to modify the main method in Hello.kt in order to use commandline arguments, you can specify them on commandline as:
|
||||
|
||||
mvn exec:java -Dexec.args="argument1"
|
||||
@@ -1,95 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.jetbrains.kotlin.examples</groupId>
|
||||
<artifactId>hello-world</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<kotlin.version>0.1-SNAPSHOT</kotlin.version>
|
||||
<junit.version>4.10</junit.version>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${kotlin.version}</version>
|
||||
|
||||
<configuration/>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<mainClass>hello.HelloPackage</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jetbrains-all</id>
|
||||
<url>http://repository.jetbrains.com/all</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>jetbrains-all</id>
|
||||
<url>http://repository.jetbrains.com/all</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
||||
@@ -1,10 +0,0 @@
|
||||
package hello
|
||||
|
||||
public fun getHelloString() : String {
|
||||
return "Hello, world!"
|
||||
}
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
println(getHelloString())
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package hello.tests
|
||||
|
||||
import junit.framework.TestCase
|
||||
import kotlin.test.assertEquals
|
||||
import hello.getHelloString
|
||||
|
||||
class HelloTest : TestCase() {
|
||||
fun testAssert() : Unit {
|
||||
assertEquals("Hello, world!", getHelloString())
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.jetbrains.kotlin.examples</groupId>
|
||||
<artifactId>mixed-code-hello-world</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<kotlin.version>0.1-SNAPSHOT</kotlin.version>
|
||||
<junit.version>4.10</junit.version>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${kotlin.version}</version>
|
||||
|
||||
<configuration/>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>process-test-sources</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jetbrains-all</id>
|
||||
<url>http://repository.jetbrains.com/all</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>jetbrains-all</id>
|
||||
<url>http://repository.jetbrains.com/all</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
||||
@@ -1,14 +0,0 @@
|
||||
package hello;
|
||||
|
||||
public class JavaHello {
|
||||
public static String JavaHelloString = "Hello from Java!";
|
||||
|
||||
public static String getHelloStringFromKotlin() {
|
||||
return HelloPackage.KotlinHelloString;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(getHelloStringFromKotlin());
|
||||
System.out.println(HelloPackage.getHelloStringFromJava());
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package hello
|
||||
|
||||
public val KotlinHelloString : String = "Hello from Kotlin!"
|
||||
|
||||
public fun getHelloStringFromJava() : String {
|
||||
return JavaHello.JavaHelloString!!;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package hello.tests;
|
||||
|
||||
import hello.JavaHello;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class HelloTest extends TestCase {
|
||||
public void testAssert() {
|
||||
assertEquals("Hello from Kotlin!", JavaHello.getHelloStringFromKotlin());
|
||||
assertEquals("Hello from Java!", hello.HelloPackage.getHelloStringFromJava());
|
||||
|
||||
System.out.println(hello.HelloPackage.getHelloStringFromJava());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user