Run Corda project on IntelliJ - gradle

I'm using a MacBook Air OS X 10.9 (Mavericks) and IntelliJ IDEA, but the IDE won't let me execute the test "ProjectImportedOKTest" which is in src/test/java/java_bootcamp/. I followed the exact same steps of this video:
https://www.youtube.com/watch?v=ZgKxjwImKAs&index=3&list=PLi1PppB3-YrVq5Qy_RM9Qidq0eh-nL11N
But for some reason my green arrow to run the test is always disabled. It could be something with the configuration option in the top left of IntelliJ, which I left blank or even something with gradle.
Thanks a lot!!

You can invalidate the caches of the intelliJ by using the option
file -> invalidate caches/Restart.
It helped for me.

There are several things you could try.
Ensure that your source java or kotlin folder is marked as "Sources Root". Do this by right clicking the folder and selecting "Mark Directory as"
Go to view -> Tool Windows -> Gradle and hit the refresh icon
Try opening the project a different way, such as importing the project or just opening the project
Rebuild the project and ensure there are no errors
Go to File -> Project Structure and ensure Java 1.8 is set as the Project SDK
Got to File -> Settings 0> Build, Execution, Deployment and select Gradle. Ensure Gradle JVM has Java 1.8 and that "Use default gradle wrapper" is selected.
Again under Settings and Build, Execution, Deployment, go to Compiler -> Kotlin Compiler and check that Target JVM version is set to 1.8

I ran into the same problem running on Windows and ran into this question trying to find the solution. It turns out Gradle wasn't installed on my machine and that was causing the problems.
According to the Corda Docs - "Gradle - we use 4.10 and the gradlew script in the project / samples directories will download it for you."
However, I installed from the Gradle website here - https://gradle.org/install/#with-a-package-manager -and configured it in the PATH variable. After doing so, my green arrow was enabled and I was able to run the test successfully.

Related

Where can I find the error messages for IntelliJ Maven repository errors?

I am having trouble updating my maven repositories in IntelliJ. I have three repositories that show errors, but IntelliJ doesn't show the full error messages.
I am looking in File >> Settings >> Build, Execution, Deployment >> Build Tools >> Maven >> Repositories
This is what I see:
I have tried the update button in the upper right, but I always get the "Error" message. What I can't figure out is where I can view what the actual errors are. Can anyone tell me where these error messages are logged or displayed?
I can build from the command line just fine. I am using the following:
Windows 10 Pro
IntelliJ Ultimate 2002.3.2
Maven 3.6.3
Java jdk1.8.0_66
If you have a stand-alone maven instance, and builds work fine from the command line, but they do not work from IntelliJ, it's likely that IJ is not configured to use the same maven settings as your system.
IntelliJ will use its bundled maven runtime rather than the one from your system. IJ will also use default maven settings locations.
You can modify these under the Settings > Build, Execution, Deployment > Build Tools > Maven screen. Make sure the settings match those in your systems MAVEN_HOME .
This information shows up in the idea log. This log can be found in the Help menu in the top search bar of the IntelliJ window.
Help >> Show log in explorer
You can then open and search the log using your preferred text editor.
https://intellij-support.jetbrains.com/hc/en-us/articles/207241085
#CrazyCoder provided this information in a comment.

gradle-wrapper.properties not found after clean install intellij idea 2020.1.2 community edition on windows 10

Installed clean windows10(1607) and intellij idea(2020.1.2 community edition). When i create new gradle project
Invalid Gradle JDK configuration found. Open Gradle Settings
"gradle-wrapper.properties not found".
How can I fix it?
Install gradle 6.7
sdk install gradle 6.7
brew install gradle
Go to IntelliJ and set gradle version:
On File >> Settings >> Build, Execution , Deployment >> Gradle
or
Preferences >> Gradle
In Use Gradke from specific the correct location
If IDEA is set to use the Gradle wrapper (as it is in your screenshot: "Use Gradle from:" is set to "gradle-wrapper.properties"), IDEA expects the following file structure:
Gradle wrapper JAR: [project root]/gradle/wrapper/gradle-wrapper.jar
Gradle wrapper properties: [project root]/gradle/wrapper/gradle-wrapper.properties
Gradle wrapper script: [project root]/gradlew.bat
If you are missing one of these three elements, IDEA will attempt to generate the wrapper by calling the gradle wrapper task. It will do this using the Gradle JDK, which may or may not be the project SDK (File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM).
I'm not sure how it selects the version of Gradle it uses - I only have 6.8.3 installed on my machine, and I had my wrapper properties set to 7.0-rc-1, yet somehow it used 6.7.0 when generating the wrapper.
I tried various options for clearing the cache, but did not get the result.
Openjdk-14 installed by default and does not work. From site adoptopenjdk.net install OpenJDK 11 (LTS). When creating the project, I chose 11 version. Then the program suggested updating gradle to version 6 and it worked.
I ran into this problem a while ago when I upgraded to intellij 2020.* The first time I created a new project there was no problem: gradle daemon did its work and the project was created with no problems.
In my case, the project would start a new gradle daemon, and attempt to build the project, would get rejected by windows Security, and nothing would happen, so intellij goes ahead and starts another (unsuccessful) daemon. Soon, I had 20+ gradle daemon processes running on my system, all of them doing nothing.
So, it looks like intellij has messed in enabling that it places the appropriate permissions it requires for these folders that it depends on to run properly. So, you need to manually give these permissions, and then things (should) work.
The real issue here is security on your machine: either a virus checker or the security software, Windows Security on Windows 10, for example. The first time you make a project, Intellij goes and produces a number of folders that they need access to.
However, once these folders are available, for whatever, intellij doesn't make sure to give itself access.
On windows 10, in AppData, you'll find several folders required by Intellij to produce, in my case, produce gradle projects.
Try finding the various folders that Intellij has produced on your system, and give them exceptions on your virus checker and on whatever firewall/security software programs that may block access.

Gradle / IntelliJ miscommunication causing "Unable to start daemon process"

My IntelliJ Idea projects have been working fine until I cloned a new project from our repo and installed Gradle.
This new project runs, but running the debugger causes the following error:
I've completed the steps recommended in this similar SO question. I have also read the Gradle Daemon guide.
Some helpful information:
-Gradle does respond to command line prompts, including --profile and --status:
-The project builds and executes; the problem is only the debugger. Is this a mapping issue between IntelliJ and Gradle?
-In the Settings menu, Gradle JVM: is set to "Use Project JDK (Java version "1.8.0_211") and this program is written in Java 8. Delegate settings set to: Build and run using intelliJ IDEA. Run tests using IntelliJ IDEA. Should these change to Gradle?
-I took the advice of one of the respondents and had one of our IT guys check out my ports and firewall settings. He was unable to solve the problem and said the issue is with Gradle.
So far, nothing has worked. What should I do?
I solved this problem after some tinkering:
In (IntelliJ) File > Settings > Build, Execution, Deployment > Gradle, I changed "Use gradle 'wrapper' task configuration" to "Use local gradle distribution."
Also, notice in this screenshot that "Gradle VM options" has a custom value; this was suggested as a solution in another post. This relates to memory management, as some people speculated that the daemon was crashing because of a RAM issue. My solution appears to work regardless of whether I alter that value.

Intellij issue resolving dependency for spring kotlin

Intellij is giving me errors all around for brand new kotlin/spring project and I cannot build or run the project from the IDE.
If I do it from the command line however, there are no issues and I can build and run the app.
'classpath' in 'org.gradle.api.artifacts.dsl.DependencyHandler' cannot be applied to '(groovy.lang.GString)'
'apply' in 'org.gradle.api.plugins.PluginAware' cannot be applied to '(['plugin':java.lang.String])'
Cannot access class 'java.lang.String'. Check your module classpath for missing or conflicting dependencie
Type mismatch.
Required:
java.lang.String
Found:
kotlin.String
Any ideas to what may be the issue?
I tried Kotlin multiplatform JVM type mismatch in InteliJ but doesn't seem to fix the issue.
UPDATE:
Cleared gradle caches, reinstalled Intellij, Import project that was created from start.spring.io with Gradle and Kotlin selected.
Using default gradle wrapper and project jdk (the path says jre)? gives me an error. Open gradle settings just opens the file explorer.
Using default gradle wrapper and machine local JDK same issues with the dependencies from above.
This issue comes up if you set up your own module inside IntelliJ and you think that since you are doing a Kotlin (Maven) project, the SDK should be set to Kotlin. Wrong!
The problem is shown in the first image. The project SDK is set to Kotlin.
Change it to Java. Probably any 8+ Java will be good enough.
This solves the IDE errors and the compiler errors as well.
Unset KOTLIN_HOME and other Kotlin- or Java-related settings you may have in your environment (env to check, unset NAME to unset.)
Then kill any Gradle daemon still running (pkill -f GradleDaemon) and test your Gradle build from the terminal. If all goes well, remove the .idea directory; restart IDEA, making sure to run it without the stray environment variables (for example, launch idea.sh from the terminal where you unset them); and re-import your project, with the choice of using the default Gradle wrapper.
If you need to use standalone Kotlin versions, installed for example through SDKMAN, consider taking the SDKMAN activation lines out of your shell init file (.bashrc for Bash) and into a standalone script (say, ~/bin/sdkman) that will also change your shell prompt (PS1 in Bash) to remind you that you have entered a SDKMAN-managed CLI session.

Android Studio Gradle Build Error: Read Time Out

I have the latest Android Studio IDE installed on my Windows 10 laptop, and it was working fine until my windows operating system made a huge automatic update.
Now, when start my Android Studio IDE, I get the following error and it doesn't build.
Gradle sync failed: Read timed out Consult IDE log for more details
(Help | Show Log) (3m 34s 195ms)
I need help on this.
I encounter this error "Read Time Out", and I simply choose menu item: File -> Invalidate Caches / Restart... to fixed it.
[UPDATE]
I just encounter this error for second time, this time Invalidate Caches / Restart... not able to fix it, but then I try close the android Studio, killall -9 java to ensure all java process has been terminated, then relaunch Android Studio, no more error.
[UPDATE 2]
I just encounter this error and I fixed it by replug the phone cable and rerun.
I got around this issue by turning on Offline Mode in the Gradle tool window.
I have just synced the Project with Gradle files and it worked
Editing global gradle.properties with the following line was the fix for me:
org.gradle.jvmargs=-Dorg.gradle.internal.http.connectionTimeout=120000 -Dorg.gradle.internal.http.socketTimeout=120000
For Chinese users who often use a proxy to download dependency jars, the cause is often proxy settings.
We should check multiple places if the proxy is correctly configured.
Android Studio Settings - Appearance & Behavior - System Settings - HTTP Proxy
${project_root}/gradle.properties
~/.gradle/gradle.properties
In my case, I somehow once configured an HTTP proxy in ~/.gradle/gradle.properties, which was forgotten later. Then when I dealt with a SOCKS5 proxy in IDE Settings and project-level gradle.properties, things always run into trouble. Finally, deleting invalid proxy settings in ~/.gradle/gradle.properties save my day.
I fixed the error by inserting following lines in gradle.properties:
systemProp.org.gradle.internal.http.connectionTimeout=180000
systemProp.org.gradle.internal.http.socketTimeout=180000
This sets the Gradle's connection timeout from the default 30s to 180s (3m).
In my case the read timeout occurred because my computer is behind a HTTP proxy, and it failed to timely connect to http://jcenter.bintray.com.
For more info about the Gradle options, you can refer to https://github.com/gradle/gradle/issues/3370
Simple Answer:
Check the Internet Connection - it should not fluctuate while building the project
File-->>Sync Project with Gradle File
Build>> Clean Project Or Rebuild Project.
I just removed
include ':app'
from setting.gradle and then sync project
it will fails again
then write it back an re-sync and then error gone and will start downloading.
Here's what worked for me (on Windows):
From C:\Users\{$user}\.gradle
Delete these 3 folders:
caches
daemon
wrapper
Then restart Android Studio and Gradle should start downloading automatically
None of the answer worked for me.
I solved it by
Delete project>.gradle directory
File>Sync Project with Gradle Files
In my case it was due to Jitpack.io server down, causing my project unable to build. So I just enabled the Offline Mode for gradle to continue developing my project while Jitpack.io is resolving their server issue.
You will see more info when you click "build" on top of the "read time out" message in build output. In my case, it was a facebook dependency issue so I just had to upgrade it to a newer version.
In my case, it was a firewall issue. After adding Android Studio to its whitelist everything is working fine.
A simple Clean Project + Rebuild Project worked for me
I resumed working on my project after a long time and I was using an Old version of navigation dependency.
after updating version to versions.navigation = "2.3.0" from versions.navigation = "2.3.0-aplha01" my issue was resolved.
so in short make sure you are using latest version of gradle and all libraries (compatible with your gradle version).
Above fixes didn't work for me on MacOS Big Sur 11.5.1 after updating to the new version of Arctic Fox 2020.3.1 Patch 3.
My issue with this was resolved by doing the following:
Close your Android project
Navigate to the root folder of you project
Remove the '.gradle' and '.idea' folders
Start your Android project, which will start the build process. Let this finish
Now the build should succeed. If not, also do an 'Invalidate caches/restart'
In my case, this error was showing up while I am trying to create a new project,
and the default Kotlin Gradle plugin API version was the culprit,
While building/Gradle sync I noticed that the sync process is always getting stuck at the downloading kotlin.gradle.plugin.api:1.5.21,
So I searched for 1.5.21 in the build.gradle and updated it to the latest version, and it worked.
Just Simple Step and you Got Solution.
Android Studio -> FILE -> Invalid Caches / Restart -> Invalidate and Restart
Done Keep Code ☻♥
In my case, Android Studio Arctic Fox | 2020.3.1 Patch 4 (Windows)
I have try 3 step/solution;
Delete 2 root folder .gradle & .idea but still give 'Read timeout'
Invalid Caches/Restart also resulted 'Read timeout'
Close Android Studio, repeat solution 1, monitor 'Build Output' log, then choose 'Disable gradle offline..." , wait and let Android Studio do its thing, then on the log Build showed "BUILD SUCCESSFUL in 28s". Then, I try to run the app just to check and my apps still work as usual.
*Remark: This case happened might be because of my Android Studio IDE Version outdated. As for now, latest version is Android Studio Dolphin | 2021.3.1 Patch 1 .
This error got due to the internet connection during gradles files connection interrupts.
I tried the following techniques but unfortunately, didn't get any solution.
File->Invalidate Cache.
File->Sync Project with .gradle files
Delete Project .gradle and .idea files.
I got the solution to update gradle-wrapper.properties 6.8 to 7.1 after successfully sync revert back from 7.1 to 6.8
#distributionUrl=https://services.gradle.org/distributions/gradle-7.1-bin.zip
distributionUrl=https://services.gradle.org/distributions/gradle-6.8-bin.zip
Use the following code in gradle.properties :
systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost
org.gradle.daemon=false

Resources