<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.ion.distribution</groupId>
		<artifactId>entaxy-ion-karaf-dist</artifactId>
		<version>1.11.1</version>
	</parent>
	<artifactId>entaxy-ion-karaf-kar</artifactId>
	<packaging>pom</packaging>
	<name>Entaxy :: Distribution :: Karaf :: kar</name>
	<description>Entaxy ready Karaf ${karaf.version} distribution as kar</description>

	<dependencies>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<executions>
					<execution>
						<!-- unpack entaxy-ion-karaf zip distribution as a content for kar -->
						<id>unpack</id>
						<phase>prepare-package</phase>
						<goals>
							<goal>unpack</goal>
						</goals>
						<configuration>
							<artifactItems>
								<artifactItem>
									<groupId>ru.entaxy.ion.distribution</groupId>
									<artifactId>entaxy-ion-karaf</artifactId>
									<version>${project.version}</version>
									<type>zip</type>
									<overWrite>true</overWrite>
									<!-- includes>entaxy-ion-karaf/**.*</includes -->
									<fileMappers>
										<org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
											<pattern>^entaxy-ion-karaf/</pattern>
											<replacement>./</replacement>
										</org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
									</fileMappers>
									<outputDirectory>${project.build.directory}/classes/resources</outputDirectory>
								</artifactItem>
							</artifactItems>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-resources-plugin</artifactId>
				<executions>
					<execution>
						<!-- we need a feature to build distributions based on kar -->
						<id>copy-resources</id>
						<phase>prepare-package</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
			   				<configuration>
			      				<outputDirectory>${basedir}/target/feature</outputDirectory>
							<resources>          
								<resource>
									<directory>src/features</directory>
									<filtering>true</filtering>
								</resource>
							</resources>              
						</configuration>            
					</execution>
			  		</executions>
			</plugin>	    
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<executions>
					<!-- install feature to Maven -->
					<execution>
						<id>attach-artifacts</id>
						<phase>package</phase>
						<goals>
							<goal>attach-artifact</goal>
						</goals>
						<configuration>
							<artifacts>
								<artifact>
									<file>target/feature/feature.xml</file>
									<type>xml</type>
									<classifier>features</classifier>
								</artifact>
							</artifacts>
						</configuration>
					</execution>
				</executions>
			</plugin>		      

			<plugin>
				<groupId>org.apache.karaf.tooling</groupId>
				<artifactId>karaf-maven-plugin</artifactId>
				<extensions>true</extensions>
				<executions>
					<execution>
					<id>package-kar</id>
					<goals>
					<goal>kar</goal>
					</goals>
					</execution>            
				</executions>
		        
				<configuration>
					<enableGeneration>true</enableGeneration>
		            <finalName>${project.artifactId}</finalName>
					<javase>11</javase>
					<generateConsistencyReport>${project.build.directory}</generateConsistencyReport>
					<consistencyReportProjectName>Entaxy Karaf (full)</consistencyReportProjectName>
					<pathPrefix>${project.artifactId}</pathPrefix>
					<usePathPrefix>true</usePathPrefix>
				</configuration>
			</plugin>
		</plugins>
	</build>

</project>
