Import source code: Could not install Gradle distribution - eclipse

Gradle
michael#michael:~$ gradle -v
------------------------------------------------------------
Gradle 6.3
------------------------------------------------------------
Java
michael#michael:~$ java -version
java version "14.0.1" 2020-04-14
Spring Tool Suite 4 (an Eclipse derivative)
Version: 4.6.0.RELEASE
Buildship
Eclipse Plug-ins for Gradle 3.1.4.v20200326-1743 org.eclipse.buildship.feature.group Eclipse Buildship
I've downloaded a code samples for a book.
Then:
File -> Import -> Existing Gradle Project.
When I import, I override workspace settings:
1. Gradle version = 6.3
2. Gradle user home = /opt/gradle/gradle-6.3/bin
3. Java home = /usr/lib/jvm/jdk-14.0.1/bin
The same as described above:
The problem:
Description Resource Path Location Type
Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-6.3-bin.zip'.
Could not create parent directory for lock file /opt/gradle/gradle-6.3/bin/wrapper/dists/gradle-6.3-bin/8tpu6egwsccjzp10c1jckl0rx/gradle-6.3-bin.zip.lck beginning-spring-5 line 0 Gradle Error Marker
The same as a picture:
Well, STS seems to be trying to install Gradle.
Could you help me understand what is going on and help cope with this.
If I do everything wrongly, please help me just import the source code.

Related

"Could not run phased build action using connection to Gradle distribution"

I'm having various Gradle problems after a new clean Eclipse install.
They seem to be associated w/ this "Problem" message:
Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.1.1-bin.zip'.
Initialization script 'Z:\eclipse-workspace\.metadata\.plugins\org.eclipse.buildship.core\init.d\eclipsePlugin.gradle'
Could not compile initialization script 'Z:\eclipse-workspace\.metadata\.plugins\org.eclipse.buildship.core\init.d\eclipsePlugin.gradle'.
startup failed:
General error during semantic analysis: Unsupported class file major version 60
java.lang.IllegalArgumentException: Unsupported class file major version 60
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:196)
.....
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.base/java.lang.Thread.run(Thread.java:831)
1 error
I've already tried deleting .gradle & "Gradle->Refresh Gradle Project".
I've also tried this:
stackoverflow
My Java install is clean:
java version "16.0.1" 2021-04-20
& confirmed Eclipse is pointing to it ("Preferences->Java->Installed JREs").
Installation details:
Buildship: Eclipse Plug-ins for Gradle 3.1.5.v20210113-0929
Eclipse IDE for Java Developers 4.20.0.20210612-1200
Windows 10.
Eclipse Install Err Log:
!ENTRY org.eclipse.buildship.core 2 2 2021-07-09 11:22:05.951
!MESSAGE Initialize project testgradleprj failed due to an error in the referenced Gradle build.
!STACK 0
org.gradle.tooling.BuildException: Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.1.1-bin.zip'.
Gradle 6.8 does not work with Java 16.
Java 16 supported starting with Gradle 7
"In previous Gradle versions, running Gradle itself on Java 16 resulted in an error."
https://docs.gradle.org/7.0/release-notes.html#java-16
Thanks to LMC. I changed the project prefs->Gradle from Wrapper to Specific=7.1.1 :
I have updated my gradle-warpper.properties file with
distributionUrl=https://services.gradle.org/distributions/gradle-6.4.1-bin.zip
from
distributionUrl=https://services.gradle.org/distributions/gradle-5.6.2-bin.zip
and refresh the gradlew project in eclipse. It's build successfull
Note : Java 11 version is installed in my machine
Change your gradle.properties file
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
And build.gradle file
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0'
}
In my case, it was because Eclipse was running upon a JVM that was different from the one used by my local Gradle.
I edited the eclipse.ini file so that Eclipse would run on the same JVM as my local Gradle (i.e. the one pointed by JAVA_HOME) and it worked!

Gradle (wrapper) + STS + Spring Boot: Error: Could not find or load main class 1.1,

One project among many started giving me the following error when running Gradle Tasks -> application -> bootRun:
Error: Could not find or load main class 1.1,
However, the following both work:
Running ./gradlew bootRun from the command-line
Starting the service with STS Boot Dashboard
It's odd that the Gradle Task window's execution is coming up with the class 1.1,.
Ideas?
Configuration
Windows 10 Pro
STS 3.9.4.RELEASE
Eclipse Buildship 2.2.1
Gradle Wrapper 4.5.1
Spring Boot 2.0.3.RELEASE
Attempts
Ran ./gradlew clean build
Refreshed Gradle Tasks in the window
Right-clicked project and ran Gradle -> Refresh Gradle Project
Restarted STS
Deleted ./metadata and restarted STS
Deleted ./bin and ./build directories
Unloaded the project and re-imported as Gradle project
Ran "STS -clean"
... always the same result
I have the same issue. Anyway in Eclipse Oxygen it just suddenly stops working but in terminal it is fine.
https://github.com/JetBrains/kotlin-native/issues/1747
Maybe this link would help. It is not working for me but I believe it points to the right direction.
Solution he purposes:
No, removing of node does not help. But the follow line in the Gradle script solve the problem:
System.getProperties().remove( 'org.osgi.framework.system.capabilities' )
The value of the property is:
osgi.ee; osgi.ee="OSGi/Minimum"; version:List<Version>="1.0, 1.1, 1.2",osgi.ee; osgi.ee="JRE"; version:List<Version>="1.0, 1.1",osgi.ee; osgi.ee="JavaSE"; version:List<Version>="1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8",osgi.ee; osgi.ee="JavaSE/compact1"; version:List<Version>="1.8",osgi.ee; osgi.ee="JavaSE/compact2"; version:List<Version>="1.8",osgi.ee; osgi.ee="JavaSE/compact3"; version:List<Version>="1.8"
It look like that you try to add all environment variable to the command line but does not quote correctly.

Changes to kotlin class not recognized by Spring Boot?

Changes are not reflected in the service response from http://localhost:8080/hi after:
Modifying the response string of SomeController in the code below
Spring Tool Suite automatically compiles the changes
Spring Boot DevTools automatically restarts the server
Request to http://localhost:8080/hi still gives the old response
Somehow they're getting cached, even after running ./gradlew build manually.
Totally different issues: I have Java 1.8 JRE and JDK installed into two directories under Program Files\Java. The project shows the JRE dependency and running build from STS Gradle Tasks window yields the JRE instead of the JDK, even though JAVA_HOME is properly set to the JDK, STS is configured to use the JDK by default (JRE unchecked), and the Spring Boot Project is configured to use the workspace settings (JDK). It seems to be picking up the JRE from the IDE runtime itself, instead of from the settings? I found a work-around by right-clicking the build task and selecting build -> Open Gradle Run Configuration -> Java Home and manually setting this to the same directory as the JDK. I also found a workaround for the project with right-click on project Properties -> Java Build Path -> Libraries, removing JRE System Library and adding the JDK (Add Library... -> JRE System Library -> Workspace default JRE (jdk1.8.0_144)). But, sometimes the project resets itself to the JRE somehow.
Gradle Distribution: Gradle wrapper from target build
Gradle Version: 4.5.1
Java Home: C:\Program Files\Java\jre1.8.0_171
Code
package com.example.demo
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
#RestController
class SomeController {
#GetMapping("/hi")
fun hi(): String {
return "hey"
}
}
#SpringBootApplication
open class DemoApplication
fun main(args: Array<String>) {
runApplication<DemoApplication>(*args)
}
Configuration
Windows 10 Pro
Spring Tool Suite 3.9.4.RELEASE
JDK 1.8
Kotlin 1.2.41
Gradle Wrapper 4.5.1
Spring Boot + DevTools 2.0.3.RELEASE
Setup Steps
New workspace in STS with Gradle Buildship and Kotlin extensions
Add JDK 1.8 as default
Create project File -> New -> Spring Starter Project
Gradle (Buildship 2.x)
Java 8
Kotlin
Reactive Web
DevTools
Actuator
Right-click project Configure Kotlin -> Add Kotlin Nature
Start service Boot Dashboard -> local -> demo [devtools] [:8080]

How to build maven spark project (Scala), then import and config eclipse

I have cloned this project: https://github.com/sryza/aas
and built successful with maven ( pom.xml)
I then import to Eclipse oxygen ( scala IDE plug in), open and run the file "main.scala", and had an error: not found the main class though I had tried to run as configuration with scala nature. Which step i missed?
In general how can i config eclipse to switch with Java, Scala, and python(install PyDev)
Thanks for your help
You can try the following:
1 When you clone the project use: mvn eclipse:eclipse so you can import it in eclipse.
2 Run mvn clean install to see if the project is building
Witch Eclipse IDE for Java EE Developers you should be able to run it

maven in command line succeed, but failed when using the same maven in eclipse

I'm trying to build the project of hadoop. I followed the official document as follows on how to do that.
http://wiki.apache.org/hadoop/HowToContribute
https://wiki.apache.org/hadoop/EclipseEnvironment
I've git clone the project, maven install it successfully, but when I import the project, or even a sub-project like 'hadoop-yarn-api', I got the following errors on maven:
Description Resource Path Location Type
Plugin execution not covered by lifecycle configuration: org.apache.hadoop:hadoop-maven-plugins:3.0.0-SNAPSHOT:protoc (execution: compile-protoc, phase: generate-sources) pom.xml /hadoop-yarn-api line 73 Maven Project Build Lifecycle Mapping Problem
Then I'm trying to mvn clean install the project via External Tools Configuration in eclipse, it also failed on:
[ERROR] Failed to execute goal org.apache.hadoop:hadoop-maven-plugins:3.0.0-SNAPSHOT:protoc (compile-protoc) on project hadoop-yarn-api: org.apache.maven.plugin.MojoExecutionException: 'protoc --version' did not return a version -> [Help 1]
But the curious part is that when I cd into the root directory of 'hadoop-yarn-api' and invoke mvn clean install, it can be built successfully.
I'm using m2ecipse in eclipse, and I'm sure that I've changed to the maven which is exactly the one that I'm used in command line, not the embedded one.
And I've installed protocol buffers 2.5.0:
$ protoc --version
libprotoc 2.5.0
Could anyone give me some idea? Many thanks!
P.S.
Eclipse Java EE IDE - Juno Service Release 2
m2e - 1.4.1.20140328-1905
Mac 1- 0.9.4
maven - 3.0.5
Hadoop - 2.2.0