<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.opencastproject</groupId>
    <artifactId>base</artifactId>
    <version>8.0</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <properties>
    <checkstyle.skip>true</checkstyle.skip>
    <opencast.basedir>${project.basedir}/..</opencast.basedir>
    <packaging.definition>${opencast.basedir}/assemblies/package.xml</packaging.definition>
  </properties>
  <groupId>org.opencastproject.assemblies</groupId>
  <artifactId>opencast-assemblies</artifactId>
  <packaging>pom</packaging>
  <name>Assemblies</name>
  <profiles>
    <profile>
      <id>dist</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <modules>
        <module>karaf-features</module>
        <module>dist-admin</module>
        <module>dist-adminpresentation</module>
        <module>dist-allinone</module>
        <module>dist-ingest</module>
        <module>dist-presentation</module>
        <module>dist-worker</module>
      </modules>
    </profile>
    <profile>
      <id>dev</id>
      <modules>
        <module>karaf-features</module>
        <module>dist-develop</module>
      </modules>
    </profile>
    <profile>
      <id>none</id>
      <modules/>
    </profile>
  </profiles>
  <build>
    <plugins>
      <!-- Make sure to clean build dir before rebuilding assemblies -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-clean-plugin</artifactId>
        <inherited>false</inherited>
        <configuration>
          <filesets>
            <fileset>
              <directory>${opencast.basedir}/</directory>
              <includes>
                <include>build/</include>
              </includes>
            </fileset>
          </filesets>
        </configuration>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <!-- Make sure to delete old assemblies before rebuilding them -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <configuration>
            <filesets>
              <fileset>
                <directory>${opencast.basedir}/build/</directory>
                <includes>
                  <include>${project.artifactId}-*.tar.gz</include>
                  <include>${project.artifactId}-*/</include>
                </includes>
              </fileset>
            </filesets>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <executions>
            <execution>
              <id>process-resources</id>
              <goals>
                <goal>resources</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.karaf.tooling</groupId>
          <artifactId>karaf-maven-plugin</artifactId>
          <version>${karaf.version}</version>
          <extensions>true</extensions>
          <configuration>
            <libraries>
              <library>xerces-2.11.0.jar;url:="wrap:mvn:xerces/xercesImpl/2.11.0$Export-Package=org.apache.*;version=2.11.0";type:=endorsed;export:=true;delegate:=true</library>
              <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxp-api-1.4/2.8.0;type:=endorsed;export:=true</library>
              <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxb-api-2.2/2.8.0;type:=endorsed;export:=true</library>
              <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxws-api-2.2/2.8.0;type:=endorsed;export:=true</library>
              <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.saaj-api-1.3/2.8.0;type:=endorsed;export:=true</library>
              <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.activation-api-1.1/2.8.0;type:=endorsed;export:=true</library>
              <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.stax-api-1.2/2.8.0;type:=endorsed;export:=true</library>
              <library>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xalan/2.7.2_3;type:=endorsed;export:=true</library>
              <library>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xalan-serializer/2.7.2_1;type:=endorsed;export:=true</library>
              <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.activator/2.8.0;type:=default;export:=true</library>
              <library>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.locator/2.8.0;type:=default;export:=true</library>
            </libraries>
            <archiveZip>false</archiveZip>
            <archiveTarGz>false</archiveTarGz>
            <installedFeatures>
              <feature>opencast-security-cas</feature>
              <feature>opencast-moodle</feature>
              <feature>opencast-sakai</feature>
            </installedFeatures>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-antrun-plugin</artifactId>
          <executions>
            <execution>
              <phase>prepare-package</phase>
              <configuration>
                <target>
                  <!-- Make sure to deactivate JMX by default -->
                  <replaceregexp file="target/assembly/bin/karaf" match="-Dcom.sun.management.jmxremote" replace="" byline="true"/>
                  <!-- Correct the start script name -->
                  <replaceregexp file="target/assembly/bin/karaf" match="^KARAF_SCRIPT=.*$" replace="KARAF_SCRIPT='start-opencast'" byline="true"/>
                  <!-- Mitigation for https://issues.apache.org/jira/browse/KARAF-5526 -->
                  <replaceregexp file="target/assembly/bin/karaf" match=" init$" replace=" [ -z &quot;${TERM##*256color}&quot; ] &amp;&amp; export TERM=xterm-color&#x0A;    init" byline="true"/>
                  <!-- Make sure bundle cache gets cleared by default -->
                  <replaceregexp file="target/assembly/etc/system.properties" match="^karaf.clean.cache .*=.*$" replace="karaf.clean.cache = true" byline="true"/>
                  <!-- Additional config lines to system.properties -->
                  <concat destfile="target/assembly/etc/system.properties" append="true">
                    <filelist dir="../resources" files="system.properties.append"/>
                  </concat>
                  <concat destfile="target/assembly/etc/shell.init.script" append="true">
                    <filelist dir="resources" files="shell.init.script.append"/>
                  </concat>
                  <!-- Adding extra OSGi system packages to configuration -->
                  <replace file="target/assembly/etc/config.properties" token="org.osgi.framework.system.packages= \" value="org.osgi.framework.system.packages= com.sun.image.codec.jpeg, com.sun.jndi.ldap, \"/>
                  <!-- Disabled write permissions on karaf configuration by deactivating config saves -->
                  <replaceregexp file="target/assembly/etc/config.properties" match="^felix.fileinstall.enableConfigSave .*=.*$" replace="felix.fileinstall.enableConfigSave = false" byline="true"/>
                  <!-- Special configuration for development -->
                  <replaceregexp file="target/classes/package.xml" match="tar\.gz" replace="dir" byline="true"/>
                  <replaceregexp file="target/classes/package.xml" match="baseDirectory&gt;.*&lt;/baseDirectory&gt;" replace="includeBaseDirectory&gt;false&lt;/includeBaseDirectory&gt;" byline="true"/>
                </target>
              </configuration>
              <goals>
                <goal>run</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          <executions>
            <execution>
              <phase>package</phase>
              <goals>
                <goal>single</goal>
              </goals>
              <configuration>
                <descriptors>
                  <descriptor>${packaging.definition}</descriptor>
                </descriptors>
                <outputDirectory>${opencast.basedir}/build/</outputDirectory>
                <appendAssemblyId>false</appendAssemblyId>
                <tarLongFileMode>gnu</tarLongFileMode>
                <attach>false</attach>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <executions>
            <execution>
              <id>default-install</id>
              <phase>none</phase>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>
