<?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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>build.buf</groupId>
    <artifactId>protobuf-javalite</artifactId>
    <version>3.22.2</version>

    <name>protobuf-javalite supplement for use with official protobuf-javalite artifact</name>
    <url>https://github.com/bufbuild/protobuf-javalite</url>
    <description>protobuf-javalite contains additional generated classes for use with the Protobuf Java Lite runtime.</description>

    <developers>
        <developer>
            <id>bufbuild</id>
            <name>Buf</name>
            <email>dev@buf.build</email>
            <url>https://buf.build/</url>
            <organization>Buf Technologies, Inc.</organization>
            <organizationUrl>https://buf.build/</organizationUrl>
        </developer>
    </developers>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <scm>
        <developerConnection>scm:git:https://github.com/bufbuild/protobuf-javalite.git</developerConnection>
        <url>https://github.com/bufbuild/protobuf-javalite</url>
        <tag>v3.22.2</tag>
    </scm>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <buf.version>1.17.0</buf.version>
        <!-- The version of protobuf to target (both protoc and the version of the .proto files). -->
        <protobuf.version>3.22.2</protobuf.version>

        <!-- Directory where generated code is stored. -->
        <output.dir>${project.build.directory}/generated-sources/proto</output.dir>
        <!-- Proto source directory. -->
        <proto.dir>${project.build.directory}/proto</proto.dir>
        <!-- Full path to the buf artifact - needed so we can make it executable. -->
        <buf>${settings.localRepository}/build/buf/buf/${buf.version}/buf-${buf.version}-${os.detected.classifier}.exe</buf>
        <!-- Full path to the protoc artifact - needed so we can make it executable. -->
        <protoc>${settings.localRepository}/com/google/protobuf/protoc/${protobuf.version}/protoc-${protobuf.version}-${os.detected.classifier}.exe</protoc>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.google.protobuf</groupId>
                <artifactId>protobuf-bom</artifactId>
                <version>${protobuf.version}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>com.google.protobuf</groupId>
                <artifactId>protobuf-javalite</artifactId>
                <version>${protobuf.version}</version>
            </dependency>
            <dependency>
                <groupId>com.google.protobuf</groupId>
                <artifactId>protoc</artifactId>
                <version>${protobuf.version}</version>
                <type>exe</type>
                <classifier>${os.detected.classifier}</classifier>
            </dependency>
            <dependency>
                <groupId>build.buf</groupId>
                <artifactId>buf</artifactId>
                <version>${buf.version}</version>
                <type>exe</type>
                <classifier>${os.detected.classifier}</classifier>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-javalite</artifactId>
        </dependency>
        <dependency>
            <groupId>build.buf</groupId>
            <artifactId>buf</artifactId>
            <type>exe</type>
            <classifier>${os.detected.classifier}</classifier>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protoc</artifactId>
            <type>exe</type>
            <classifier>${os.detected.classifier}</classifier>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>${proto.dir}</directory>
            </resource>
        </resources>
        <sourceDirectory>${output.dir}</sourceDirectory>
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>1.7.1</version>
            </extension>
        </extensions>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.5.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.11.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.5.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>3.0.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.5.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>3.0.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.3.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.2.1</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>1.6.13</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>configure-protoc</id>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <phase>initialize</phase>
                        <configuration>
                            <target>
                                <chmod file="${buf}" perm="+x" />
                                <chmod file="${protoc}" perm="+x" />
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <release>8</release>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <!-- Unpack the .proto files to compile from the full protobuf-java artifact. -->
                    <execution>
                        <id>unpack-proto</id>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <phase>initialize</phase>
                        <configuration>
                            <artifact>com.google.protobuf:protobuf-java:${protobuf.version}</artifact>
                            <includes>google/protobuf/descriptor.proto</includes>
                            <outputDirectory>${proto.dir}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <configuration>
                    <releaseProfiles>release</releaseProfiles>
                    <scmCommentPrefix>[skip ci] </scmCommentPrefix>
                    <tagNameFormat>v@{project.version}</tagNameFormat>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-buf-gen-yaml</id>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <phase>initialize</phase>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>${project.basedir}</directory>
                                    <filtering>true</filtering>
                                    <includes>buf.gen.yaml</includes>
                                </resource>
                            </resources>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <!-- Generate Java code for the lite runtime using buf. -->
                    <execution>
                        <id>generate-code</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <executable>${buf}</executable>
                            <arguments>
                                <argument>generate</argument>
                                <argument>--template</argument>
                                <argument>${project.build.directory}/buf.gen.yaml</argument>
                            </arguments>
                            <workingDirectory>${proto.dir}</workingDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>false</autoReleaseAfterClose>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
