<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>zone.dragon</groupId>
    <artifactId>base-java-pom</artifactId>
    <version>5.0.10</version>
  </parent>
  <groupId>zone.dragon.protobuf</groupId>
  <artifactId>protoc-gen-openapi</artifactId>
  <version>1.0.2</version>
  <properties>
    <maven.compiler.release>8</maven.compiler.release>
    <kotlin.code.style>official</kotlin.code.style>
    <protobuf.version>4.28.2</protobuf.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <guava.version>33.2.1-android</guava.version>
    <protoc-gen-openapi-package>github.com/baharclerode/gnostic/cmd/protoc-gen-openapi@v0.7.1-baharclerode</protoc-gen-openapi-package>
    <gopath>${project.build.directory}/go</gopath>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.errorprone</groupId>
        <artifactId>error_prone_annotations</artifactId>
        <version>2.28.0</version>
      </dependency>
      <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java</artifactId>
        <version>${protobuf.version}</version>
      </dependency>
      <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java-util</artifactId>
        <version>${protobuf.version}</version>
      </dependency>
      <dependency>
        <groupId>com.google.j2objc</groupId>
        <artifactId>j2objc-annotations</artifactId>
        <version>3.0.0</version>
      </dependency>
      <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-protobuf</artifactId>
        <version>1.68.0</version>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-protobuf</artifactId>
    </dependency>
  </dependencies>
  <build>
    <extensions>
      <extension>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>1.7.1</version>
      </extension>
    </extensions>
    <plugins>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <configuration>
          <ignoredUnusedDeclaredDependencies>
            <dependency>io.grpc:grpc-protobuf</dependency>
          </ignoredUnusedDeclaredDependencies>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-enforcer-plugin</artifactId>
        <configuration>
          <rules combine.children="append">
            <requireOS>
              <family>unix</family>
              <arch>amd64</arch>
            </requireOS>
          </rules>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.igormaznitsa</groupId>
        <artifactId>mvn-golang-wrapper</artifactId>
        <version>2.3.10</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>protoc-gen-openapi-windows-amd64</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>install</goal>
            </goals>
            <configuration>
              <targetArch>amd64</targetArch>
              <targetOs>windows</targetOs>
            </configuration>
          </execution>
          <execution>
            <id>protoc-gen-openapi-windows-386</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>install</goal>
            </goals>
            <configuration>
              <targetArch>386</targetArch>
              <targetOs>windows</targetOs>
            </configuration>
          </execution>
          <execution>
            <id>protoc-gen-openapi-linux-amd64</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>install</goal>
            </goals>
            <configuration>
              <targetArch>amd64</targetArch>
              <targetOs>linux</targetOs>
            </configuration>
          </execution>
          <execution>
            <id>protoc-gen-openapi-darwin-amd64</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>install</goal>
            </goals>
            <configuration>
              <targetArch>amd64</targetArch>
              <targetOs>darwin</targetOs>
            </configuration>
          </execution>
          <execution>
            <id>protoc-gen-openapi-darwin-arm64</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>install</goal>
            </goals>
            <configuration>
              <targetArch>arm64</targetArch>
              <targetOs>darwin</targetOs>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <goBin>NONE</goBin>
          <goPath>${gopath}</goPath>
          <sources>${project.basedir}/src/main/go</sources>
          <scanDependencies>false</scanDependencies>
          <buildFlags>
            <flag>-modcacherw</flag>
          </buildFlags>
          <packages>
            <package>${protoc-gen-openapi-package}</package>
          </packages>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.xolstice.maven.plugins</groupId>
        <artifactId>protobuf-maven-plugin</artifactId>
        <version>0.6.1</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>build-java-protos</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>compile</goal>
              <goal>test-compile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <includes>
            <include>openapiv2/**.proto</include>
            <include>openapiv3/**.proto</include>
          </includes>
          <protoSourceRoot>${gopath}/pkg/mod/github.com/google/gnostic@v0.7.0/</protoSourceRoot>
          <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-exe</id>
            <phase>package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <artifacts>
                <artifact>
                  <file>${gopath}/bin/windows_amd64/protoc-gen-openapi.exe</file>
                  <type>exe</type>
                  <classifier>windows-x86_64</classifier>
                </artifact>
                <artifact>
                  <file>${gopath}/bin/windows_386/protoc-gen-openapi.exe</file>
                  <type>exe</type>
                  <classifier>windows-x86_32</classifier>
                </artifact>
                <artifact>
                  <file>${gopath}/bin/darwin_amd64/protoc-gen-openapi</file>
                  <type>exe</type>
                  <classifier>osx-x86_64</classifier>
                </artifact>
                <artifact>
                  <file>${gopath}/bin/darwin_arm64/protoc-gen-openapi</file>
                  <type>exe</type>
                  <classifier>osx-aarch_64</classifier>
                </artifact>
                <artifact>
                  <file>${gopath}/bin/protoc-gen-openapi</file>
                  <type>exe</type>
                  <classifier>linux-x86_64</classifier>
                </artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
