<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (c) 2021 PANTHEON.tech  s.r.o. All Rights Reserved.

  This program and the accompanying materials are made available under the
  terms of the Eclipse Public License v1.0 which accompanies this distribution,
  and is available at https://www.eclipse.org/legal/epl-v10.html
-->
<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>

    <parent>
        <groupId>io.lighty.core</groupId>
        <artifactId>lighty-parent</artifactId>
        <version>14.3.0</version>
        <relativePath>../lighty-parent</relativePath>
    </parent>

    <!--
        This is a parent suitable for packaging Yang models with their Java v1 bindings.
        The binding-parent from ODL activates too many unimportant plugins.
    -->
    <groupId>io.lighty.core</groupId>
    <artifactId>lighty-binding-parent</artifactId>
    <packaging>pom</packaging>
    <name>${project.groupId}:${project.artifactId}</name>
    <url>https://github.com/PANTHEONtech/lighty</url>

    <properties>
        <salGeneratorPath>target/generated-sources/mdsal-binding</salGeneratorPath>
        <yangFilesPath>src/main/yang</yangFilesPath>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.opendaylight.mdsal</groupId>
            <artifactId>yang-binding</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.spotbugs</groupId>
            <artifactId>spotbugs-annotations</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jdt</groupId>
            <artifactId>org.eclipse.jdt.annotation</artifactId>
            <optional>true</optional>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Yangtools, generate yang -->
            <plugin>
                <groupId>org.opendaylight.yangtools</groupId>
                <artifactId>yang-maven-plugin</artifactId>
                <version>6.0.8</version>
                <dependencies>
                    <dependency>
                        <groupId>org.opendaylight.mdsal</groupId>
                        <artifactId>maven-sal-api-gen-plugin</artifactId>
                        <version>7.0.10</version>
                        <type>jar</type>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>binding</id>
                        <goals>
                            <goal>generate-sources</goal>
                        </goals>
                        <configuration>
                            <yangFilesRootDir>${yangFilesPath}</yangFilesRootDir>
                            <codeGenerators>
                                <generator>
                                    <codeGeneratorClass>org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl</codeGeneratorClass>
                                    <outputBaseDir>${salGeneratorPath}</outputBaseDir>
                                </generator>
                            </codeGenerators>
                            <inspectDependencies>true</inspectDependencies>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>${salGeneratorPath}</directory>
                            <includes>
                                <include>**</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <!-- add generated yang classes to build -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-yang-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${salGeneratorPath}</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
