<!--
  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

      http://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</groupId>
        <artifactId>apache</artifactId>
        <version>21</version>
    </parent>

    <groupId>com.alipay.sofa</groupId>
    <artifactId>sofa-rpc-compiler</artifactId>
    <version>0.0.3</version>

    <packaging>jar</packaging>

    <properties>
        <maven_compiler_version>3.6.0</maven_compiler_version>
        <maven_jar_version>3.0.2</maven_jar_version>
        <maven_source_version>3.0.1</maven_source_version>
        <maven_javadoc_version>3.0.1</maven_javadoc_version>
        <java_source_version>1.8</java_source_version>
        <java_target_version>1.8</java_target_version>
        <file_encoding>UTF-8</file_encoding>
        <module.deploy.skip>true</module.deploy.skip>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.salesforce.servicelibs</groupId>
            <artifactId>grpc-contrib</artifactId>
            <version>0.8.1</version>
        </dependency>
        <dependency>
            <groupId>com.salesforce.servicelibs</groupId>
            <artifactId>jprotoc</artifactId>
            <version>0.9.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven_compiler_version}</version>
                <configuration>
                    <compilerArgument>-proc:none</compilerArgument>
                    <fork>true</fork>
                    <source>${java_source_version}</source>
                    <target>${java_target_version}</target>
                    <encoding>${file_encoding}</encoding>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${maven_jar_version}</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>com.alipay.sofa.gen.triple.SofaTripleGenerator</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <!-- Optional, used to build directly executable packages (without using 'java -jar'),
            for example 'artifactId-1.0.0-osx-x86_64.exe', 'artifactId-1.0.0-osx-x86_64.exe' -->
            <plugin>
                <groupId>com.salesforce.servicelibs</groupId>
                <artifactId>canteen-maven-plugin</artifactId>
                <version>1.0.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>bootstrap</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.googlecode.maven-java-formatter-plugin</groupId>
                <artifactId>maven-java-formatter-plugin</artifactId>
                <version>0.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>format</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <configFile>${user.dir}/../tools/codestyle/formatter.xml</configFile>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <configuration>
                    <skip>${module.deploy.skip}</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <properties>
                <log4j2_version>2.11.1</log4j2_version>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>${maven_source_version}</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven_javadoc_version}</version>
                        <executions>
                            <execution>
                                <id>attach-javadoc</id>
                                <goals>
                                    <goal>jar</goal>
                                    <goal>aggregate</goal>
                                </goals>
                                <configuration>
                                    <additionalDependencies>
                                        <additionalDependency>
                                            <groupId>org.apache.logging.log4j</groupId>
                                            <artifactId>log4j-api</artifactId>
                                            <version>${log4j2_version}</version>
                                        </additionalDependency>
                                        <additionalDependency>
                                            <groupId>org.apache.logging.log4j</groupId>
                                            <artifactId>log4j-core</artifactId>
                                            <version>${log4j2_version}</version>
                                        </additionalDependency>
                                    </additionalDependencies>
                                </configuration>
                            </execution>
                        </executions>
                        <configuration>
                            <show>public</show>
                            <charset>UTF-8</charset>
                            <encoding>UTF-8</encoding>
                            <docencoding>UTF-8</docencoding>
                            <links>
                                <link>http://docs.oracle.com/javase/8/docs/api</link>
                            </links>
                            <doclint>none</doclint>
                            <excludePackageNames>
                                com.alipay.sofa.demo.*
                            </excludePackageNames>
                            <doctitle>SOFA RPC ${project.version} API</doctitle>
                            <windowtitle>SOFA RPC ${project.version} API</windowtitle>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.7</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>false</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <distributionManagement>
                <snapshotRepository>
                    <id>ossrh</id>
                    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
                </snapshotRepository>
                <repository>
                    <id>ossrh</id>
                    <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
                </repository>
            </distributionManagement>
        </profile>
    </profiles>

    <name>sofa-rpc-compiler</name>
    <description>SOFA RPC Customized GRPC Stub Compiler.</description>
</project>