我正试图在Windows上用GraalVM构建一个GraalVM 7应用程序。我已经成功地将它用于macOS和Linux。使用Windows时,我会看到命令行太长的错误。
[INFO] Executing: C:\Users\runneradmin\.graalvm\graalvm-ce-java17-22.0.0.2\bin\native-image.cmd -cp ...;D:\a\auth0-full-stack-java-example\auth0-full-stack-java-example\target\flickr-2-0.0.1-SNAPSHOT.jar --no-fallback --verbose -J-Xmx10g -H:Name=native-executable
The command line is too long.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------我复制并粘贴了GitHub操作运行的命令,它的长度仅超过12000个字符。根据本文件,Windows只支持8191个字符。
我试着使用这一建议缩短类路径,但没有帮助。我甚至尝试了C:\r而不是C:\repo。
People 在Twitter上建议使用PowerShell并将命令回显到文件中,然后运行该命令。但是,我还没有找到从Maven中提取native-image.cmd命令及其参数的任何示例。
您可以找到我用来配置这里的这里操作。为了方便起见,我还把它贴在下面。
name: Publish
on:
release:
types: [published]
env:
graalvm_version: '22.0.0.2'
java_version: '17'
branch: 'spring-native'
jobs:
build:
name: GraalVM - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 90
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v2
with:
ref: '${{ env.branch }}'
- name: Set up GraalVM (Java ${{ env.java_version }})
uses: graalvm/setup-graalvm@v1
with:
version: '${{ env.graalvm_version }}'
java-version: '${{ env.java_version }}'
components: 'native-image'
- name: Cache Maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven
- name: Cache npm dependencies
uses: actions/cache@v2
with:
path: |
~/.npm
~/.cache/Cypress/
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
- name: Set up swap space
if: runner.os == 'Linux'
uses: pierotofy/set-swap-space@v1.0
with:
swap-size-gb: 10
- name: Build native images
run: ./mvnw -B -ntp package -Pnative,prod -DskipTests
- name: Archive binary
uses: actions/upload-artifact@v2
with:
name: flickr2-${{ matrix.os }}-x86_64
path: target/native-executable
- name: Get release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Rename binary
run: mv target/native-executable target/flickr2-${{ runner.os }}-${{ env.RELEASE_VERSION }}-x86_64
- name: Upload release
uses: alexellis/upload-assets@0.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_paths: '["target/flickr2-${{ runner.os }}*"]'
build-windows:
name: GraalVM - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
os: [windows-latest]
steps:
- uses: actions/checkout@v2
with:
ref: '${{ env.branch }}'
- uses: ilammy/msvc-dev-cmd@v1
- uses: microsoft/setup-msbuild@v1
- name: Set up GraalVM (Java ${{ env.java_version }})
uses: graalvm/setup-graalvm@v1
with:
version: '${{ env.graalvm_version }}'
java-version: '${{ env.java_version }}'
components: 'native-image'
- name: Cache Maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven
- name: Cache npm dependencies
uses: actions/cache@v2
with:
path: |
~/.npm
~/.cache/Cypress/
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
- name: Configure pagefile
uses: al-cheb/configure-pagefile-action@v1.2
- name: Set up pagefile
run: |
(Get-CimInstance Win32_PageFileUsage).AllocatedBaseSize
- name: mvnw --version
run: mvnw --version
shell: cmd
- name: Maven resolve
run: mvnw -B -ntp dependency:resolve-plugins
shell: cmd
- name: Build native images
run: |
mklink /J C:\r C:\Users\runneradmin\.m2\repository
mvnw -B -ntp package -Pnative,prod -DskipTests -Dmaven.repo.local=C:\r
shell: cmd
- name: Archive binary
uses: actions/upload-artifact@v2
with:
name: flickr-${{ matrix.os }}-x86_64.exe
path: target/native-executable.exe
- name: Get release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Rename binary
run: move target/native-executable.exe target/flickr2-${{ runner.os }}-${{ env.RELEASE_VERSION }}-x86_64.exe
- name: Upload release
uses: alexellis/upload-assets@0.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_paths: '["target/flickr2-${{ runner.os }}*"]'发布于 2022-03-01 02:03:19
升级到本机构建工具v0.9.10在Windows上修复了这个问题。在https://github.com/graalvm/native-build-tools/issues/214和https://github.com/graalvm/setup-graalvm/issues/6#issuecomment-1054582083上有更多的细节。
https://stackoverflow.com/questions/71297835
复制相似问题