0

0

WPILIB (FRC) Gradlew 问题(Gradle 构建正常,但 gradlew 不行)

王林

王林

发布时间:2024-02-11 10:30:09

|

1263人浏览过

|

来源于stackoverflow

转载

php小编子墨wpilib (frc) gradlew 问题是指在使用gradle构建frc项目时,遇到gradlew命令无法正常运行的情况。虽然gradle构建可以顺利进行,但在使用gradlew命令时却遇到了问题。这个问题可能导致项目无法正常编译和运行,给开发者带来了困扰。接下来,我们将详细解答这个问题,帮助开发者解决这一常见的难题。

问题内容

我最近在 windows 笔记本电脑上安装了 wpilib 并启动了一个项目,但是当我尝试使用 gradlew 构建项目时它不起作用:

这是我的 build.gradle

plugins {
    id "java"
    id "edu.wpi.first.gradlerio" version "2024.1.1"
}

java {
    sourcecompatibility = javaversion.version_17
    targetcompatibility = javaversion.version_17
}

def robot_main_class = "frc.robot.main"

// define my targets (roborio) and artifacts (deployable files)
// this is added by gradlerio's backing project deployutils.
deploy {
    targets {
        roborio(gettargettypeclass('roborio')) {
            // team number is loaded either from the .wpilib/wpilib_preferences.json
            // or from command line. if not found an exception will be thrown.
            // you can use getteamordefault(team) instead of getteamnumber if you
            // want to store a team number in this file.
            team = project.frc.getteamnumber()
            debug = project.frc.getdebugordefault(false)

            artifacts {
                // first part is artifact name, 2nd is artifact type
                // gettargettypeclass is a shortcut to get the class type using a string

                frcjava(getartifacttypeclass('frcjavaartifact')) {
                }

                // static files artifact
                frcstaticfiledeploy(getartifacttypeclass('filetreeartifact')) {
                    files = project.filetree('src/main/deploy')
                    directory = '/home/lvuser/deploy'
                }
            }
        }
    }
}

def deployartifact = deploy.targets.roborio.artifacts.frcjava

// set to true to use debug for jni.
wpi.java.debugjni = false

// set this to true to enable desktop support.
def includedesktopsupport = false

// defining my dependencies. in this case, wpilib (+ friends), and vendor libraries.
// also defines junit 5.
dependencies {
    implementation wpi.java.deps.wpilib()
    implementation wpi.java.vendor.java()

    roboriodebug wpi.java.deps.wpilibjnidebug(wpi.platforms.roborio)
    roboriodebug wpi.java.vendor.jnidebug(wpi.platforms.roborio)

    roboriorelease wpi.java.deps.wpilibjnirelease(wpi.platforms.roborio)
    roboriorelease wpi.java.vendor.jnirelease(wpi.platforms.roborio)

    nativedebug wpi.java.deps.wpilibjnidebug(wpi.platforms.desktop)
    nativedebug wpi.java.vendor.jnidebug(wpi.platforms.desktop)
    simulationdebug wpi.sim.enabledebug()

    nativerelease wpi.java.deps.wpilibjnirelease(wpi.platforms.desktop)
    nativerelease wpi.java.vendor.jnirelease(wpi.platforms.desktop)
    simulationrelease wpi.sim.enablerelease()

    testimplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
    testruntimeonly 'org.junit.platform:junit-platform-launcher'
}

test {
    usejunitplatform()
    systemproperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
}

// simulation configuration (e.g. environment variables).
wpi.sim.addgui().defaultenabled = true
wpi.sim.adddriverstation()

// setting up my jar file. in this case, adding all libraries into the main jar ('fat jar')
// in order to make them all available at runtime. also adding the manifest so wpilib
// knows where to look for our robot class.
jar {
    from { configurations.runtimeclasspath.collect { it.isdirectory() ? it : ziptree(it) } }
    from sourcesets.main.allsource
    manifest edu.wpi.first.gradlerio.gradlerioplugin.javamanifest(robot_main_class)
    duplicatesstrategy = duplicatesstrategy.include
}

// configure jar and deploy tasks
deployartifact.jartask = jar
wpi.java.configureexecutabletasks(jar)
wpi.java.configuretesttasks(test)

// configure string concat to always inline compile
tasks.withtype(javacompile) {
    options.compilerargs.add '-xdstringconcat=inline'
}

现在如果我用 gradle 构建,它构建得非常好

设置.gradle:

import org.gradle.internal.os.operatingsystem

pluginmanagement {
    repositories {
        mavenlocal()
        gradlepluginportal()
        string frcyear = '2024'
        file frchome
        if (operatingsystem.current().iswindows()) {
            string publicfolder = system.getenv('public')
            if (publicfolder == null) {
                publicfolder = "c:\users\public"
            }
            def homeroot = new file(publicfolder, "wpilib")
            frchome = new file(homeroot, frcyear)
        } else {
            def userfolder = system.getproperty("user.home")
            def homeroot = new file(userfolder, "wpilib")
            frchome = new file(homeroot, frcyear)
        }
        def frchomemaven = new file(frchome, 'maven')
        maven {
            name 'frchome'
            url frchomemaven
        }
    }
}

properties props = system.getproperties();
props.setproperty("org.gradle.internal.native.headers.unresolved.dependencies.ignore", "true");

我预计它也会使用 gradlew 构建,但事实并非如此,

这是我的 gradle-wrapper.properties

Inworld.ai
Inworld.ai

InWorldAI是一个AI角色开发平台,开发者可以创建具有自然语言、上下文意识和多模态的AI角色,并可以继承到游戏和实时媒体中

下载
distributionbase=gradle_user_home
distributionpath=permwrapper/dists
distributionurl=https://services.gradle.org/distributions/gradle-8.5-bin.zip
networktimeout=10000
validatedistributionurl=true
zipstorebase=gradle_user_home
zipstorepath=permwrapper/dists

它没有构建它而是给了我这个:

>gradlew
Exception in thread "main" java.lang.ClassNotFoundException: org.gradle.launcher.GradleMain
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
        at org.gradle.wrapper.GradleWrapperMain.main(SourceFile:70)

我什至尝试重新生成包装器,gradlewrapper

另外:出于某种原因,gradlew 无论如何都不会听命令,它是唯一的构建

编辑: 我已经在 github codespaces 和我自己的 linux (arch linux) 上尝试了我的代码,但是 windows 不适合我,我已经重新安装了 wpilib 多次,不知道为什么它对我这样做。我尝试过使用 windows 虚拟机,但它的工作原理很奇怪,为什么我的计算机无法工作。

解决方法

此错误的解决方案是您必须删除主目录 C:Users{username} 中的 .gradle 文件夹。现在,在我的安装过程中一定发生了一些导致此错误发生的事情。现在一切都可以正确构建。

注意:在删除之前您必须重新启动计算机,因为除非重新启动,否则它不会让您删除。

相关标签:

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
github中文官网入口 github中文版官网网页进入
github中文官网入口 github中文版官网网页进入

github中文官网入口https://docs.github.com/zh/get-started,GitHub 是一种基于云的平台,可在其中存储、共享并与他人一起编写代码。 通过将代码存储在GitHub 上的“存储库”中,你可以: “展示或共享”你的工作。 持续“跟踪和管理”对代码的更改。

4031

2026.01.21

windows查看端口占用情况
windows查看端口占用情况

Windows端口可以认为是计算机与外界通讯交流的出入口。逻辑意义上的端口一般是指TCP/IP协议中的端口,端口号的范围从0到65535,比如用于浏览网页服务的80端口,用于FTP服务的21端口等等。怎么查看windows端口占用情况呢?php中文网给大家带来了相关的教程以及文章,欢迎大家前来阅读学习。

1476

2023.07.26

查看端口占用情况windows
查看端口占用情况windows

端口占用是指与端口关联的软件占用端口而使得其他应用程序无法使用这些端口,端口占用问题是计算机系统编程领域的一个常见问题,端口占用的根本原因可能是操作系统的一些错误,服务器也可能会出现端口占用问题。php中文网给大家带来了相关的教程以及文章,欢迎大家前来学习阅读。

1169

2023.07.27

windows照片无法显示
windows照片无法显示

当我们尝试打开一张图片时,可能会出现一个错误提示,提示说"Windows照片查看器无法显示此图片,因为计算机上的可用内存不足",本专题为大家提供windows照片无法显示相关的文章,帮助大家解决该问题。

835

2023.08.01

windows查看端口被占用的情况
windows查看端口被占用的情况

windows查看端口被占用的情况的方法:1、使用Windows自带的资源监视器;2、使用命令提示符查看端口信息;3、使用任务管理器查看占用端口的进程。本专题为大家提供windows查看端口被占用的情况的相关的文章、下载、课程内容,供大家免费下载体验。

461

2023.08.02

windows无法访问共享电脑
windows无法访问共享电脑

在现代社会中,共享电脑是办公室和家庭的重要组成部分。然而,有时我们可能会遇到Windows无法访问共享电脑的问题。这个问题可能会导致数据无法共享,影响工作和生活的正常进行。php中文网给大家带来了相关的教程以及文章,欢迎大家前来阅读学习。

2361

2023.08.08

windows自动更新
windows自动更新

Windows操作系统的自动更新功能可以确保系统及时获取最新的补丁和安全更新,以提高系统的稳定性和安全性。然而,有时候我们可能希望暂时或永久地关闭Windows的自动更新功能。php中文网给大家带来了相关的教程以及文章,欢迎大家前来学习阅读。

874

2023.08.10

windows boot manager
windows boot manager

windows boot manager无法开机的解决方法:1、系统文件损坏,使用Windows安装光盘或USB启动盘进入恢复环境,选择修复计算机,然后选择自动修复;2、引导顺序错误,进入恢复环境,选择命令提示符,输入命令"bootrec /fixboot"和"bootrec /fixmbr",然后重新启动计算机;3、硬件问题,使用硬盘检测工具进行扫描和修复;4、重装操作系统。本专题还提供其他解决

1948

2023.08.28

Go高并发任务调度与Goroutine池化实践
Go高并发任务调度与Goroutine池化实践

本专题围绕 Go 语言在高并发任务处理场景中的实践展开,系统讲解 Goroutine 调度模型、Channel 通信机制以及并发控制策略。内容包括任务队列设计、Goroutine 池化管理、资源限制控制以及并发任务的性能优化方法。通过实际案例演示,帮助开发者构建稳定高效的 Go 并发任务处理系统,提高系统在高负载环境下的处理能力与稳定性。

4

2026.03.10

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号