<?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>dev.digiried</groupId>
  <artifactId>wattpilot4j</artifactId>
  <version>2.2.0</version>

  <name>Wattpilot4j</name>
  <description>Client SDK for Fronius Wattpilot wallboxes</description>
  <url>https://github.com/florian-h05/wattpilot4j</url>

  <licenses>
    <license>
      <name>The Apache License, Version 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>
  <developers>
    <developer>
      <id>florian-h05</id>
      <name>Florian Hotze</name>
      <email>dev@florianhotze.com</email>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git://github.com/florian-h05/wattpilot4j.git</connection>
    <developerConnection>scm:git:ssh://github.com/florian-h05/wattpilot4j.git</developerConnection>
    <tag>v2.2.0</tag>
    <url>https://github.com/florian-h05/wattpilot4j</url>
  </scm>

  <properties>
    <enforcer-plugin.version>3.6.2</enforcer-plugin.version>
    <spotless.version>3.1.0</spotless.version>
    <license-plugin.version>2.7.0</license-plugin.version>
    <java.version>17</java.version>
    <maven.compiler.release>${java.version}</maven.compiler.release>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <slf4j.version>2.0.16</slf4j.version>
    <jetty-version>9.4.57.v20241219</jetty-version>
    <gson-version>2.13.1</gson-version>
  </properties>

  <dependencies>
    <!-- Null Annotations -->
    <dependency>
      <groupId>org.eclipse.jdt</groupId>
      <artifactId>org.eclipse.jdt.annotation</artifactId>
      <version>2.4.0</version>
      <scope>provided</scope>
    </dependency>
    <!-- Logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <!-- WebSocket Client -->
    <dependency>
      <groupId>org.eclipse.jetty.websocket</groupId>
      <artifactId>websocket-client</artifactId>
      <version>${jetty-version}</version>
    </dependency>
    <!-- Gson -->
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>${gson-version}</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <!-- Eclipse Compiler and LastNPE EEA for Null Annotations -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.9.0</version>
        <executions>
          <execution>
            <id>unpack-eea</id>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.lastnpe.eea</groupId>
                  <artifactId>eea-all</artifactId>
                  <version>2.4.0</version>
                  <overWrite>true</overWrite>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.14.1</version>
        <configuration>
          <compilerId>eclipse</compilerId>
          <compilerArgs>
            <arg>-annotationpath</arg>
            <arg>CLASSPATH</arg>
            <arg>-classpath</arg>
            <arg>${project.build.directory}/dependency</arg>
            <arg>-err:+nullAnnot(org.eclipse.jdt.annotation.Nullable|org.eclipse.jdt.annotation.NonNull|org.eclipse.jdt.annotation.NonNullByDefault),+inheritNullAnnot,+nullAnnotConflict,-nullUncheckedConversion</arg>
            <arg>-warn:+null,+inheritNullAnnot,+nullAnnotConflict,-nullUncheckedConversion,+nullAnnotRedundant,+nullDereference,-unused</arg>
          </compilerArgs>
          <showWarnings>true</showWarnings>
          <showDeprecation>true</showDeprecation>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-compiler-eclipse</artifactId>
            <version>2.16.1</version>
          </dependency>
          <dependency>
            <groupId>org.eclipse.jdt</groupId>
            <artifactId>ecj</artifactId>
            <version>3.43.0</version>
          </dependency>
        </dependencies>
      </plugin>
      <!-- BND and JAR Plugin to create OSGi bundle -->
      <plugin>
        <groupId>biz.aQute.bnd</groupId>
        <artifactId>bnd-maven-plugin</artifactId>
        <version>7.1.0</version>
        <executions>
          <execution>
            <goals>
              <goal>bnd-process</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.5.0</version>
        <configuration>
          <archive>
            <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
          </archive>
        </configuration>
      </plugin>
      <!-- Source Plugin to attach sources as JAR -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.3.1</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- JavaDoc Plugin to attach JavaDoc as JAR -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.12.0</version>
        <configuration>
          <doclint>-accessibility,-html,-reference,-syntax</doclint>
        </configuration>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- Assembly Plugin to build an assembly JAR of the shell app -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.7.1</version>
        <configuration>
          <archive>
            <manifest>
              <mainClass>dev.digiried.wattpilot.shell.App</mainClass>
            </manifest>
          </archive>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
      </plugin>
      <!-- Enforcer Plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>${enforcer-plugin.version}</version>
        <executions>
          <execution>
            <id>enforce-java</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireJavaVersion>
                  <version>${java.version}</version>
                </requireJavaVersion>
                <requireMavenVersion>
                  <version>3.9.0</version>
                </requireMavenVersion>
              </rules>
              <failFast>true</failFast>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- Release Plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>3.2.0</version>
        <configuration>
          <pushChanges>false</pushChanges>
          <tagNameFormat>v@{project.version}</tagNameFormat>
          <preparationGoals>clean spotless:apply verify</preparationGoals>
          <completionGoals>spotless:apply</completionGoals>
        </configuration>
      </plugin>
      <!-- Spotless Plugin -->
      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <version>${spotless.version}</version>
        <configuration>
          <formats>
            <!-- you can define as many formats as you want, each is independent -->
            <format>
              <!-- define the files to apply to -->
              <includes>
                <include>.gitattributes</include>
                <include>.gitignore</include>
              </includes>
              <!-- define the steps to apply to those files -->
              <trimTrailingWhitespace/>
              <endWithNewline/>
              <indent>
                <tabs>true</tabs>
                <spacesPerTab>4</spacesPerTab>
              </indent>
            </format>
          </formats>
          <java>
            <googleJavaFormat>
              <version>1.25.2</version>
              <style>AOSP</style>
              <reflowLongStrings>true</reflowLongStrings>
              <formatJavadoc>true</formatJavadoc>
            </googleJavaFormat>

            <importOrder>
              <wildcardsLast>true</wildcardsLast>
              <order>\#dev.digiried.wattpilot,dev.digiried.wattpilot,java|javax|jakarta,\#</order>
              <!-- you can use an empty string for all the imports you didn't specify explicitly, '|' to join group without blank line, and '\#` prefix for static imports. -->
            </importOrder>
          </java>

          <pom>
            <sortPom>
              <expandEmptyElements>false</expandEmptyElements>
              <indentAttribute>schemaLocation</indentAttribute>
              <predefinedSortOrder>recommended_2008_06</predefinedSortOrder>
              <sortDependencyExclusions/>
              <sortDependencyManagement/>
            </sortPom>
          </pom>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>validate</phase>
          </execution>
        </executions>
      </plugin>
      <!-- License Plugin -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <version>${license-plugin.version}</version>
        <configuration>
          <inceptionYear>2025</inceptionYear>
          <licenseName>apache_v2</licenseName>
          <organizationName>Florian Hotze</organizationName>
          <copyrightOwners>Florian Hotze</copyrightOwners>
          <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
          <useJavaNoReformatCommentStartTag>false</useJavaNoReformatCommentStartTag>
          <trimHeaderLine>true</trimHeaderLine>
          <failOnMissingHeader>true</failOnMissingHeader>
          <failOnNotUptodateHeader>true</failOnNotUptodateHeader>

          <roots>
            <root>src/main/java</root>
            <root>src/test/java</root>
          </roots>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>check-file-header</goal>
            </goals>
            <phase>validate</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <!-- Shell App Profile -->
    <profile>
      <id>shell</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>3.6.2</version>
            <configuration>
              <mainClass>dev.digiried.wattpilot.shell.App</mainClass>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>java</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <!-- Shell App GraalVM Native Image Compilation Profile -->
    <profile>
      <id>shell-native</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.graalvm.buildtools</groupId>
            <artifactId>native-maven-plugin</artifactId>
            <version>0.11.0</version>
            <extensions>true</extensions>
            <configuration>
              <mainClass>dev.digiried.wattpilot.shell.App</mainClass>
              <imageName>wattpilotShell</imageName>
              <buildArgs>
                <!-- enables additional compiler optimizations -->
                <buildArg>-O3</buildArg>
              </buildArgs>
            </configuration>
            <executions>
              <execution>
                <id>build-native</id>
                <goals>
                  <goal>compile-no-fork</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <!-- Local GPG Signing Profile -->
    <profile>
      <id>local-sign</id>
      <activation>
        <property>
          <name>local-sign</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.2.8</version>
            <configuration>
              <keyname>${gpg.keyname}</keyname>
              <passphraseServerId>${gpg.keyname}</passphraseServerId>
            </configuration>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <goals>
                  <goal>sign</goal>
                </goals>
                <phase>verify</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <!-- Maven Central Publishing Profile -->
    <profile>
      <id>central</id>
      <activation>
        <property>
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.2.8</version>
            <configuration>
              <keyname>${gpg.keyname}</keyname>
              <passphraseServerId>${gpg.keyname}</passphraseServerId>
            </configuration>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <goals>
                  <goal>sign</goal>
                </goals>
                <phase>verify</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
            <version>0.7.0</version>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>central</publishingServerId>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
