Skip to content
Snippets Groups Projects
pom.xml 9.41 KiB
Newer Older
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <!-- Major project properties -->
    <groupId>no.uib.inf101.terminal</groupId> <!-- must match package of Main class -->
    <artifactId>INF101ShellLab</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>INF101 Shell Lab</name>
    <packaging>jar</packaging>

    <properties>
        <!-- General project properties -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>17</java.version>

        <!-- Properties required for packaging application as JAR and installer -->
        <app.main.class>${groupId}.Main</app.main.class> <!-- name of main class -->
        <app.vendor>Torstein Strømme</app.vendor> <!-- replace with your name -->
        <app.version>1.0.0</app.version> <!-- version displayed in "about" -->
        <app.installer.macosx.type>dmg</app.installer.macosx.type> <!-- dmg, pkg -->
        <app.installer.windows.type>msi</app.installer.windows.type> <!-- msi, exe -->
        <app.macosx.icon.path>src/main/logo/macosx/logo.icns</app.macosx.icon.path>
        <app.windows.icon.path>src/main/logo/windows/logo.ico</app.windows.icon.path>

        <!-- Library and plugin versions -->
        <junit.version>5.9.1</junit.version>
        <maven.compiler.plugin.version>3.10.1</maven.compiler.plugin.version>
        <maven.dependency.plugin.version>3.4.0</maven.dependency.plugin.version>
        <maven.jar.plugin.version>3.3.0</maven.jar.plugin.version>
        <maven.surefire.plugin.version>3.0.0-M5</maven.surefire.plugin.version>
        <exec.maven.plugin.version>1.6.0</exec.maven.plugin.version>

        <!-- Computed properties -->
        <maven.compiler.release>${java.version}</maven.compiler.release>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <release>${java.version}</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>${maven.dependency.plugin.version}</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>
                                ${project.build.directory}/libs
                            </outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                            <includeScope>compile</includeScope>
                            <includeScope>runtime</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${maven.jar.plugin.version}</version>
                <configuration>
                    <archive>
                        <index>true</index>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>${app.main.class}</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>org.junit.jupiter</groupId>
                        <artifactId>junit-jupiter-engine</artifactId>
                        <version>${junit.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>build-mac</id>
            <activation>
                <os><family>mac</family></os>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>exec-maven-plugin</artifactId>
                        <groupId>org.codehaus.mojo</groupId>
                        <version>${exec.maven.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>Build Native Mac App</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <workingDirectory>${project.basedir}</workingDirectory>
                            <executable>./make/build_app_mac.sh</executable>
                            <environmentVariables>
                                <APP_PACKAGE>${project.groupId}</APP_PACKAGE>
                                <ABOUT_NAME>${project.name}</ABOUT_NAME>
                                <APP_VENDOR>${app.vendor}</APP_VENDOR>
                                <APP_VERSION>${app.version}</APP_VERSION>
                                <ICON_PATH>${app.macosx.icon.path}</ICON_PATH>
                                <INSTALLER_TYPE>${app.installer.macosx.type}</INSTALLER_TYPE>
                                <JAVA_HOME>${java.home}</JAVA_HOME>
                                <JAVA_VERSION>${java.version}</JAVA_VERSION>
                                <MAIN_CLASS>${app.main.class}</MAIN_CLASS>
                                <MAIN_JAR>${project.artifactId}-${project.version}.jar</MAIN_JAR>
                                <PROJECT_NAME>${project.name}</PROJECT_NAME>
                                <PROJECT_VERSION>${project.version}</PROJECT_VERSION>
                            </environmentVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>build-windows</id>
            <activation>
                <os><family>windows</family></os>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>exec-maven-plugin</artifactId>
                        <groupId>org.codehaus.mojo</groupId>
                        <version>${exec.maven.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>Build Native Windows App</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <workingDirectory>${project.basedir}</workingDirectory>
                            <executable>./make/build_app_windows.bat</executable>
                            <environmentVariables>
                                <APP_PACKAGE>${project.groupId}</APP_PACKAGE>
                                <APP_VENDOR>${app.vendor}</APP_VENDOR>
                                <APP_VERSION>${app.version}</APP_VERSION>
                                <ICON_PATH>${app.windows.icon.path}</ICON_PATH>
                                <INSTALLER_TYPE>${app.installer.windows.type}</INSTALLER_TYPE>
                                <JAVA_HOME>${java.home}</JAVA_HOME>
                                <JAVA_VERSION>${java.version}</JAVA_VERSION>
                                <MAIN_JAR>${project.artifactId}-${project.version}.jar</MAIN_JAR>
                                <MAIN_CLASS>${app.main.class}</MAIN_CLASS>
                                <PROJECT_NAME>${project.name}</PROJECT_NAME>
                                <PROJECT_VERSION>${project.version}</PROJECT_VERSION>
                            </environmentVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>