diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 211ffa1a..52b979f9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: Substrate Build on: push: branches: - - master + - '*' pull_request: branches: - master @@ -85,16 +85,16 @@ jobs: - name: Build project run: ./gradlew -i build -x test - - name: Deploy Snapshot - if: runner.os == 'Linux' && github.ref == 'refs/heads/master' - run: ./gradlew publish -PsonatypeUsername=$SONATYPE_USERNAME -PsonatypePassword=$SONATYPE_PASSWORD - env: - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - - - name: Draft release - if: runner.os == 'Linux' && github.ref == 'refs/heads/master' - # Drafts your next Release notes as Pull Requests are merged into "master" - uses: release-drafter/release-drafter@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - name: Deploy Snapshot + # if: runner.os == 'Linux' && github.ref == 'refs/heads/master' + # run: ./gradlew publish -PsonatypeUsername=$SONATYPE_USERNAME -PsonatypePassword=$SONATYPE_PASSWORD + # env: + # SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + # SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + + # - name: Draft release + # if: runner.os == 'Linux' && github.ref == 'refs/heads/master' + # # Drafts your next Release notes as Pull Requests are merged into "master" + # uses: release-drafter/release-drafter@v5 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/gradlew.bat b/gradlew.bat index 15e1ee37..9991c503 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,100 +1,100 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem http://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem http://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/run-tests.bat b/run-tests.bat new file mode 100644 index 00000000..9b7e1383 --- /dev/null +++ b/run-tests.bat @@ -0,0 +1,103 @@ +@echo off + +rem Removing 'out' directory +rmdir /S /Q out + +set JAVAFX_PLATFORM=win +set JAVAFX_VERSION=13.0.1 + +set JAVAFX_STATIC_PLATFORM=win-x86_64 +set JAVAFX_STATIC_VERSION=14-ea+gvm1 + +echo Downloading JavaFX %JAVAFX_VERSION%-%JAVAFX_PLATFORM% jars... +mkdir libs\javafx +for %%j in (base controls graphics) do ( + if not exist libs\javafx\javafx-%%j-%JAVAFX_VERSION%-%JAVAFX_PLATFORM%.jar ( + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get -Dartifact=org.openjfx:javafx-%%j:%JAVAFX_VERSION%:jar:%JAVAFX_PLATFORM% + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy -Dartifact=org.openjfx:javafx-%%j:%JAVAFX_VERSION%:jar:%JAVAFX_PLATFORM% -DoutputDirectory=libs\javafx + ) +) +echo Downloading JavaFX jars completed! + +echo Downloading JavaFX static SDK %JAVAFX_STATIC_VERSION%-%JAVAFX_STATIC_PLATFORM%... +mkdir libs\javafxstatic +if not exist libs\javafxstatic\openjfx-%JAVAFX_STATIC_VERSION%-%JAVAFX_STATIC_PLATFORM%-static.zip ( + powershell -Command "Invoke-WebRequest -OutFile libs\javafxstatic\openjfx-%JAVAFX_STATIC_VERSION%-%JAVAFX_STATIC_PLATFORM%-static.zip https://download2.gluonhq.com/substrate/javafxstaticsdk/openjfx-%JAVAFX_STATIC_VERSION%-%JAVAFX_STATIC_PLATFORM%-static.zip" + tar -xf libs\javafxstatic\openjfx-%JAVAFX_STATIC_VERSION%-%JAVAFX_STATIC_PLATFORM%-static.zip -C libs\javafxstatic +) +echo Downloading JavaFX static SDK completed! + +echo Downloading substrate dependencies... +mkdir libs\substrate +if not exist libs\substrate\dd-plist-1.22.jar ( + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get -Dartifact=com.googlecode.plist:dd-plist:1.22 + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy -Dartifact=com.googlecode.plist:dd-plist:1.22 -DoutputDirectory=libs\substrate +) +if not exist libs\substrate\jnr-ffi-2.1.11.jar ( + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get -Dartifact=com.github.jnr:jnr-ffi:2.1.11 + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy -Dartifact=com.github.jnr:jnr-ffi:2.1.11 -DoutputDirectory=libs\substrate +) +if not exist libs\substrate\bcpkix-jdk15on-1.49.jar ( + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get -Dartifact=org.bouncycastle:bcpkix-jdk15on:1.49 + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy -Dartifact=org.bouncycastle:bcpkix-jdk15on:1.49 -DoutputDirectory=libs\substrate +) +if not exist libs\substrate\bcprov-jdk15on-1.49.jar ( + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get -Dartifact=org.bouncycastle:bcprov-jdk15on:1.49 + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy -Dartifact=org.bouncycastle:bcprov-jdk15on:1.49 -DoutputDirectory=libs\substrate +) +echo Downloading substrate dependencies completed! + +echo Compiling substrate... +set SUBSTRATE_SOURCES= +for /r %%f in (src\main\java\*.java) do ( + set SUBSTRATE_SOURCES=!SUBSTRATE_SOURCES! %%f +) + +set SUBSTRATE_MODULE_PATH= +for /r %%f in (libs\substrate\*.jar) do ( + if "%SUBSTRATE_MODULE_PATH%"=="" ( + set SUBSTRATE_MODULE_PATH=%%f + ) else ( + set SUBSTRATE_MODULE_PATH=%%f;%SUBSTRATE_MODULE_PATH% + ) +) +javac -source 11 -target 11 -d out\substrate -g -proc:none -XDuseUnsharedTable=true --module-path %SUBSTRATE_MODULE_PATH% %SUBSTRATE_SOURCES% +echo Substrate compilation done! + +echo Compiling test HelloWorld... +set TEST_HELLOWORLD_SOURCES= +for /r %%f in (test-project\helloWorld\src\main\java\*.java) do ( + set TEST_HELLOWORLD_SOURCES=!TEST_HELLOWORLD_SOURCES! %%f +) +javac -source 11 -target 11 -d out\helloWorld -g -proc:none -XDuseUnsharedTable=true %TEST_HELLOWORLD_SOURCES% +echo Test HelloWorld compilation done! + +echo Running test HelloWorld... +java -classpath %SUBSTRATE_MODULE_PATH%;out\substrate;src\main\resources ^ + -Dimagecp="%cd%\out\helloWorld" ^ + -Dgraalvm=%GRAALVM_HOME% ^ + -Dmainclass=com.gluonhq.substrate.test.Main ^ + com.gluonhq.substrate.SubstrateDispatcher +echo Test HelloWorld completed + +echo Compiling test HelloFX... +set TEST_HELLOFX_SOURCES= +for /r %%f in (test-project\helloFX\src\main\java\*.java) do ( + set TEST_HELLOFX_SOURCES=!TEST_HELLOFX_SOURCES! %%f +) +set TEST_HELLOFX_MODULE_PATH= +for /r %%f in (libs\javafx\*.jar) do ( + set TEST_HELLOFX_MODULE_PATH=!cd!\%%f;%TEST_HELLOFX_MODULE_PATH% +) +javac -source 11 -target 11 -d out\helloFX -g -proc:none -XDuseUnsharedTable=true --module-path %TEST_HELLOFX_MODULE_PATH% --add-modules javafx.controls %TEST_HELLOFX_SOURCES% +echo Test HelloFX compilation done! + +echo Running test HelloFX... +java -classpath %SUBSTRATE_MODULE_PATH%;out\substrate;src\main\resources ^ + -Dimagecp="%cd%\out\helloFX;%TEST_HELLOFX_MODULE_PATH%" ^ + -Dgraalvm=%GRAALVM_HOME% ^ + -Dmainclass=com.gluonhq.substrate.test.Main ^ + -Djavafxsdk=libs\javafxstatic\sdk ^ + -Dprism.sw=true ^ + com.gluonhq.substrate.SubstrateDispatcher +echo Test HelloFX completed diff --git a/src/main/java/com/gluonhq/substrate/target/AndroidTargetConfiguration.java b/src/main/java/com/gluonhq/substrate/target/AndroidTargetConfiguration.java index da1f7b78..e31aad16 100644 --- a/src/main/java/com/gluonhq/substrate/target/AndroidTargetConfiguration.java +++ b/src/main/java/com/gluonhq/substrate/target/AndroidTargetConfiguration.java @@ -509,7 +509,7 @@ private Path getCapCacheDir() throws IOException { * @return Path of the Android project * @throws IOException */ - private Path prepareAndroidProject() throws IOException { + private Path prepareAndroidProject() throws IOException, InterruptedException { Path androidProject = getAndroidProjectPath(); if (Files.exists(androidProject)) { FileOps.deleteDirectory(androidProject); @@ -518,7 +518,19 @@ private Path prepareAndroidProject() throws IOException { if (!projectConfiguration.hasWeb()) { Files.deleteIfExists(Path.of(androidProject.toString(), "app", "src", "main", "java", "com", "gluonhq", "helloandroid", "NativeWebView.java")); } - androidProject.resolve("gradlew").toFile().setExecutable(true); + Path gradlewPath = androidProject.resolve("gradlew"); + gradlewPath.toFile().setExecutable(true); + + // Run 'dos2unix' on the gradlew file + ProcessBuilder processBuilder = new ProcessBuilder("dos2unix", gradlewPath.toString()); + processBuilder.redirectErrorStream(true); + Process process = processBuilder.start(); + int exitCode = process.waitFor(); + + if (exitCode != 0) { + throw new IOException("Failed to run dos2unix on gradlew. Exit code: " + exitCode); + } + return androidProject; }