KT-2917 maven archetype for kotlin projects

This commit is contained in:
Sergey Mashkov
2015-11-30 20:57:06 +03:00
parent f35dc47b4e
commit 14ca0f4aac
16 changed files with 351 additions and 0 deletions
+2
View File
@@ -82,6 +82,8 @@
<module>tools/kotlin-reflect</module>
<module>tools/kotlin-osgi-bundle</module>
<module>tools/maven-archetypes</module>
<module>tools/binary-compatibility-validator</module>
<!--NB! kotlin-js-library should be built before kotlin-gradle-plugin-->
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-archetypes-parent</artifactId>
<version>0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>org.jetbrains.kotlin</groupId>
<name>kotlin-archetype-js</name>
<description>Kotlin single-module JavaScript project archetype</description>
<artifactId>kotlin-archetype-js</artifactId>
<packaging>maven-archetype</packaging>
</project>
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor
xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
name="kotlin-archetype"
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<fileSets>
<fileSet encoding="UTF-8" filtered="true" packaged="true">
<directory>src/main/kotlin</directory>
<includes>
<include>**/*.kt</include>
</includes>
</fileSet>
<fileSet encoding="UTF-8" filtered="true" packaged="false">
<directory></directory>
<includes>
<include>index.html</include>
</includes>
</fileSet>
</fileSets>
<requiredProperties>
<requiredProperty key="kotlinVersion">
<defaultValue>${project.version}</defaultValue>
</requiredProperty>
</requiredProperties>
</archetype-descriptor>
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Test page</title>
<!-- include kotlin runtime (run mvn package to get it there) -->
<script type="text/javascript" src="target/classes/lib/kotlin.js"></script>
<!-- your compiled script (run mvn compile to get it up to date) -->
<!-- see src/main/kotlin/${packageInPathFormat}/Hello.kt for implementation -->
<script type="text/javascript" src="target/classes/${artifactId}.js"></script>
</head>
<body>
</body>
</html>
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
<packaging>jar</packaging>
<name>${groupId} ${artifactId}</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>${kotlinVersion}</kotlin.version>
<junit.version>4.12</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-js-library</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>js</goal>
</goals>
<configuration>
<sourceMap>true</sourceMap> <!-- source map is useful for debugging in tools that support source maps -->
<outputFile>${project.build.outputDirectory}/${project.artifactId}.js</outputFile>
</configuration>
</execution>
</executions>
</plugin>
<!-- unpack kotlin.js to target/classes/lib for example index.html -->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>extract-kotlinjs</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>kotlin-js-library</includeArtifactIds>
<outputDirectory>${build.outputDirectory}/lib</outputDirectory>
<includes>**\/*.js</includes>
<excludes>**\/*.meta.js</excludes> <!-- we don't need meta.js files in runtime -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,13 @@
package ${package}
import kotlin.browser.window
/**
* Example main function. Started at script body.
* At first time you have to run `mvn package`.
* Open example index.html in browser once you compile it.
*/
fun main(args: Array<String>) {
window.alert("Hello, World!")
}
@@ -0,0 +1,6 @@
#Mon Nov 30 19:53:25 MSK 2015
package=it.pkg
version=0.1-SNAPSHOT
groupId=archetype.it
artifactId=basic
kotlinVersion=0.1-SNAPSHOT
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-archetypes-parent</artifactId>
<version>0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>org.jetbrains.kotlin</groupId>
<name>kotlin-archetype-jvm</name>
<description>Kotlin single-module JVM project archetype</description>
<artifactId>kotlin-archetype-jvm</artifactId>
<packaging>maven-archetype</packaging>
</project>
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor
xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
name="kotlin-archetype"
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<fileSets>
<fileSet encoding="UTF-8" filtered="true" packaged="true">
<directory>src/main/kotlin</directory>
<includes>
<include>**/*.kt</include>
</includes>
</fileSet>
<fileSet encoding="UTF-8" filtered="true" packaged="true">
<directory>src/test/kotlin</directory>
<includes>
<include>**/*.kt</include>
</includes>
</fileSet>
</fileSets>
<requiredProperties>
<requiredProperty key="kotlinVersion">
<defaultValue>${project.version}</defaultValue>
</requiredProperty>
</requiredProperties>
</archetype-descriptor>
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
<packaging>jar</packaging>
<name>${groupId} ${artifactId}</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>${kotlinVersion}</kotlin.version>
<junit.version>4.12</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<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>
</plugins>
</build>
</project>
@@ -0,0 +1,6 @@
package ${package}
fun main(args: Array<String>) {
println("Hello, World")
}
@@ -0,0 +1,8 @@
package ${package}
import org.junit.Test
import kotlin.test.assertEquals
class HelloTest {
}
@@ -0,0 +1,6 @@
#Mon Nov 30 19:53:25 MSK 2015
package=it.pkg
version=0.1-SNAPSHOT
groupId=archetype.it
artifactId=basic
kotlinVersion=0.1-SNAPSHOT
+59
View File
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-project</artifactId>
<version>0.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>org.jetbrains.kotlin</groupId>
<name>kotlin-archetypes</name>
<description>Kotlin archetypes parent</description>
<artifactId>kotlin-archetypes-parent</artifactId>
<packaging>pom</packaging>
<modules>
<module>kotlin-archetype-jvm</module>
<module>kotlin-archetype-js</module>
</modules>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>META-INF/maven/archetype-metadata.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>META-INF/maven/archetype-metadata.xml</exclude>
</excludes>
</resource>
</resources>
<extensions>
<extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
<version>2.4</version>
</extension>
</extensions>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-archetype-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>