gpt4 book ai didi

spring-boot - 如何使用 GraalVM 和 Windows 解决 "The command line is too long"?

转载 作者:行者123 更新时间:2023-12-05 05:45:46 31 4
gpt4 key购买 nike

我正在尝试在 Windows 上使用 GraalVM 构建 JHipster 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 Actions 运行的命令,它的长度刚好超过 12,000 个字符。根据this document , Windows 只支持 8191 个字符。

我尝试使用 this suggestion 缩短类路径,但这没有帮助。我什至尝试使用 C:\r 而不是 C:\repo

on Twitter建议使用 PowerShell 并将命令回显到文件中,然后运行它。但是,我还没有找到任何有关如何从 Maven 中提取 native-image.cmd 命令及其参数的示例。

您可以找到我用来配置东西的 GitHub 操作 here .为了方便起见,我也将其粘贴在下面。

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 }}*"]'

最佳答案

升级到 native-build-tools v0.9.10 修复了 Windows 上的这个问题。更多详情,请访问 https://github.com/graalvm/native-build-tools/issues/214https://github.com/graalvm/setup-graalvm/issues/6#issuecomment-1054582083 .

关于spring-boot - 如何使用 GraalVM 和 Windows 解决 "The command line is too long"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71297835/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com