Skip to content

Commit

Permalink
Merge pull request #3034 from 1c-syntax/bugfix/issue-2919_image_macos…
Browse files Browse the repository at this point in the history
…_j20

fix(build): Поддержка jpackage macOS Ventura
  • Loading branch information
nixel2007 authored Apr 1, 2023
2 parents 6f61b44 + 98cd850 commit 9f9644f
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 54 deletions.
73 changes: 73 additions & 0 deletions .github/scripts/build-jpackage.py
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])
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java_version: ['11', '17']
java_version: ['11', '17', '20']
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v3
Expand Down
62 changes: 9 additions & 53 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 9f9644f

Please sign in to comment.