<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at
  
  https://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
-->
<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.apache.directory.api</groupId>
    <artifactId>api-ldap-schema-parent</artifactId>
    <version>2.1.2</version>
  </parent>
  
  <artifactId>api-ldap-schema-data</artifactId>
  <name>Apache Directory LDAP API Schema Data</name>

  <description>
    Jar bundled LDIF files containing schema data using the Apache Directory
    specific meta schema for describing schema information using LDAP.  This
    jar can be used by clients as well as by ApacheDS' schema partition.
  </description>

  <dependencies>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>api-i18n</artifactId>
    </dependency>

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>api-ldap-model</artifactId>
    </dependency>

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>api-ldap-extras-aci</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <groupId>org.apache.maven.plugins</groupId>
        <configuration>
          <systemPropertyVariables>
            <workingDirectory>${basedir}/target</workingDirectory>
          </systemPropertyVariables>
          <parallel>all</parallel>
          <threadCount>10</threadCount>
          <properties>
            <configurationParameters>
              junit.jupiter.execution.parallel.enabled=true
            </configurationParameters>
          </properties>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <configuration>
              <target>
                <!-- Various properties -->
                <property name="schema.index" value="target/generated-resources/apacheds/META-INF/apacheds-schema.index" />
                <property name="schema.location" value="src${file.separator}main${file.separator}resources${file.separator}" />
              
                <!-- Listing all LDIF files under schema location -->
                <path id="schema.files.path">
                  <fileset dir="${schema.location}">
                    <include name="**/*.ldif" />
                    <exclude name="schema-all.ldif" />
                  </fileset>
                </path>
                <property name="schema.files" refid="schema.files.path" />
                
                <!-- Creating the schema index file -->
                <echo message="${schema.files}" file="${schema.index}" />
                <replace file="${schema.index}">
                  <!-- Replace the path separator (':' on Unix, ';' on Windows) by a new line -->
                  <replacefilter token="${path.separator}" value="${line.separator}" />
                  <!-- Remove the full path of the schema location to get relative paths for files -->
                  <replacefilter token="${basedir}${file.separator}${schema.location}" value="" />
                  <!-- Replace the file separator ('/' on Unix, '\' on Windows) by a '/' - Useful on Windows -->
                  <replacefilter token="${file.separator}" value="/" />
                </replace>
                
                <attachartifact file="${schema.index}" classifier="schema" type="index" />
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestFile>META-INF/MANIFEST.MF</manifestFile>
            <addMavenDescriptor>false</addMavenDescriptor>
          </archive>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <inherited>true</inherited>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>bundle-manifest</id>
            <phase>process-classes</phase>
            <goals>
              <goal>manifest</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <manifestLocation>META-INF</manifestLocation>
          <instructions>
            <Bundle-SymbolicName>${project.groupId}.ldap.schema</Bundle-SymbolicName>
            <Export-Package>
              org.apache.directory.api.ldap.schema.extractor;version="${project.version}";-noimport:=true,
              org.apache.directory.api.ldap.schema.extractor.impl;version="${project.version}";-noimport:=true,
              org.apache.directory.api.ldap.schema.loader;version="${project.version}";-noimport:=true,
              org.apache.directory.api.ldap.schema.manager.impl;version="${project.version}";-noimport:=true
            </Export-Package>
            <Import-Package>
              org.apache.directory.api.asn1.util;version=${project.version},
              org.apache.directory.api.i18n;version=${project.version},
              org.apache.directory.api.ldap.aci;version=${project.version},
              org.apache.directory.api.ldap.model.constants;version=${project.version},
              org.apache.directory.api.ldap.model.entry;version=${project.version},
              org.apache.directory.api.ldap.model.exception;version=${project.version},
              org.apache.directory.api.ldap.model.ldif;version=${project.version},
              org.apache.directory.api.ldap.model.message;version=${project.version},
              org.apache.directory.api.ldap.model.name;version=${project.version},
              org.apache.directory.api.ldap.model.schema;version=${project.version},
              org.apache.directory.api.ldap.model.schema.comparators;version=${project.version},
              org.apache.directory.api.ldap.model.schema.normalizers;version=${project.version},
              org.apache.directory.api.ldap.model.schema.parsers;version=${project.version},
              org.apache.directory.api.ldap.model.schema.registries;version=${project.version},
              org.apache.directory.api.ldap.model.schema.syntaxCheckers;version=${project.version},
              org.apache.directory.api.util;version=${project.version},
              org.slf4j;version=${slf4j.api.bundleversion}
            </Import-Package>
            <Automatic-Module-Name>apache.directory.ldap.api.schema.data</Automatic-Module-Name>
          </instructions>
        </configuration>
      </plugin>

    </plugins>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
      <resource>
        <directory>target/generated-resources/apacheds</directory>
      </resource>
    </resources>
  </build>
</project>
