先看下报错内容吧,如下:
FAILURE: Build completed with 2 failures. 1: Task failed with an exception. ----------- * Where: Build file '/Users/liubolun/IdeaProjects/elasticsearch/benchmarks/build.gradle' line: 20 * What went wrong: A problem occurred evaluating project ':benchmarks'. > Failed to apply plugin [id 'elasticsearch.build'] > {awt.toolkit=sun.lwawt.macosx.LWCToolkit, java.specification.version=11, kotlinx.coroutines.debug=off, sun.cpu.isalist=, sun.jnu.encoding=UTF-8, sun.arch.data.model=64, idea.fatal.error.notification=disabled, pty4j.preferred.native.folder=/Applications/IntelliJ IDEA.app/Contents/lib/pty4j, java.vendor.url=https://adoptium.net/, sun.boot.library.path=/Users/liubolun/Library/Java/JavaVirtualMachines/temurin-11.0.14.1/Contents/Home/lib, sun.java.command=org.gradle.launcher.daemon.bootstrap.GradleDaemon 5.4.1, jdk.debug=release, aether.connector.resumeDownloads=false, com.apple.mrj.application.live-resize=false, java.specification.vendor=Oracle Corporation, java.version.date=2024-01-16, java.home=/Users/liubolun/Library/Java/JavaVirtualMachines/temurin-11.0.14.1/Contents/Home, file.separator=/, java.vm.compressedOopsMode=Zero based, line.separator= , java.specification.name=Java Platform API Specification, java.vm.specification.vendor=Oracle Corporation, jdk.attach.allowAttachSelf=true, jbr.virtualization.information=No virtualization detected, user.script=Hans, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, java.runtime.version=11.0.14.1+1, user.name=liubolun, javax.swing.rebaseCssSizeMap=true, idea.paths.selector=IntelliJIdea2023.3, file.encoding=UTF-8, jnidispatch.path=/Applications/IntelliJ IDEA.app/Contents/lib/jna/amd64/libjnidispatch.jnilib, https.nonProxyHosts=*.github.com|plugins.jetbrains.com, idea.popup.weight=heavy, idea.sync.active=true, java.vendor.version=JBR-17.0.10+1-1087.23-jcef, idea.gradle.download.sources=false, jna.loaded=true, java.io.tmpdir=/var/folders/r_/jcb0k0wn2zjcmqjrh0p81fmr0000gn/T/, idea.version=2023.3.6, java.version=11.0.14.1, idea.xdebug.key=-Xdebug, java.vm.specification.name=Java Virtual Machine Specification, java.awt.printerjob=sun.lwawt.macosx.CPrinterJob, sun.os.patch.level=unknown, native.encoding=UTF-8, java.library.path=/Users/liubolun/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:., java.vendor=Eclipse Adoptium, io.netty.processId=53003, sun.io.unicode.encoding=UnicodeBig, java.rmi.server.disableHttp=true, library.jansi.path=/Users/liubolun/.gradle/native/jansi/1.17.1/osx, io.netty.machineId=28:f0:76:ff:fe:16:65:0e, gopherProxySet=false, idea.active=true, java.class.path=/Users/liubolun/.gradle/wrapper/dists/gradle-5.4.1-all/3221gyojl5jsh0helicew7rwx/gradle-5.4.1/lib/gradle-launcher-5.4.1.jar, java.vm.vendor=Eclipse Adoptium, idea.vendor.name=JetBrains, user.variant=, idea.resolveSourceSetDependencies=true, user.timezone=Asia/Shanghai, jb.vmOptionsFile=/Users/liubolun/ja-netfilter/vmoptions/idea.vmoptions, idea.no.launcher=false, swing.bufferPerWindow=true, os.name=Mac OS X, java.vm.specification.version=11, apple.laf.useScreenMenuBar=false, user.country=CN, sun.java.launcher=SUN_STANDARD, http.nonProxyHosts=*.github.com|plugins.jetbrains.com, sun.cpu.endian=little, user.home=/Users/liubolun, user.language=zh, jdk.http.auth.tunneling.disabledSchemes="", idea.cycle.buffer.size=1024, io.netty.allocator.numHeapArenas=1, java.awt.graphicsenv=sun.awt.CGraphicsEnvironment, io.netty.allocator.numDirectArenas=1, idea.max.intellisense.filesize=2500, io.netty.allocator.useCacheForAllThreads=false, path.separator=:, os.version=14.4.1, java.runtime.name=OpenJDK Runtime Environment, io.netty.allocator.cacheTrimIntervalMillis=600000, jdk.module.illegalAccess.silent=true, jdk.tls.client.protocols=TLSv1.2, java.vm.name=OpenJDK 64-Bit Server VM, jna.platform.library.path=/usr/lib:/usr/lib, java.vendor.url.bug=https://bugreport.java.com/bugreport/, intellij.platform.runtime.repository.path=/Applications/IntelliJ IDEA.app/Contents/modules/module-descriptors.jar, java.util.concurrent.ForkJoinPool.common.threadFactory=com.intellij.concurrency.IdeaForkJoinWorkerThreadFactory, user.dir=/Users/liubolun/IdeaProjects/elasticsearch, os.arch=x86_64, io.netty.serviceThreadPrefix=Netty , idea.dynamic.classpath=false, java.vm.info=mixed mode, java.vm.version=11.0.14.1+1, java.rmi.server.hostname=127.0.0.1, idea.max.content.load.filesize=20000, javax.swing.JTree.excludeAccessibleChildrenFromClosedNodes=true, java.class.version=55.0, splash=true} JAVA_HOME must be set to build Elasticsearch. Note that if the variable was just set you might have to run `./gradlew --stop` for it to be picked up. See https://github.com/elastic/elasticsearch/issues/31399 details. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ============================================================================== 2: Task failed with an exception. ----------- * What went wrong: A problem occurred configuring project ':benchmarks'. > Must specify license and notice file for project :benchmarks * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ============================================================================== * Get more help at https://help.gradle.org
执行gradle的时候,grable报错,报错内容有个关键的信息 JAVA_HOME must be set to build Elasticsearch
但是我的本机电脑已经配置了JAVA_HOME,很迷惑!!!
不过我们可以通过报错内容定位到对应的代码位置:
代码位置:org/elasticsearch/gradle/BuildPlugin.groovy
再执行一下,果然返回了null值,我晕了,我的机器明明是配置了的
先不纠结本地JAVA_HOME了,直接上骚操作,把 compilerJavaHome 获取逻辑改下,不从JAVA_HOME中获取,直接配置成路径:
String compilerJavaHome = "/Users/你的用户名/Library/Java/JavaVirtualMachines/temurin-11.0.14.1/Contents/Home"
先改成这个逻辑,就可以运行了~
标签:java,sun,idea,gradle,version,Elasticsearch,HOME,JAVA,true From: https://www.cnblogs.com/boluopabo/p/18193558