<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>apimgt</artifactId>
        <groupId>org.wso2.am.choreo.extensions</groupId>
        <version>1.1.37</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>org.wso2.am.choreo.extensions.token.handler</artifactId>
    <packaging>bundle</packaging>

    <dependencies>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
            <artifactId>org.wso2.carbon.identity.oauth</artifactId>
        </dependency>
        <dependency>
            <groupId>io.envoyproxy.protoc-gen-validate</groupId>
            <artifactId>pgv-java-stub</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-protobuf</artifactId>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-stub</artifactId>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-netty-shaded</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.am.choreo.extensions</groupId>
            <artifactId>org.wso2.am.choreo.extensions.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.extension.identity.oauth2.grantType.token.exchange</groupId>
            <artifactId>org.wso2.carbon.identity.oauth2.grant.token.exchange</artifactId>
        </dependency>
    </dependencies>

    <build>
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>${kr.motd.version}</version>
            </extension>
        </extensions>

        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Name>${project.artifactId}</Bundle-Name>
                        <Private-Package>
                            org.wso2.am.choreo.extensions.token.handler.internal,
                            io.grpc.*,
                            io.envoyproxy.*,
                            com.google.protobuf.*,
                            com.google.common.util.concurrent.*,
                            io.perfmark.*,
                        </Private-Package>
                        <Import-Package>
                            org.osgi.framework.*;version="${osgi.framework.version.range}",
                            org.wso2.carbon.identity.openidconnect;version="${carbon.identity.openidconnect.version.range}",
                            org.wso2.carbon.identity.oauth2.grant.token.exchange;version="${oauth2.grant.token.exchange.version.range}",
                            org.wso2.carbon.identity.oauth2.grant.token.exchange.utils;version="${oauth2.grant.token.exchange.version.range}",
                            org.wso2.carbon.identity.oauth2.*;version="${carbon.identity.oauth2.version.range}"
                        </Import-Package>
                        <Export-package>
                            org.wso2.am.choreo.extensions.token.handler.*,
                        </Export-package>
                        <DynamicImport-Package>*</DynamicImport-Package>
                    </instructions>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <configuration>
                    <protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}
                    </protocArtifact>
                </configuration>
                <executions>
                    <execution>
                        <id>protoc-java-pgv</id>
                        <goals>
                            <goal>compile-custom</goal>
                        </goals>
                        <configuration>
                            <pluginParameter>lang=java</pluginParameter>
                            <pluginId>java-pgv</pluginId>
                            <pluginArtifact>
                                io.envoyproxy.protoc-gen-validate:protoc-gen-validate:${pgv.version}:exe:${os.detected.classifier}
                            </pluginArtifact>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

<!--             compile proto file into java files. -->
            <plugin>
                <groupId>com.github.os72</groupId>
                <artifactId>protoc-jar-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <includeMavenTypes>direct</includeMavenTypes>

                            <inputDirectories>
                                <include>src/main/resources</include>
                            </inputDirectories>

                            <outputTargets>
                                <outputTarget>
                                    <type>java</type>
                                    <outputDirectory>src/gen/java</outputDirectory>
                                </outputTarget>
                                <outputTarget>
                                    <type>grpc-java</type>
                                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.15.0</pluginArtifact>
                                    <outputDirectory>src/gen/java</outputDirectory>
                                </outputTarget>
                            </outputTargets>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/gen/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
