<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</groupId>
        <artifactId>entaxy-ion-distribution</artifactId>
        <version>1.11.1</version>
    </parent>
    <groupId>ru.entaxy.ion.distribution</groupId>
    <artifactId>entaxy-ion-assembly-dist</artifactId>
    <packaging>pom</packaging>
    <name>ENTAXY :: DISTRIBUTION :: ASSEMBLY</name>
    <description>ENTAXY :: DISTRIBUTION :: ASSEMBLY</description>

    <dependencies>
        <!-- dependency>
            <groupId>ru.entaxy.esb.distribution</groupId>
            <artifactId>entaxy-platform</artifactId>
            <version>${project.version}</version>
            <type>zip</type>
        </dependency -->

        <!-- dependency>
            <groupId>ru.entaxy.esb</groupId>
            <artifactId>entaxy-documentation</artifactId>
            <version>${project.version}</version>
            <type>zip</type>
            <classifier>documentation</classifier>
        </dependency -->

        <dependency>
            <groupId>ru.entaxy.esb</groupId>
            <artifactId>root</artifactId>
            <version>${entaxy.platform.version}</version>
            <type>deps</type>
            <classifier>aggregated</classifier>
        </dependency>
    </dependencies>

    <properties>
        <platform.origin.groupId>ru.entaxy.ion.distribution</platform.origin.groupId>
        <platform.origin.artifactId></platform.origin.artifactId>
        <platform.origin.version>${project.version}</platform.origin.version>
        <platform.origin.type>zip</platform.origin.type>
        <platform.root.folder>${platform.origin.artifactId}</platform.root.folder>

        <assembly.base.directory>entaxy-${platform.origin.version}</assembly.base.directory>
    </properties>

    <profiles>
		
		<profile>
			<id>common-license-info</id>
            <activation>
                <file>
                    <missing>nonexec</missing>
                </file>
            </activation>
			<properties>
				<!-- we can use ${project.organization.name} here, but we won't -->
                <license.organizationName>EmDev LLC</license.organizationName>

                <license.inceptionYear>2020</license.inceptionYear>
                <license.projectName>${project.artifactId}</license.projectName>
                <license.copyrightOwners>${license.organizationName}</license.copyrightOwners>
			</properties>
		</profile>
		<profile>
			<id>open-license</id>
			<activation>
				<property>
					<name>useCommercialLicense</name>
					<value>!true</value>
				</property>
			</activation>
			<properties>
                <license.licenseName>apache_v2</license.licenseName>				
			</properties>
		</profile>
		
        <profile>
            <id>attach-assembly-resouces</id>
            <activation>
                <file>
                    <exists>src/root/NOTICE-KARAF</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-artifacts</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <artifacts>
                                        <artifact>
                                            <file>src/root/NOTICE-KARAF</file>
                                            <type>notice</type>
                                            <classifier>karaf</classifier>
                                        </artifact>
                                        <artifact>
                                            <file>src/assembly/binaries.xml</file>
                                            <type>xml</type>
                                            <classifier>binaries</classifier>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>build-assembly</id>
            <activation>
                <file>
                    <missing>nonexec</missing>
                </file>
            </activation>

            <properties>

                <!-- we can use ${project.organization.name} here, but we won't -->
                <license.organizationName>EmDev LLC</license.organizationName>

                <license.inceptionYear>2020</license.inceptionYear>
                <license.projectName>${project.artifactId}</license.projectName>
                <license.copyrightOwners>${license.organizationName}</license.copyrightOwners>
                <license.licenseName>apache_v2</license.licenseName>

                <license.processStartTag>~~~~~~licensing~~~~~~</license.processStartTag>
                <license.processEndTag>~~~~~~/licensing~~~~~~</license.processEndTag>
                <license.sectionDelimiter>==========</license.sectionDelimiter>
                <license.update.headers.exclude />
            </properties>
            <build>
                <plugins>
                    <!-- @TODO move declaration to root/pom.xml -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack-origins</id>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>${platform.origin.groupId}</groupId>
                                            <artifactId>${platform.origin.artifactId}</artifactId>
                                            <version>${platform.origin.version}</version>
                                            <type>${platform.origin.type}</type>
                                            <outputDirectory>${project.build.directory}/unpacked</outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>ru.entaxy.esb</groupId>
                                            <artifactId>entaxy-documentation</artifactId>
                                            <version>${entaxy.documentation.version}</version>
                                            <type>zip</type>
                                            <classifier>documentation</classifier>
                                            <outputDirectory>${project.build.directory}/documentation</outputDirectory>
                                            <fileMappers>
                                                <org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                                    <pattern>^[^/]*/</pattern>
                                                    <replacement>./</replacement>
                                                </org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                            </fileMappers>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>ru.entaxy.esb</groupId>
                                            <artifactId>camel-documentation</artifactId>
                                            <version>${entaxy.documentation.version}</version>
                                            <type>zip</type>
                                            <classifier>documentation</classifier>
                                            <outputDirectory>${project.build.directory}/camel-documentation</outputDirectory>
                                            <fileMappers>
                                                <org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                                    <pattern>^[^/]*/</pattern>
                                                    <replacement>./</replacement>
                                                </org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                            </fileMappers>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-origins</id>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>ru.entaxy.ion.distribution</groupId>
                                            <artifactId>entaxy-ion-assembly-dist</artifactId>
                                            <version>${project.version}</version>
                                            <type>notice</type>
                                            <classifier>karaf</classifier>
                                            <outputDirectory>${project.build.directory}/unpacked/root</outputDirectory>
                                            <destFileName>NOTICE-KARAF</destFileName>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>ru.entaxy.ion.distribution</groupId>
                                            <artifactId>entaxy-ion-assembly-dist</artifactId>
                                            <version>${project.version}</version>
                                            <type>xml</type>
                                            <classifier>binaries</classifier>
                                            <outputDirectory>${project.build.directory}/unpacked/assembly
                                            </outputDirectory>
                                            <destFileName>binaries.xml</destFileName>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>

                            <!-- execution>
                                <id>unpack-platform</id>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>unpack-dependencies</goal>
                                </goals>
                                <configuration>
                                    <includeArtifactIds>entaxy-ion-platform</includeArtifactIds>
                                    <includeTypes>zip</includeTypes>
                                    <outputDirectory>${project.build.directory}/unpacked</outputDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>unpack-docs</id>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>unpack-dependencies</goal>
                                </goals>
                                <configuration>
                                    <includeArtifactIds>root</includeArtifactIds>
                                    <includeTypes>zip</includeTypes>
                                    <outputDirectory>${project.build.directory}/documentation</outputDirectory>
                                </configuration>
                            </execution-->
                        </executions>
                    </plugin>

                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-override-origins</id>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <copy todir="${project.build.directory}/unpacked/assembly" overwrite="true"
                                              failonerror="false">
                                            <fileset dir="src/assembly">
                                                <include name="**/*"></include>
                                            </fileset>
                                        </copy>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>license-maven-plugin</artifactId>
                        <version>2.0.0</version>
                        <executions>
                            <!-- execution>
                              <id>download-licenses</id>
                              <goals>
                                <goal>download-licenses</goal>
                              </goals>
                            </execution-->

                            <execution>
                                <id>update-project-license</id>
                                <goals>
                                    <goal>update-project-license</goal>
                                </goals>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <organizationName>${license.organizationName}</organizationName>
                                    <inceptionYear>${license.inceptionYear}</inceptionYear>
                                    <projectName>${license.projectName}</projectName>
                                    <copyrightOwners>${license.copyrightOwners}</copyrightOwners>
                                    <licenseName>${license.licenseName}</licenseName>

                                    <licenseFile>${project.build.directory}/generated/LICENSE</licenseFile>

                                    <bundleLicensePath>META-INF/LICENSE</bundleLicensePath>
                                    <generateBundle>true</generateBundle>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <!-- NOTE: We don't need a groupId specification because the group is
                             org.apache.maven.plugins ...which is assumed by default.
                         -->
                        <artifactId>maven-assembly-plugin</artifactId>
                        <version>3.3.0</version>
                        <executions>
                            <execution>
                                <id>assebmly</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <descriptors>
                                        <descriptor>${project.build.directory}/unpacked/assembly/binaries.xml
                                        </descriptor>
                                    </descriptors>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>


        </profile>
        <!--		-->
        <!--		<profile>-->
        <!--			<id>entaxy-assembly-dist-license-configuration</id>-->
        <!--            <activation>-->
        <!--                <property>-->
        <!--                    <name>processLicense</name>-->
        <!--                    <value>true</value>-->
        <!--                </property>-->
        <!--            </activation>-->
        <!--            -->
        <!--            <dependencies>-->
        <!--			  	&lt;!&ndash; -->
        <!--			  		The following is the dependency to 3d-party dependencies list-->
        <!--			  		generated by license-maven-plugin:aggregate-add-third-party-->
        <!--			  		for root project-->
        <!--			  		After migrating /system/* projects to /platform the dependency-->
        <!--			  		should point to platform also-->
        <!--			  	 &ndash;&gt;-->
        <!--			  	<dependency>-->
        <!--			  		<groupId>ru.entaxy.esb</groupId>-->
        <!--			  		<artifactId>root</artifactId>-->
        <!--			  		<version>${entaxy.platform.version}</version>-->
        <!--			  		<type>deps</type>-->
        <!--			  		<classifier>aggregated</classifier>-->
        <!--			  	</dependency>-->
        <!--            </dependencies>-->
        <!--		</profile>-->

    </profiles>

    <modules>
        <module>entaxy-ion-assembly</module>
        <module>entaxy-ion-assembly-with-ui</module>
        <module>entaxy-ion-assembly-compact</module>
    </modules>

</project>
