Skip to content

Commit e149368

Browse files
committedJan 12, 2025·
Avoid building an exec-based binary on windows
1 parent b1e7a83 commit e149368

File tree

3 files changed

+48
-25
lines changed

3 files changed

+48
-25
lines changed
 

‎.github/workflows/build.yml

+20-4
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,32 @@ jobs:
2929
- name: Setup Gradle
3030
uses: gradle/actions/setup-gradle@v4
3131

32-
- name: build
33-
run: ./gradlew build
32+
- name: Check style
33+
run: ./gradlew ktlintCheck
3434

35-
- name: release binary
35+
- name: Build unix binary
36+
if: ${{ contains(matrix.target, 'macos') || contains(matrix.target, 'linux') }}
3637
run: |
3738
VARIANT=$(echo ${{ matrix.target }} | sed -E 's/-x64/X64/; s/-arm64/Arm64/')
3839
./gradlew ${variant}Binary
3940
40-
- name: archive vat
41+
- name: Archive vat-${{ matrix.target }}
42+
if: ${{ contains(matrix.target, 'macos') || contains(matrix.target, 'linux') }}
4143
uses: actions/upload-artifact@v4
4244
with:
4345
name: vat-${{ matrix.target }}
4446
path: build/libs/vat-${{ matrix.target }}
47+
48+
- name: Build windows jar
49+
if: ${{ contains(matrix.target, 'windows') }}
50+
run: |
51+
VARIANT=$(echo ${{ matrix.target }} | sed -E 's/-x64/X64/; s/-arm64/Arm64/')
52+
./gradlew ${variant}Optimize
53+
54+
- name: Archive vat-${{ matrix.target }}.jar
55+
if: ${{ contains(matrix.target, 'windows') }}
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: vat-${{ matrix.target }}.jar
59+
path: build/libs/vat-${{ matrix.target }}.jar
60+

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
### Added
6+
- Build targets for windows and linux systems
67

78
### Changed
89

‎build.gradle.kts

+27-21
Original file line numberDiff line numberDiff line change
@@ -182,23 +182,26 @@ tasks {
182182
dependsOn("$os${arch.capitalized()}Jar")
183183
}
184184

185-
val binaryFileProp = layout.buildDirectory.file("libs/vat-$os-$arch")
186-
register("$os${arch.capitalized()}Binary") {
187-
description = "Prepends shell script in the jar to improve CLI"
188-
group = "build"
189-
190-
dependsOn("$os${arch.capitalized()}Optimize")
191-
192-
inputs.file("build/libs/vat-$os-$arch-$version.jar")
193-
outputs.file(binaryFileProp)
194-
195-
doLast {
196-
val binaryFile = binaryFileProp.get().asFile
197-
binaryFile.parentFile.mkdirs()
198-
binaryFile.delete()
199-
binaryFile.appendText("#!/bin/sh\n\nexec java \$JAVA_OPTS -jar \$0 \"\$@\"\n\n")
200-
file("build/libs/vat-$os-$arch-$version.jar").inputStream().use { binaryFile.appendBytes(it.readBytes()) }
201-
binaryFile.setExecutable(true, false)
185+
if (os != "windows") {
186+
val binaryFileProp = layout.buildDirectory.file("libs/vat-$os-$arch")
187+
register("$os${arch.capitalized()}Binary") {
188+
description = "Prepends shell script in the jar to improve CLI"
189+
group = "build"
190+
191+
dependsOn("$os${arch.capitalized()}Optimize")
192+
193+
inputs.file("build/libs/vat-$os-$arch-$version.jar")
194+
outputs.file(binaryFileProp)
195+
196+
doLast {
197+
val binaryFile = binaryFileProp.get().asFile
198+
binaryFile.parentFile.mkdirs()
199+
binaryFile.delete()
200+
binaryFile.appendText("#!/bin/sh\n\nexec java \$JAVA_OPTS -jar \$0 \"\$@\"\n\n")
201+
file("build/libs/vat-$os-$arch-$version.jar").inputStream()
202+
.use { binaryFile.appendBytes(it.readBytes()) }
203+
binaryFile.setExecutable(true, false)
204+
}
202205
}
203206
}
204207
}
@@ -233,9 +236,12 @@ tasks {
233236
dependsOn("$targetOs${targetArch.capitalized()}Optimize")
234237
}
235238

236-
val binary by registering {
237-
description = "Prepends shell script in the jar to improve CLI for the current system ($targetOs-$targetArch)"
238-
group = "build"
239-
dependsOn("$targetOs${targetArch.capitalized()}Binary")
239+
if (targetOs != "windows") {
240+
val binary by registering {
241+
description =
242+
"Prepends shell script in the jar to improve CLI for the current system ($targetOs-$targetArch)"
243+
group = "build"
244+
dependsOn("$targetOs${targetArch.capitalized()}Binary")
245+
}
240246
}
241247
}

0 commit comments

Comments
 (0)
Please sign in to comment.