<?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.
    
     SPDX-License-Identifier: Apache-2.0
-->
<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <artifactId>jenax-serviceenhancer-preview</artifactId>
  <name>Service Enhancer Preview</name>
  <description>Experimental plugin that extends the sparql SERVICE clauses with bulk requests, lateral joins and advanced result set caching.</description>

  <parent>
    <groupId>org.aksw.jenax</groupId>
    <artifactId>jenax-parent</artifactId>
    <version>6.1.0-1-SNAPSHOT</version>
  </parent>

  <properties>
    <automatic.module.name>org.aksw.jenax.serviceplugins</automatic.module.name>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.jena</groupId>
      <artifactId>jena-arq</artifactId>
    </dependency>

    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>

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

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j2-impl</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.jena</groupId>
      <artifactId>jena-tdb2</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins> 

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
          <windowtitle>Service Enhancer</windowtitle>
          <doctitle>Service Enhancer ${project.version}</doctitle>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <!-- Profile to build a "plugin jar bundle" that can be loaded with fuseki or any other jena-based app -->
  <profiles>
    <profile>
      <id>bundle</id>
      <dependencies>
        <dependency>
          <groupId>org.apache.jena</groupId>
          <artifactId>jena-arq</artifactId>
          <scope>provided</scope>
        </dependency>
      </dependencies>
      <build>  
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <relocations>
                    <relocation>
                      <pattern>com.google</pattern>
                      <shadedPattern>org.apache.jena.sparql.service.enhancer.shaded.com.google</shadedPattern>
                   </relocation>
                  </relocations>
                  <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
                      <addHeader>false</addHeader>
                    </transformer>
                  </transformers>
                  <filters>
                    <filter>
                      <artifact>*:*</artifact>
                      <excludes>
                        <exclude>META-INF/*.SF</exclude>
                        <exclude>META-INF/*.DSA</exclude>
                        <exclude>META-INF/*.RSA</exclude>
                        <exclude>META-INF/DEPENDENCIES</exclude>
                        <exclude>META-INF/MANIFEST.MF</exclude>
                        <exclude>**/module-info.class</exclude>
                      </excludes>
                    </filter>
                  </filters>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Profile that unpacks the class files from the JAR release of this maven module. -->
    <!-- Use the command below to create a shaded Fuseki-Mod plugin jar from this pom.xml alone. -->
    <!-- The command execution will attempt to download the necessary JAR files and only operate on them. -->
    <!-- The Java source code does not have to be present. -->
    <!-- mvn -Punpack-own-classes,bundle -Dmaven.test.skip package -->
    <profile>
      <id>unpack-own-classes</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>unpack-own-classes</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>${project.groupId}</groupId>
                      <artifactId>${project.artifactId}</artifactId>
                      <version>${project.version}</version>
                      <type>jar</type>
                      <overWrite>false</overWrite>
                      <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                    </artifactItem>
                  </artifactItems>
                  <!-- Skip if classes already exist (normal build with sources) -->
                  <overWriteIfNewer>false</overWriteIfNewer>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
