<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2014 Cisco Systems, Inc. and others.  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 http://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">
  <parent>
    <groupId>org.opendaylight.mdsal</groupId>
    <artifactId>binding-parent</artifactId>
    <version>0.12.2</version>
    <relativePath>../../../..//mdsal/binding/binding-parent</relativePath>
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <groupId>org.opendaylight.controller</groupId>
  <artifactId>config-parent</artifactId>
  <version>0.8.2</version>
  <packaging>pom</packaging>

  <properties>
    <config.version>0.8.2</config.version>
    <mdsal.version>1.7.2</mdsal.version>
    <yangtools.version>2.0.5</yangtools.version>
    <jmxGeneratorPath>${project.build.directory}/generated-sources/config-binding</jmxGeneratorPath>
    <config.file>src/main/config/default-config.xml</config.file>
  </properties>

  <dependencyManagement>
    <dependencies>
      <!-- project specific dependencies -->
      <dependency>
        <groupId>org.opendaylight.controller</groupId>
        <artifactId>config-artifacts</artifactId>
        <version>${config.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.opendaylight.controller</groupId>
        <artifactId>mdsal-artifacts</artifactId>
        <version>${mdsal.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.opendaylight.yangtools</groupId>
        <artifactId>yangtools-artifacts</artifactId>
        <version>${yangtools.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.opendaylight.mdsal</groupId>
        <artifactId>mdsal-artifacts</artifactId>
        <version>2.4.2</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.opendaylight.yangtools</groupId>
      <artifactId>yang-common</artifactId>
    </dependency>
    <dependency>
      <groupId>org.opendaylight.controller</groupId>
      <artifactId>config-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.opendaylight.controller</groupId>
      <artifactId>sal-binding-config</artifactId>
    </dependency>
  </dependencies>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.opendaylight.yangtools</groupId>
          <artifactId>yang-maven-plugin</artifactId>
          <version>${yangtools.version}</version>
          <dependencies>
            <dependency>
              <groupId>org.opendaylight.controller</groupId>
              <artifactId>yang-jmx-generator-plugin</artifactId>
              <version>${config.version}</version>
            </dependency>
          </dependencies>
          <executions>
            <execution>
              <id>config</id>
              <goals>
                <goal>generate-sources</goal>
              </goals>
              <configuration>
                <codeGenerators>
                  <generator>
                    <codeGeneratorClass>org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator</codeGeneratorClass>
                    <outputBaseDir>${jmxGeneratorPath}</outputBaseDir>
                    <additionalConfiguration>
                      <namespaceToPackage1>urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang</namespaceToPackage1>
                    </additionalConfiguration>
                  </generator>
                </codeGenerators>
                <inspectDependencies>true</inspectDependencies>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <configuration>
            <filesets>
              <fileset>
                <directory>${jmxGeneratorPath}</directory>
                <includes>
                  <include>**</include>
                </includes>
              </fileset>
              <fileset>
                <directory>${salGeneratorPath}</directory>
                <includes>
                  <include>**</include>
                </includes>
              </fileset>
            </filesets>
          </configuration>
        </plugin>
        <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>${jmxGeneratorPath}</source>
                  <source>${salGeneratorPath}</source>
                </sources>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <!-- This has to match the definition in odlparent and exists only
             because for some reason PMD does not understand wildcards. -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-pmd-plugin</artifactId>
          <executions>
            <execution>
              <id>cpd</id>
              <phase>process-sources</phase>
              <goals>
                <goal>cpd-check</goal>
              </goals>
              <configuration>
                <excludeRoots>
                  <excludeRoot>${jmxGeneratorPath}</excludeRoot>
                  <excludeRoot>${salGeneratorPath}</excludeRoot>
                </excludeRoots>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
  <profiles>
    <profile>
      <id>attach-config-without-filtering</id>
      <activation>
        <file>
          <exists>${config.file}</exists>
        </file>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>build-helper-maven-plugin</artifactId>
              <executions>
                <execution>
                  <id>attach-artifacts</id>
                  <goals>
                    <goal>attach-artifact</goal>
                  </goals>
                  <phase>package</phase>
                  <configuration>
                    <artifacts>
                      <artifact>
                        <file>${config.file}</file>
                        <type>xml</type>
                        <classifier>config</classifier>
                      </artifact>
                    </artifacts>
                  </configuration>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </pluginManagement>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
