<?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>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <timestamp>${maven.build.timestamp}</timestamp>
        <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'Z</maven.build.timestamp.format>
        <buildNumber></buildNumber>
    </properties>

    <parent>
        <groupId>org.libreccm</groupId>
        <artifactId>libreccm-parent</artifactId>
        <version>7.0.0-SNAPSHOT</version>
    </parent>

    <groupId>org.libreccm</groupId>
    <artifactId>ccm-pagemodelseditor</artifactId>
    <version>7.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>LibreCCM PageModels Editor</name>

    <licenses>
        <license>
            <name>Lesser GPL 2.1</name>
            <url>http://www.gnu.org/licenses/old-licenses/lgpl-2.1</url>
        </license>
    </licenses>

    <build>
        <finalName>ccm-pagemodelseditor</finalName>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>src/main/typescript</directory>
            </resource>
            <resource>
                <directory>${project.build.directory}/generated-resources</directory>
            </resource>
        </resources>

        <plugins>

            <!--<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-remote-resources-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>bundle</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <resourcesDirectory>src/main/typescript</resourcesDirectory>
                    <includes>
                        <include>**/*.ts</include>
                        <include>**/*.tsx</include>
                    </includes>
                </configuration>
            </plugin>-->

            <!--<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>

                <executions>
                    <execution>
                        <id>npm install</id>
                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>npm</executable>
                            <arguments>
                                <argument>install</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm run build</id>
                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>npm</executable>
                            <arguments>
                                <argument>run</argument>
                                <argument>build</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm link</id>
                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>npm</executable>
                            <arguments>
                                <argument>link</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>-->

            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>

                <configuration>
                    <installDirectory>../node</installDirectory>
                </configuration>

                <executions>
                    <execution>
                        <id>Install node.js and NPM</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v16.14.2</nodeVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>install</arguments>
                        </configuration>
                    </execution>
                    <!-- Sync Maven module version and NPM module version -->
                    <execution>
                        <id>npm version</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>version --allow-same-version=true ${project.version}${buildNumber}</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm link</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>link</arguments>
                        </configuration>
                    </execution>
                    
                    <execution>
                        <id>npm publish</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        
                        <phase>deploy</phase>
                        
                        <configuration>
                            <arguments>publish --userconfig ../libreccm.npmrc</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>with-buildnumber</id>
            <activation>
                <property>
                    <name>env.BUILD_NUMBER</name>
                </property>
            </activation>
            <properties>
                <buildNumber>.${env.BUILD_NUMBER}</buildNumber>
            </properties>
        </profile>
    </profiles>

</project>
