<?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>ov-secure-data-manager</artifactId>
        <groupId>com.scytl.products.ov.sdm</groupId>
        <version>2.1.6</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>secure-data-manager-packaging</artifactId>
    <name>Secure Data Manager Packaging</name>
    <packaging>pom</packaging>

    <properties>        
        <jce.version>8</jce.version>
        <scytl-gmp.version>6.1.1</scytl-gmp.version>
    </properties>

	<dependencyManagement>
		<dependencies>
	        <dependency>
	            <groupId>com.scytl.products.ov.sdm.ui</groupId>
	            <artifactId>sdm-ws-rest</artifactId>
	            <version>${project.version}</version>
	            <type>jar</type>
	        </dependency>
	
	        <dependency>
	            <groupId>com.scytl.products.ov.sdm.frontend</groupId>
	            <artifactId>ov-sdm-frontend</artifactId>
	            <version>${project.version}</version>
	            <type>pom</type>
	        </dependency>
	
	        <dependency>
	            <groupId>com.scytl.products.ov.sdm</groupId>
	            <artifactId>sdm-db-utils</artifactId>
	            <version>${project.version}</version>
	            <type>pom</type>
	        </dependency>
	
	        <dependency>
	            <groupId>com.scytl.products.ov</groupId>
	            <artifactId>mixnet-webapp</artifactId>
	            <version>${project.version}</version>
	            <type>war</type>
	        </dependency>
	
	        <dependency>
	            <groupId>org.bouncycastle</groupId>
	            <artifactId>bcprov-jdk15on</artifactId>
	            <version>${bouncycastle.version}</version>
	        </dependency>
	
	        <dependency>
	            <groupId>com.oracle</groupId>
	            <artifactId>UnlimitedJCEPolicy</artifactId>
	            <version>${jce.version}</version>
	            <type>zip</type>
	        </dependency>
	        
	        <dependency>
	           <groupId>com.scytl.math</groupId>
	           <artifactId>scytl-math</artifactId>
	           <version>${scytl-math.version}</version>
	        </dependency>
	        
	        <dependency>
	           <groupId>com.scytl.math</groupId>
	           <artifactId>scytl-math-native</artifactId>
	           <version>${scytl-math.version}</version>
	           <type>nar</type>
	        </dependency>
	        
	        <dependency>
	           <groupId>com.scytl.gmp</groupId>
	           <artifactId>scytl-gmp</artifactId>
	           <version>${scytl-gmp.version}</version>
	           <type>nar</type>
	        </dependency>
	
	        <dependency>
	            <groupId>com.scytl.products.ov</groupId>
	            <artifactId>config-webapp</artifactId>
	            <version>${project.version}</version>
	            <type>war</type>
	        </dependency>
            
            <dependency>
                <groupId>com.scytl.products.ov</groupId>
                <artifactId>config-engine</artifactId>
                <version>${project.version}</version>
                <type>jar</type>
            </dependency>

	        <dependency>
	            <groupId>com.scytl.products.ov</groupId>
	            <artifactId>tallying-webapp</artifactId>
	            <version>${project.version}</version>
	            <type>war</type>
	        </dependency>
	    </dependencies>	
	</dependencyManagement>

  <dependencies>
        <dependency>
            <groupId>com.scytl.products.ov.sdm.ui</groupId>
            <artifactId>sdm-ws-rest</artifactId>
            <type>jar</type>
        </dependency>

        <dependency>
            <groupId>com.scytl.products.ov.sdm.frontend</groupId>
            <artifactId>ov-sdm-frontend</artifactId>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>com.scytl.products.ov.sdm</groupId>
            <artifactId>sdm-db-utils</artifactId>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>com.scytl.products.ov</groupId>
            <artifactId>mixnet-webapp</artifactId>
            <type>war</type>
        </dependency>

        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk15on</artifactId>
        </dependency>

        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>UnlimitedJCEPolicy</artifactId>
            <type>zip</type>
        </dependency>
        
        <dependency>
           <groupId>com.scytl.math</groupId>
           <artifactId>scytl-math</artifactId>
        </dependency>
        
        <dependency>
           <groupId>com.scytl.math</groupId>
           <artifactId>scytl-math-native</artifactId>
           <type>nar</type>
        </dependency>
        
        <dependency>
           <groupId>com.scytl.gmp</groupId>
           <artifactId>scytl-gmp</artifactId>
           <type>nar</type>
        </dependency>

        <dependency>
            <groupId>com.scytl.products.ov</groupId>
            <artifactId>config-webapp</artifactId>
            <type>war</type>
        </dependency>

        <dependency>
            <groupId>com.scytl.products.ov</groupId>
            <artifactId>config-engine</artifactId>
            <type>jar</type>
        </dependency>
                                
        <dependency>
            <groupId>com.scytl.products.ov</groupId>
            <artifactId>tallying-webapp</artifactId>
            <type>war</type>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.scytl.products.ov.sdm.ui</groupId>
                                    <artifactId>sdm-ws-rest</artifactId>
                                    <type>jar</type>
                                    <outputDirectory>${project.build.directory}/install/sdm/</outputDirectory>
                                    <destFileName>sdm-ws-rest.jar</destFileName>
                                </artifactItem>
                                                                
                                <artifactItem>
                                    <groupId>org.bouncycastle</groupId>
                                    <artifactId>bcprov-jdk15on</artifactId>
                                    <outputDirectory>${project.build.directory}/install/</outputDirectory>
                                    <destFileName>bcprov-jdk15on.jar</destFileName>
                                </artifactItem>
                                
                                <artifactItem>
                                    <groupId>com.scytl.math</groupId>
                                    <artifactId>scytl-math</artifactId>
                                    <outputDirectory>${project.build.directory}/install/scytl-math</outputDirectory>
                                </artifactItem>
                                
                                <artifactItem>
                                    <groupId>com.oracle</groupId>
                                    <artifactId>UnlimitedJCEPolicy</artifactId>
                                    <type>zip</type>
                                    <outputDirectory>${project.build.directory}/install/</outputDirectory>
                                </artifactItem>
                                
                                <artifactItem>
                                    <groupId>com.scytl.products.ov</groupId>
                                    <artifactId>config-webapp</artifactId>
                                    <type>war</type>
                                    <outputDirectory>${project.build.directory}/install/webapps/</outputDirectory>
                                    <destFileName>config-generator.war</destFileName>
                                </artifactItem>

                                <artifactItem>
                                    <groupId>com.scytl.products.ov</groupId>
                                    <artifactId>mixnet-webapp</artifactId>
                                    <type>war</type>
                                    <outputDirectory>${project.build.directory}/install/webapps/</outputDirectory>
                                    <destFileName>mixing.war</destFileName>
                                </artifactItem>

                                <artifactItem>
                                    <groupId>com.scytl.products.ov</groupId>
                                    <artifactId>tallying-webapp</artifactId>
                                    <type>war</type>
                                    <outputDirectory>${project.build.directory}/install/webapps/</outputDirectory>
                                    <destFileName>tallying.war</destFileName>
                                </artifactItem>

                            </artifactItems>
                        </configuration>
                    </execution>

                    <execution>
                        <id>unpack</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.scytl.products.ov</groupId>
                                    <artifactId>config-engine</artifactId>
                                    <type>jar</type>
                                    <outputDirectory>${project.build.directory}/install/unpackedConfigEngine</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.scytl.products.ov.sdm.frontend</groupId>
                                    <artifactId>ov-sdm-frontend</artifactId>
                                    <type>zip</type>
                                    <outputDirectory>${project.build.directory}/install/</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.scytl.products.ov.sdm.ui</groupId>
                                    <artifactId>sdm-ws-rest</artifactId>
                                    <type>zip</type>
                                    <outputDirectory>${project.build.directory}/install/sdm/</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.scytl.products.ov.sdm</groupId>
                                    <artifactId>sdm-db-utils</artifactId>
                                    <type>zip</type>
                                    <outputDirectory>${project.build.directory}/dbutils</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.scytl.math</groupId>
                                    <artifactId>scytl-math-native</artifactId>
                                    <classifier>amd64-Linux-gpp-jni</classifier>
                                    <type>nar</type>
                                    <outputDirectory>${project.build.directory}/install/scytl-math</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.scytl.math</groupId>
                                    <artifactId>scytl-math-native</artifactId>
                                    <classifier>amd64-Windows-gpp-jni</classifier>
                                    <type>nar</type>
                                    <outputDirectory>${project.build.directory}/install/scytl-math</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.scytl.gmp</groupId>
                                    <artifactId>scytl-gmp</artifactId>
                                    <classifier>amd64-Linux-gpp-shared</classifier>
                                    <type>nar</type>
                                    <outputDirectory>${project.build.directory}/install/scytl-math</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.scytl.gmp</groupId>
                                    <artifactId>scytl-gmp</artifactId>
                                    <classifier>amd64-Windows-gpp-shared</classifier>
                                    <type>nar</type>
                                    <outputDirectory>${project.build.directory}/install/scytl-math</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>
                            <target name="building">
                                <!-- LINUX EXEC -->
                                <exec executable="sh" dir="${project.build.directory}" osfamily="unix" failonerror="true">
                                    <arg line="dbutils/bin/createDBTool.sh install/sdm/sdmDB" />
                                </exec>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptor>package.xml</descriptor>
                    <appendAssemblyId>false</appendAssemblyId>
                    <finalName>ov-secure-data-manager-package-${project.version}</finalName>
                </configuration>
                <executions>
                    <execution>
                        <id>create-archive</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

