<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>ru.entaxy.esb.kaoto</groupId>
        <artifactId>kaoto</artifactId>
        <version>2.7.0</version>
    </parent>
    <artifactId>kaoto-ui</artifactId>
    <packaging>war</packaging>
    <name>ENTAXY :: KAOTO :: UI</name>
    <description>ENTAXY :: KAOTO :: UI</description>
    
    
    <properties>
        <kaoto.version>2.7.0.entaxy</kaoto.version>
	    <!-- filtered plugin properties, we don't define plugin-scripts here
			as we build that dynamically using maven-antrun-plugin below. -->
        <!-- plugin-context is what context this plugin will handle requests on
          in the application server -->
        <plugin-context>/kaoto-ui</plugin-context>

        <!-- plugin-name is the name of our plugin, affects the name used for
          the plugin's mbean -->
        <plugin-name>kaoto-ui</plugin-name>

        <!-- plugin-domain is currently unused, we just define it to an empty
          string -->
        <plugin-domain />

        <!-- this lets this plugin deploy nicely into karaf, these get used
          for the ImportPackage directive for maven-bundle-plugin -->
        <bundle.osgi.import.pkg>
            javax.management;resolution:=optional,
            org.slf4j;resolution:=optional;version="[1.7,2)",
            javax.servlet;version="[3.1,4)"
        </bundle.osgi.import.pkg>
	
	    <webapp-dir>${project.artifactId}-${project.version}</webapp-dir>
	    <webapp-outdir>${basedir}/target/ui</webapp-outdir>
	    <schema-outdir>${basedir}/src/main/webapp/lib</schema-outdir>
	    <appjs-outfile>${webapp-outdir}/app/app.js</appjs-outfile>
	
	<!--
	    <angular.version>1.7.9</angular.version>
	-->
	
	  </properties>

    <build>
		<resources>
	      <resource>
	        <directory>src/main/resources</directory>
	        <filtering>true</filtering>
	        <includes>
	          <include>**/*.xml</include>
	        </includes>
	      </resource>
	    </resources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.8.1</version>
                    <executions>
                        <execution>
                            <id>unpack</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                            <configuration>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>ru.entaxy.esb.kaoto</groupId>
                                        <artifactId>kaoto-build</artifactId>
                                        <version>${kaoto.version}</version>
                                        <type>zip</type>
                                        <overWrite>false</overWrite>
                                        <outputDirectory>${project.build.directory}/ui</outputDirectory>
                                    </artifactItem>
                                </artifactItems>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>bundle-manifest</id>
                            <phase>process-classes</phase>
                            <goals>
                                <goal>manifest</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <manifestLocation>${webapp-outdir}/META-INF</manifestLocation>
                        <supportedProjectTypes>
                            <supportedProjectType>jar</supportedProjectType>
                            <supportedProjectType>bundle</supportedProjectType>
                            <supportedProjectType>war</supportedProjectType>
                        </supportedProjectTypes>
                        <instructions>
                            <Webapp-Context>${plugin-context}</Webapp-Context>
                            <Web-ContextPath>${plugin-context}</Web-ContextPath>

                            <Embed-Directory>WEB-INF/lib</Embed-Directory>
                            <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
                            <Embed-Transitive>true</Embed-Transitive>

                            <!-- Export-Package>${osgi.export}</Export-Package>
                            <Import-Package>${osgi.import}</Import-Package>
                            <DynamicImport-Package>${osgi.dynamic}</DynamicImport-Package>
                            <Private-Package>${osgi.private.pkg}</Private-Package -->

                            <Bundle-ClassPath>.,WEB-INF/classes</Bundle-ClassPath>

                            <Bundle-Name>${project.name}</Bundle-Name>
                            <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                            <Implementation-Title>Entaxy</Implementation-Title>
                            <Implementation-Version>${project.version}</Implementation-Version>
                        </instructions>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.3.2</version>
                    <executions>
                        <execution>
                            <id>war</id>
                            <phase>package</phase>
                        </execution>
                    </executions>

                    <configuration>
                        <warName>kaoto-build</warName>
                        <outputFileNameMapping>@{artifactId}@-@{baseVersion}@@{dashClassifier?}@.@{extension}@</outputFileNameMapping>
			          	<packagingExcludes>**/classes/OSGI-INF/**</packagingExcludes>
			          	<failOnMissingWebXml>false</failOnMissingWebXml>
			          	<archive>
			            	<manifestFile>${webapp-outdir}/META-INF/MANIFEST.MF</manifestFile>
			          	</archive>

                        <webResources>
                            <resource>
                                <directory>${webapp-outdir}</directory>
                            </resource>
                        </webResources>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>
