<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.openpatch</groupId>
    <artifactId>scratch</artifactId>
    <version>4.25.0</version>
    <packaging>jar</packaging>

    <name>Scratch for Java</name>
    <description>Scratch for Java is a Java library that replicates the functionality and concepts of Scratch, helping learners transition from block-based programming to text-based coding in Java. It provides an approachable API inspired by Scratch blocks, making it easier for beginners to understand programming concepts while gaining experience with real Java syntax and tools.</description>
    <url>https://scratch4j.openpatch.org</url>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>https://opensource.org/licenses/MIT</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <id>mikebarkmin</id>
            <name>Mike Barkmin</name>
            <email>mike@barkmin.eu</email>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://github.com/openpatch/scratch-for-java.git</connection>
        <developerConnection>scm:git:ssh://github.com/openpatch/scratch-for-java.git</developerConnection>
        <url>https://github.com/openpatch/scratch-for-java</url>
    </scm>

    <properties>
        <maven.compiler.release>17</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <libs.processing>4.4.10</libs.processing>
        <libs.jackson>2.19.2</libs.jackson>
    </properties>

    <repositories>
        <repository>
            <id>jogamp</id>
            <url>https://jogamp.org/deployment/maven/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.processing</groupId>
            <artifactId>core</artifactId>
            <version>${libs.processing}</version>
        </dependency>
        <dependency>
            <groupId>org.jogamp.jogl</groupId>
            <artifactId>jogl-all-main</artifactId>
            <version>2.5.0</version>
        </dependency>
        <dependency>
            <groupId>org.jogamp.gluegen</groupId>
            <artifactId>gluegen-rt-main</artifactId>
            <version>2.5.0</version>
        </dependency>

        <!-- Jackson -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${libs.jackson}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${libs.jackson}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${libs.jackson}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
            <version>${libs.jackson}</version>
        </dependency>

        <dependency>
            <groupId>com.github.davidmoten</groupId>
            <artifactId>word-wrap</artifactId>
            <version>0.1.13</version>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>central</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.8.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <checksums>required</checksums>
                            <autoPublish>true</autoPublish>
                        </configuration>
                    </plugin>

                </plugins>
            </build>
        </profile>

        <profile>
            <id>all</id>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <version>3.5.0</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>shade</goal>
                                </goals>
                                <configuration>
                                    <createDependencyReducedPom>false</createDependencyReducedPom>
                                    <shadedArtifactAttached>true</shadedArtifactAttached>
                                    <shadedClassifierName>all</shadedClassifierName>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <plugins>
            <!-- Compiler -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>3.14.0</version>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>

            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <excludes>
                        <exclude>demos/**</exclude>
                        <exclude>reference/**</exclude>
                        <exclude>tools/**</exclude>
                    </excludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>add-examples-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/examples/java</source>
                                <source>src/tools/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Javadoc JAR and custom doclet execution (merged into one plugin declaration) -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.8.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                    <!-- Disable default javadoc execution -->
                    <execution>
                        <id>default-cli</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>generate-json-docs</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>javadoc-no-fork</goal>
                        </goals>
                        <configuration>
                            <doclet>doclets.Scratch4JDoclet</doclet>
                            <!-- Use the compiled classes from target/classes -->
                            <docletPath>${project.build.outputDirectory}</docletPath>
                            <outputDirectory>${project.build.directory}/../docs/book/reference</outputDirectory>
                            <useStandardDocletOptions>false</useStandardDocletOptions>
                            <additionalOptions>
                                <additionalOption>-d</additionalOption>
                                <additionalOption>${project.build.directory}/../docs/book/reference</additionalOption>
                            </additionalOptions>
                            <show>public</show>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <tags>
                        <tag>
                            <name>index-in-docs</name>
                            <placement>X</placement>
                            <head>Index in documentation</head>
                        </tag>
                        <tag>
                            <name>name-in-docs</name>
                            <placement>X</placement>
                            <head>Name in documentation</head>
                        </tag>
                        <tag>
                            <name>ignore-in-docs</name>
                            <placement>X</placement>
                            <head>Ignored in documentation</head>
                        </tag>
                        <tag>
                            <name>scratchblock</name>
                            <placement>a</placement>
                            <head>Scratch Block:</head>
                        </tag>
                        <!-- Allow any example.* tag -->
                        <tag>
                            <name>example.preview</name>
                            <placement>X</placement>
                            <head>Example:</head>
                        </tag>
                        <tag>
                            <name>example.folder</name>
                            <placement>X</placement>
                            <head>Example:</head>
                        </tag>
                        <tag>
                            <name>example.files</name>
                            <placement>X</placement>
                            <head>Example:</head>
                        </tag>
                    </tags>
                    <excludePackageNames>
                        demos.*:demos:reference.*:reference,doclets.*:doclets
                    </excludePackageNames>
                    <doclint>all,-missing</doclint>
                </configuration>
            </plugin>

            <!-- Sources JAR -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <excludes>
                        <exclude>demos/**</exclude>
                        <exclude>reference/**</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>**/*.java</exclude> <!-- exclude all Java files -->
                </excludes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/examples/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude> <!-- exclude all Java files -->
                </excludes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>
</project>
