<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.5.7</version>
    <relativePath/>
  </parent>
  <groupId>se.alipsa.lca</groupId>
  <artifactId>local-coding-assistant</artifactId>
  <version>0.5.0</version>
  <packaging>jar</packaging>
  <name>Local Coding Assistant</name>
  <description>The Local Coding assistant is an AI LLM interface based on Ollama and Embabel</description>
  <url>https://github.com/Alipsa/local-coding-assistant</url>
  <licenses>
    <license>
      <name>MIT Licence</name>
      <url>https://raw.githubusercontent.com/Alipsa/local-coding-assistant/refs/heads/main/LICENSE</url>
    </license>
  </licenses>
  <developers>
    <developer>
      <name>Per Nyfelt</name>
      <email>per.nyfelt@alipsa.se</email>
    </developer>
  </developers>
  <scm>
    <url>scm:git@github.com:Alipsa/local-coding-assistant.git</url>
  </scm>
  <properties>
    <java.version>21</java.version>
    <maven.compiler.release>${java.version}</maven.compiler.release>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <embabel-agent.version>0.3.0</embabel-agent.version>
    <extra-enforcer-rules.version>1.11.0</extra-enforcer-rules.version>
    <groovy.version>5.0.3</groovy.version>
    <junit.version>6.0.1</junit.version>
    <playwright.version>1.57.0</playwright.version>
    <spock.version>2.4-groovy-5.0</spock.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>${junit.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <!-- Main Dependencies -->
    <dependency>
      <groupId>com.embabel.agent</groupId>
      <artifactId>embabel-agent-starter</artifactId>
      <version>${embabel-agent.version}</version>
    </dependency>

    <dependency>
      <groupId>com.embabel.agent</groupId>
      <artifactId>embabel-agent-starter-shell</artifactId>
      <version>${embabel-agent.version}</version>
    </dependency>

    <dependency>
      <groupId>com.embabel.agent</groupId>
      <artifactId>embabel-agent-test</artifactId>
      <version>${embabel-agent.version}</version>
      <scope>test</scope>
    </dependency>


    <dependency>
      <groupId>org.apache.groovy</groupId>
      <artifactId>groovy</artifactId>
      <version>${groovy.version}</version>
    </dependency>

    <!--dependency>
      <groupId>org.springframework.ai</groupId>
      <artifactId>spring-ai-ollama-spring-boot-starter</artifactId>
      <version>1.0.0-M6</version>
    </dependency-->
    <dependency>
      <groupId>com.embabel.agent</groupId>
      <artifactId>embabel-agent-starter-ollama</artifactId>
      <version>${embabel-agent.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
      <groupId>com.microsoft.playwright</groupId>
      <artifactId>playwright</artifactId>
      <version>${playwright.version}</version>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <scope>test</scope>
    </dependency>
    <!-- Testing with Spock -->
    <dependency>
      <groupId>org.spockframework</groupId>
      <artifactId>spock-core</artifactId>
      <version>${spock.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.spockframework</groupId>
      <artifactId>spock-spring</artifactId>
      <version>${spock.version}</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>versions-maven-plugin</artifactId>
        <version>2.20.1</version>
        <configuration>
          <ignoredVersions>
            <!-- rules file are not read for plugin updates so add explicitly here -->
            <ignoredVersion>(?i).*[._+-](alpha|b|beta|rc|m|ea|pr).*</ignoredVersion>
          </ignoredVersions>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.6.2</version>
        <executions>
          <execution>
            <id>enforce-releases-maven-java</id>
            <phase>validate</phase>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireMavenVersion>
                  <version>[3.9.9,)</version>
                  <level>ERROR</level>
                  <message>Please use maven version 3.9.9 or higher</message>
                </requireMavenVersion>
                <requireJavaVersion>
                  <version>[${java.version},)</version>
                  <level>ERROR</level>
                  <message>Please use Java &gt;= ${java.version}</message>
                </requireJavaVersion>
              </rules>
            </configuration>
          </execution>
          <execution>
            <id>enforce-bytecode</id>
            <phase>validate</phase>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <enforceBytecodeVersion>
                  <!-- Cap dependencies at JDK 21 -->
                  <maxJdkVersion>${java.version}</maxJdkVersion>
                  <!-- Optional: ignore test scope -->
                  <ignoredScopes>
                    <ignoredScope>test</ignoredScope>
                  </ignoredScopes>
                </enforceBytecodeVersion>
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>extra-enforcer-rules</artifactId>
            <version>${extra-enforcer-rules.version}</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.codehaus.gmavenplus</groupId>
        <artifactId>gmavenplus-plugin</artifactId>
        <version>4.2.1</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>compileTests</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <targetBytecode>${java.version}</targetBytecode>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>properties</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <argLine>
            -javaagent:${org.mockito:mockito-core:jar}
            -Xshare:off
          </argLine>
          <includes>
            <include>**/*Spec.java</include>
            <include>**/*Test.java</include>
          </includes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.4.0</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>3.2.0</version>

        <executions>

          <!-- A) Generate GroovyDoc for package/deploy -->
          <execution>
            <id>groovydoc-generate</id>
            <phase>prepare-package</phase>
            <goals><goal>run</goal></goals>
            <configuration>
              <target name="groovydoc-generate">
                <taskdef name="groovydoc"
                         classname="org.codehaus.groovy.ant.Groovydoc"
                         classpathref="maven.plugin.classpath"/>

                <mkdir dir="${project.build.directory}/groovydoc"/>

                <groovydoc
                    destdir="${project.build.directory}/groovydoc"
                    use="true"
                    private="false"
                    windowtitle="${project.name} ${project.version} API"
                    doctitle="${project.name} ${project.version} API"
                    sourcepath="${project.basedir}/src/main/groovy${path.separator}${project.basedir}/src/main/java"
                />
              </target>
            </configuration>
          </execution>

          <!-- B) Copy GroovyDoc into the site output for mvn site -->
          <execution>
            <id>groovydoc-copy-to-site</id>
            <phase>pre-site</phase>
            <goals><goal>run</goal></goals>
            <configuration>
              <target name="groovydoc-copy-to-site">
                <mkdir dir="${project.reporting.outputDirectory}/groovydoc"/>
                <copy todir="${project.reporting.outputDirectory}/groovydoc" overwrite="true">
                  <fileset dir="${project.build.directory}/groovydoc"/>
                </copy>
              </target>
            </configuration>
          </execution>

        </executions>

        <dependencies>
          <dependency>
            <groupId>org.apache.groovy</groupId>
            <artifactId>groovy</artifactId>
            <version>${groovy.version}</version>
          </dependency>
          <dependency>
            <groupId>org.apache.groovy</groupId>
            <artifactId>groovy-groovydoc</artifactId>
            <version>${groovy.version}</version>
          </dependency>
          <dependency>
            <groupId>org.apache.groovy</groupId>
            <artifactId>groovy-ant</artifactId>
            <version>${groovy.version}</version>
          </dependency>
        </dependencies>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.5.0</version>
        <executions>
          <execution>
            <id>groovydoc-jar</id>
            <phase>package</phase>
            <goals><goal>jar</goal></goals>
            <configuration>
              <classifier>javadoc</classifier>
              <classesDirectory>${project.build.directory}/groovydoc</classesDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.21.0</version>
        <dependencies>
          <dependency>
            <groupId>org.apache.maven.skins</groupId>
            <artifactId>maven-fluido-skin</artifactId>
            <version>2.1.0</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jxr-plugin</artifactId>
        <version>3.6.0</version>
      </plugin>
    </plugins>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>3.9.0</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jxr-plugin</artifactId>
        <version>3.6.0</version>
      </plugin>
    </plugins>
  </reporting>

  <repositories>
    <repository>
      <id>maven-central</id>
      <url>https://repo.maven.apache.org/maven2</url>
    </repository>
    <repository>
      <id>spring-milestones</id>
      <name>Spring Milestones</name>
      <url>https://repo.spring.io/milestone</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>spring-milestones</id>
      <name>Spring Milestones</name>
      <url>https://repo.spring.io/milestone</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>

  <profiles>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.2.8</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
            <version>0.9.0</version>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>central</publishingServerId>
              <autoPublish>true</autoPublish>
              <deploymentName>${project.groupId}:${project.artifactId}:${project.version}</deploymentName>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
