-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3034 from 1c-syntax/bugfix/issue-2919_image_macos…
…_j20 fix(build): Поддержка jpackage macOS Ventura
- Loading branch information
Showing
3 changed files
with
83 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import ntpath | ||
import os | ||
import platform | ||
import re | ||
import shutil | ||
import sys | ||
|
||
|
||
def build_image(base_dir, image_prefix, executable_file): | ||
path_to_jar = get_bsl_ls_jar(base_dir) | ||
if path_to_jar is None: | ||
exit() | ||
|
||
cmd_args = [ | ||
'jpackage', | ||
'--name', 'bsl-language-server', | ||
'--input', 'build/libs', | ||
'--main-jar', path_to_jar] | ||
|
||
if is_windows(): | ||
cmd_args.append('--win-console') | ||
|
||
cmd_args.append('--type') | ||
cmd_args.append('app-image') | ||
cmd_args.append('--java-options') | ||
cmd_args.append('-Xmx2g') | ||
|
||
cmd = ' '.join(cmd_args) | ||
os.system(cmd) | ||
|
||
shutil.make_archive( | ||
"bsl-language-server_" + image_prefix, | ||
'zip', | ||
'./', | ||
executable_file) | ||
|
||
|
||
def is_windows(): | ||
return platform.system() == 'Windows' | ||
|
||
|
||
def get_base_dir(): | ||
if is_windows(): | ||
base_dir = os.getcwd() + "\\build\\libs" | ||
else: | ||
base_dir = os.getcwd() + "/build/libs" | ||
return base_dir | ||
|
||
|
||
def get_bsl_ls_jar(dir_name): | ||
pattern = r"bsl.+\.jar" | ||
names = os.listdir(dir_name) | ||
for name in names: | ||
fullname = os.path.join(dir_name, name) | ||
if os.path.isfile(fullname) and re.search(pattern, fullname) and fullname.find('exec.jar') != -1: | ||
return ntpath.basename(fullname) | ||
|
||
return None | ||
|
||
|
||
if __name__ == "__main__": | ||
# directory with build project | ||
arg_base_dir = get_base_dir() | ||
|
||
# image prefix: `win`, `nic` or `mac` | ||
arg_image_prefix = sys.argv[1] | ||
|
||
# executable file: `bsl-language-server` or `bsl-language-server.app` | ||
arg_executable_file = sys.argv[2] | ||
|
||
build_image(base_dir=get_base_dir(), | ||
image_prefix=sys.argv[1], | ||
executable_file=sys.argv[2]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,80 +28,36 @@ jobs: | |
|
||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
java-version: 20 | ||
distribution: 'temurin' | ||
|
||
- name: Build bootJar with Gradle | ||
run: ./gradlew check bootJar | ||
- name: Build jpackage app-image | ||
run: | | ||
import os | ||
import platform | ||
import re | ||
import ntpath | ||
import shutil | ||
pattern = r"bsl.+\.jar" | ||
thisPlatform = platform.system(); | ||
isWindows = False | ||
if thisPlatform == 'Windows': | ||
isWindows = True | ||
if isWindows: | ||
dirName = os.getcwd() + "\\build\\libs" | ||
else: | ||
dirName = os.getcwd() + "/build/libs" | ||
def start(): | ||
fullname = get_bslls_jar(dirName) | ||
if (fullname == None): | ||
exit | ||
cmdArgs = ['jpackage'] | ||
cmdArgs.append('--name') | ||
cmdArgs.append('bsl-language-server') | ||
cmdArgs.append('--input') | ||
cmdArgs.append('build/libs') | ||
cmdArgs.append('--main-jar') | ||
cmdArgs.append(fullname) | ||
if isWindows: | ||
cmdArgs.append('--win-console') | ||
cmdArgs.append('--type') | ||
cmdArgs.append('app-image') | ||
cmdArgs.append('--java-options') | ||
cmdArgs.append('-Xmx2g') | ||
|
||
cmd = ' '.join(cmdArgs) | ||
os.system(cmd) | ||
shutil.make_archive("bsl-language-server_" + "${{ matrix.prefix }}", 'zip', './',"${{ matrix.app-image }}") | ||
- name: Build jpackage application image | ||
run: python .github/scripts/build-jpackage.py ${{ matrix.prefix }} ${{ matrix.app-image }} | ||
|
||
def get_bslls_jar(dir): | ||
names = os.listdir(dir) | ||
for name in names: | ||
fullname = os.path.join(dir, name) | ||
if os.path.isfile(fullname) and re.search(pattern, fullname) and fullname.find('exec.jar') != -1: | ||
return ntpath.basename(fullname) | ||
return None | ||
start() | ||
shell: python | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: bsl-language-server_${{ matrix.prefix }}.zip | ||
path: ./${{ matrix.app-image }} | ||
|
||
- name: Upload assets to release | ||
uses: AButler/[email protected] | ||
with: | ||
files: './bsl-language-server_${{ matrix.prefix }}.zip' | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build with Gradle | ||
if: matrix.prefix == 'nix' | ||
run: ./gradlew build | ||
|
||
- name: Upload jar to release | ||
if: matrix.prefix == 'nix' | ||
uses: AButler/[email protected] | ||
|