<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://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>
  <parent>
    <groupId>com.vaadin</groupId>
    <artifactId>flow-project</artifactId>
    <version>25.0.8</version>
  </parent>
  <groupId>com.vaadin</groupId>
  <artifactId>flow-push</artifactId>
  <version>25.0.8</version>
  <name>Flow Push</name>
  <description>${project.name}</description>
  <licenses>
    <license>
      <name>Apache License Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <properties>
    <pushDirectory>${project.build.outputDirectory}/META-INF/resources/VAADIN/static/push</pushDirectory>
    <vaadinPush.js>${pushDirectory}/vaadinPush.js</vaadinPush.js>
    <vaadinPush-min.js>${pushDirectory}/vaadinPush-min.js</vaadinPush-min.js>
  </properties>
  <dependencies>
    <dependency>
      <groupId>com.vaadin.external.atmosphere</groupId>
      <artifactId>atmosphere-runtime</artifactId>
      <version>3.0.5.slf4jvaadin1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>osgi.core</artifactId>
      <version>7.0.0</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <versionRange>[1.8,)</versionRange>
                    <goals>
                      <goal>run</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore />
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>yuicompressor-maven-plugin</artifactId>
        <version>1.5.1</version>
        <executions>
          <execution>
            <id>minifyjs</id>
            <phase>process-resources</phase>
            <goals>
              <goal>compress</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <sourceDirectory>${pushDirectory}</sourceDirectory>
          <jswarn>false</jswarn>
          <includes>
            <include>vaadinPush.js</include>
          </includes>
          <outputDirectory>${pushDirectory}</outputDirectory>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.9.0</version>
        <executions>
          <execution>
            <id>unpack-atmosphere-js</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.atmosphere.client</groupId>
                  <artifactId>javascript</artifactId>
                  <version>${atmosphere.client.version}</version>
                  <type>war</type>
                  <outputDirectory>${project.build.directory}/temp</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
          <execution>
            <id>unpack-atmosphere-js</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <property name="javascript.unpack" location="${project.build.directory}/temp" />
                <property name="templates.dir" location="${project.build.sourceDirectory}/../templates" />
                <loadfile property="atmosphere.js.contents" srcfile="${javascript.unpack}/javascript/atmosphere.js" />
                <loadfile property="vaadinPush.js.contents" srcfile="${templates.dir}/vaadinPush.js.tpl">
                  <filterchain>
                    <replacetokens begintoken="@" endtoken="@">
                      <token value="${atmosphere.js.contents}" key="atmosphere.js" />
                    </replacetokens>
                  </filterchain>
                </loadfile>
                <echo file="${vaadinPush.js}">${vaadinPush.js.contents}</echo>
              </target>
            </configuration>
          </execution>
          <execution>
            <id>compresspush</id>
            <phase>compile</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <gzip destfile="${vaadinPush.js}.gz" src="${vaadinPush.js}" />
                <gzip destfile="${vaadinPush-min.js}.gz" src="${vaadinPush-min.js}" />
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
            <index>false</index>
            <manifest>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            </manifest>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
