diff --git a/build_app_mac.sh b/make/build_app_mac.sh similarity index 78% rename from build_app_mac.sh rename to make/build_app_mac.sh index 37549e7b316784c9b04611d67d97e430422a2d8a..2755db3b2c0791c265bba7ac2a0a3594d1cf51ec 100755 --- a/build_app_mac.sh +++ b/make/build_app_mac.sh @@ -30,8 +30,11 @@ echo " PROJECT_VERSION: $PROJECT_VERSION" # version in pom, e.g. "1.0-SNAPSHOT" echo "computed variables..." CURRENT_YEAR=$(date +'%Y') echo " CURRENT_YEAR: $CURRENT_YEAR" -PATH_TO_MAIN_CLASS="target/classes/${MAIN_CLASS//'.'//}.class" +#PATH_TO_MAIN_CLASS="target/classes/${MAIN_CLASS//'.'//}.class" +PATH_TO_MAIN_CLASS="target/classes/${APP_PACKAGE//'.'//}/" echo " PATH_TO_MAIN_CLASS: $PATH_TO_MAIN_CLASS" +echo " pwd: " +pwd # ------ SETUP DIRECTORIES AND FILES ---------------------------------------- # Remove previously generated java runtime and installers. Copy all required @@ -54,6 +57,14 @@ cp "target/${MAIN_JAR}" target/installer/input/libs/ ## application. echo "detecting required modules.." +echo "$JAVA_HOME/bin/jdeps" \ + -q \ + --multi-release "${JAVA_VERSION}" \ + --ignore-missing-deps \ + --print-module-deps \ + --class-path "target/installer/input/libs/*" \ + "$PATH_TO_MAIN_CLASS" + detected_modules=$("$JAVA_HOME/bin/jdeps" \ -q \ --multi-release "${JAVA_VERSION}" \ @@ -75,6 +86,14 @@ echo " detected modules: ${detected_modules}" # works with dependencies that are not fully modularized, yet. echo "creating java runtime image..." +echo "$JAVA_HOME/bin/jlink" \ + --strip-native-commands \ + --no-header-files \ + --no-man-pages \ + --compress=2 \ + --strip-debug \ + --add-modules "${detected_modules}" \ + --output target/java-runtime "$JAVA_HOME/bin/jlink" \ --strip-native-commands \ --no-header-files \ @@ -88,6 +107,21 @@ echo "creating java runtime image..." # In the end we will find the package inside the target/installer directory. echo "creating installer of type $INSTALLER_TYPE..." +echo "$JAVA_HOME/bin/jpackage" \ + --type "$INSTALLER_TYPE" \ + --dest target/installer \ + --input target/installer/input/libs \ + --name "${PROJECT_NAME}" \ + --main-class "${MAIN_CLASS}" \ + --main-jar "${MAIN_JAR}" \ + --runtime-image target/java-runtime \ + --icon "${ICON_PATH}" \ + --app-version "${APP_VERSION}" \ + --vendor "${APP_VENDOR}" \ + --copyright "Copyright © ${CURRENT_YEAR} ${APP_VENDOR}." \ + --mac-package-identifier "${APP_PACKAGE}" + # --java-options -Xmx2048m \ + "$JAVA_HOME/bin/jpackage" \ --type "$INSTALLER_TYPE" \ --dest target/installer \ diff --git a/build_app_windows.bat b/make/build_app_windows.bat similarity index 97% rename from build_app_windows.bat rename to make/build_app_windows.bat index 85279e962d8039b8c099cfaf7d105d5960aad05b..fe7c31489fe7d4b8039e47e50f4c1bb86cdea61e 100644 --- a/build_app_windows.bat +++ b/make/build_app_windows.bat @@ -29,7 +29,8 @@ ECHO " PROJECT_NAME: %PROJECT_NAME%" ECHO " PROJECT_VERSION: %PROJECT_VERSION%" ECHO "computed variables..." -SET PATH_TO_MAIN="target\classes\%MAIN_CLASS:.=\%.class" +@REM SET PATH_TO_MAIN="target\classes\%MAIN_CLASS:.=\%.class" +SET PATH_TO_MAIN="target\classes\%APP_PACKAGE:.=\%" ECHO " PATH_TO_MAIN: %PATH_TO_MAIN%" SET YEAR=%DATE:~6,4% ECHO " YEAR: %YEAR%" diff --git a/pom.xml b/pom.xml index bde6d04910e536eabdf8b43ec9060bb376fe897f..089deacd7bc058a3afe031e0687207ccc2cf6c58 100644 --- a/pom.xml +++ b/pom.xml @@ -5,10 +5,10 @@ <modelVersion>4.0.0</modelVersion> <!-- Major project properties --> - <groupId>no.uib.inf101.app</groupId> - <artifactId>SamplePackagedSwingApp</artifactId> + <groupId>no.uib.inf101.terminal</groupId> <!-- must match package of Main class --> + <artifactId>INF101ShellLab</artifactId> <version>1.0-SNAPSHOT</version> - <name>Sample Application</name> + <name>INF101 Shell Lab</name> <packaging>jar</packaging> <properties> @@ -17,8 +17,8 @@ <java.version>17</java.version> <!-- Properties required for packaging application as JAR and installer --> - <app.main.class>no.uib.inf101.terminal.Main</app.main.class> - <app.vendor>Torstein Strømme</app.vendor> <!-- copyright holder --> + <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 --> @@ -30,6 +30,7 @@ <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 --> @@ -99,6 +100,17 @@ </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> @@ -125,7 +137,7 @@ </executions> <configuration> <workingDirectory>${project.basedir}</workingDirectory> - <executable>./build_app_mac.sh</executable> + <executable>./make/build_app_mac.sh</executable> <environmentVariables> <APP_PACKAGE>${project.groupId}</APP_PACKAGE> <ABOUT_NAME>${project.name}</ABOUT_NAME> @@ -168,7 +180,7 @@ </executions> <configuration> <workingDirectory>${project.basedir}</workingDirectory> - <executable>build_app_windows.bat</executable> + <executable>./make/build_app_windows.bat</executable> <environmentVariables> <APP_PACKAGE>${project.groupId}</APP_PACKAGE> <APP_VENDOR>${app.vendor}</APP_VENDOR> diff --git a/src/main/java/no/uib/inf101/terminal/TextAnswers.java b/src/main/java/no/uib/inf101/terminal/TextAnswers.java index 30a6bc2a9e0b6dd506c2a522b116053d7fd658da..9f6e148466569e47f80dc19ecea4da885379a728 100644 --- a/src/main/java/no/uib/inf101/terminal/TextAnswers.java +++ b/src/main/java/no/uib/inf101/terminal/TextAnswers.java @@ -13,7 +13,7 @@ public class TextAnswers { /** In which class is the object cli refers to? */ static final String q2 = ""; - /** True or false: CommandLineInterface is both a type and interface. */ + /** True or false: CommandLineInterface is both a type and an interface. */ static final Boolean q3 = null; /** True or false: DummyShell is both a class and a type. */ diff --git a/src/test/java/no/uib/inf101/terminal/TestSimpleShellEcho.java b/src/test/java/no/uib/inf101/terminal/TestSimpleShellEcho.java index 92246e09ab76c202b7345297d79f2a6ec467c7a2..1783ebbe469a937dedc030f4679505054c5a6130 100644 --- a/src/test/java/no/uib/inf101/terminal/TestSimpleShellEcho.java +++ b/src/test/java/no/uib/inf101/terminal/TestSimpleShellEcho.java @@ -30,7 +30,7 @@ public class TestSimpleShellEcho { // shell.keyPressed('r'); // shell.keyPressed('\n'); // -// String expected = "$ echo foo bar \nfoo bar \n$ "; +// String expected = "$ echo foo bar\nfoo bar \n$ "; // assertEquals(expected, shell.getScreenContent()); // } }