<?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">
    <parent>
        <artifactId>kotlinx-html</artifactId>
        <groupId>org.jetbrains.kotlinx</groupId>
        <version>0.6.8</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.jetbrains.kotlinx</groupId>
    <artifactId>kotlinx-html-js</artifactId>
    <version>0.6.8</version>

    <name>kotlinx.html JS</name>
    <description>kotlinx.html JS implementation</description>

    <licenses>
        <license>
            <name>The Apache License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Sergey Mashkov</name>
            <organization>JetBrains s.r.o.</organization>
            <roles>
                <role>developer</role>
            </roles>
        </developer>
    </developers>
    
    <url>https://github.com/Kotlin/kotlinx.html</url>
    <scm>
        <connection>scm:git:git@github.com:Kotlin/kotlinx.html.git</connection>
        <url>https://github.com/Kotlin/kotlinx.html</url>
        <tag>kotlinx-html-0.6.8</tag>
    </scm>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-js</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlinx</groupId>
            <artifactId>kotlinx-html-common</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-test-js</artifactId>
            <version>${kotlin.version}</version>
            <optional>true</optional>
        </dependency>
    </dependencies>

    <build>
        <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>
                            <moduleKind>umd</moduleKind>
                            <sourceMap>true</sourceMap>
                            <sourceMapEmbedSources>always</sourceMapEmbedSources>
                            <sourceMapPrefix>./</sourceMapPrefix>
                            <outputFile>${project.build.outputDirectory}/${project.artifactId}.js</outputFile>
                            <multiPlatform>true</multiPlatform>
                        </configuration>
                    </execution>
                    <execution>
                        <id>compile-js-tests</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>test-js</goal>
                        </goals>
                        <configuration>
                            <outputFile>${project.basedir}/target/test-js/${project.artifactId}-tests.js</outputFile>
                            <metaInfo>true</metaInfo>
                            <sourceMap>true</sourceMap>
                            <moduleKind>umd</moduleKind>
                            <multiPlatform>true</multiPlatform>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                <execution>
                    <id>add-source</id>
                    <phase>prepare-package</phase>
                    <goals>
                    <goal>add-source</goal>
                    </goals>
                    <configuration>
                    <sources>
                        <source>../shared/src/main/kotlin</source>
                    </sources>
                    </configuration>
                </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <forceCreation>true</forceCreation>
                    <classesDirectory>${project.build.outputDirectory}</classesDirectory>
                    <includes>
                        <include>**/*.js</include>
                        <include>**/*.js.map</include>
                        <include>**/*.kjsm</include>
                        <include>**/*.kotlin_classes</include>
                        <include>**/*.kotlin_string_table</include>
                        <include>**/*.kotlin_file_table</include>
                    </includes>
                    <archive>
                        <forced />
                        <manifestEntries>
                            <Built-By>${user.name}</Built-By>

                            <Implementation-Vendor>JetBrains s.r.o.</Implementation-Vendor>
                            <Implementation-Version>${project.version}</Implementation-Version>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jetbrains.dokka</groupId>
                <artifactId>dokka-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <phase>test-compile</phase>
                        <configuration>
                            <includeScope>test</includeScope>
                            <excludeArtifactIds>kotlinx-html-common</excludeArtifactIds>
                            <includeTypes>jar</includeTypes>
                            <outputDirectory>${project.basedir}/target/test-js</outputDirectory>
                            <includes>*.js</includes>
                            <excludes>*.meta.js</excludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.3</version>

                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <skip>${maven.test.skip}</skip>
                        </configuration>
                    </execution>

                    <execution>
                        <id>npm install</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <!-- Optional configuration which provides for running any npm command -->
                        <configuration>
                            <arguments>install</arguments>
                            <skip>${maven.test.skip}</skip>
                        </configuration>
                    </execution>

                    <execution>
                        <id>javascript tests</id>
                        <goals>
                            <goal>karma</goal>
                        </goals>
                        <configuration>
                            <karmaConfPath>${project.basedir}/src/test/karma/karma.conf.js</karmaConfPath>
                            <skip>${maven.test.skip}</skip>
                            <skipTests>${maven.test.skip}</skipTests>
                        </configuration>
                    </execution>
                </executions>

                <configuration>
                    <nodeVersion>v0.12.17</nodeVersion>
                    <npmVersion>3.10.9</npmVersion>

                    <workingDirectory>${project.basedir}/src/test/karma</workingDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
