Unable to run corda tests from IntelliJ - corda

When I select and run a test, the build fails with the message:
"Kotlin: Usage of '#JvmDefault' is only allowed if the flag -Xenable-jvm-default is enabled" for the following files.
corda/serialization/src/main/kotlin/net/corda/serialization/internal/OrdinalIO.kt
corda/serialization/src/main/kotlin/net/corda/serialization/internal/SerializationFormat.kt
corda/serialization/src/main/kotlin/net/corda/serialization/internal/amqp/AMQPSerializer.kt
I have cloned corda from my fork of corda/corda on github, and am on branch master, opened in IntelliJ as per instructions on the docsite. The JDK version is 1.8.0_152 and the Kotlin plugin is on version 1.2.41. I see that the -Xenable-jvm-default is enabled in the corda/build.gradle file. There are no local changes. Could you please advise on what I missed or need to do to fix this?

This can be fixed by invalidating IntelliJ's caches and restarting IntelliJ. See jetbrains.com/help/rider/Cleaning_System_Cache.html.

Make sure you are using the gradle runner to execute the tests on IntelliJ.
Navigate to Build, Execution, Deployment -> Build Tools -> Gradle -> Runner (or search for runner)
Windows: this is in “Settings”
MacOS: this is in “Preferences”
Set “Delegate IDE build/run actions to gradle” to true
Set “Run test using:” to “Gradle Test Runner”

Related

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0 in android studio

I am trying to run my emulator after adding the firebase and google sign in plug ins/dependencies to my gradle.build files and now I am receiving the error
"Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0"
anyone know if I am doing something wrong this is a react native firebase app.
I am not sure what to try. This is my first app I am doing for a project at school and I do not really know what I am doing. I have just been following tutorials online
Solve this issue by deleting the .gradle folder from <NameOfProject>/android and again run npm run android
I think I just had this same problem. I don't have any idea what your error logs are though so I am not certain however this is my error log right here:
`> Task :react-native-gradle-plugin:compileKotlin FAILED
'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm targeta version. 1 actionable task: 1 executed`
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':react-native-gradle-plugin:compileKotlin'. Failed to query the value of task ':react-native-gradle-plugin:compileKotlin' property 'compilerRun Kotlin could not find the required JDK tools in the Java installation. Make sure Kotlin compilat
This error however I fixed by editing the gradle-wrapper.properties file's distributionUrl variable. I changed the distributionUrls gradle version to 7.4.2 the file is in Project-Name\android\gradle\wrapper\gradle-wrapper.properties
My error log is saying that gradle's version of JVM want's to be version 11 and is not but you can check gradle's jvm version by using cd android in the project root directory and after that run ./gradlew --version Change JVM's version from the version it is showing to the version that it says is required like in my case v 11. The way I changed gradle's JVM version required chocolatey which is a package manager. This is where you can require it https://chocolatey.org/install and after you have setup chocolatey open a new terminal that has administrative privileges and run this choco install -y nodejs-lts openjdk11 with the JVM version it is asking for inside your error logs
and finally run npm start and after that npm run android inside a refreshed and new terminal and gradle's JVM version and gradle's version will be updated to the specified versions
We could better help if you could you show us your android/build.gradle and android/app/build.gradle files, but here are more specific instructions than you find in the docs:
In android/build.gradle, dependencies should look something like this:
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.3.10'
classpath("com.android.tools.build:gradle:<version>")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:<version>")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
see: https://github.com/gyani-sunkara/rn-firebase-login-starter/blob/main/android/build.gradle
It is known this works with the classpaths at the beginning.
--
Also in android/app/build.gradle, it is known that the google-services dep works at the end of the file.
apply plugin: 'com.google.gms.google-services'
and make this the last "implementation" under dependencies (around line 272)
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0' // <-- add this; newer versions should work too
see: https://github.com/gyani-sunkara/rn-firebase-login-starter/blob/main/android/app/build.gradle
Then, delete android/.gradle and run npx react-native run-android in the root directory.

How to debug wso2 api manager code in idea

I am trying to run API Manager 4.0.0 from source code, I download product-am and carbon-apimgt from github. How can i debug source code in idea or eclipse ?
First of all, you have to build the product. Follow these steps in order to build the product locally.
Make sure you have installed Java and Maven in your machine.
Download or clone carbon-apimgt repository from
https://github.com/wso2/carbon-apimgt.
Go to carbon-apimgt directory and run mvn clean install command in the terminal. (You can ignore unit tests by running mvn clean install -Dmaven.test.skip=true)
Copy the build version to the clipboard (ex:- 9.12.3-SNAPSHOT)
Download or clone product-apim from https://github.com/wso2/product-apim
Replace the value of carbon.apimgt.version in pom.xml file with the value you copied. (ex:- <carbon.apimgt.version>9.12.3-SNAPSHOT</carbon.apimgt.version>)
Go to product-apim directory and run mvn clean install command in the terminal. (You can ignore integration tests by running mvn clean install -Dmaven.test.skip=true which will save your time)
The built pack can be found in product-apim/modules/distribution/product/target directory.
After building the pack, extract the content in the zip file and run sh bin/api-manager.sh --debug 5005 command.
I recommend JetBrains Intellij IDEA to debug the code easily. So, open the carbon-apimgt project in IDEA. Then Add Configuration > Add new... > Remote JVM Debug > OK. After adding the configuration, you can click on the debug button and start debugging.

Error when running Corda flow tests from IntelliJ

When I run Corda flow tests from IntelliJ, the tests fail with the following errors:
QUASAR WARNING: Quasar Java Agent isn't running. If you're using
another instrumentation method you can ignore this message; otherwise,
please refer to the Getting Started section in the Quasar
documentation.
and
java.lang.IllegalStateException: Missing the '-javaagent' JVM
argument. Make sure you run the tests with the Quasar java agent
attached to your JVM. See https://docs.corda.net/troubleshooting.html
- 'Fiber classes not instrumented' for more details.
How can I fix this?
Corda flows need to be instrumented using Quasar before they are run, so that they can be suspended mid-execution.
To achieve this in IntelliJ, you need to:
Create a run config for your tests
Open the run config and change the VM options to -ea -javaagent:PATH-TO-QUASAR-JAR
In the CorDapp example and templates, quasar.jar is located at lib/quasar.jar, so you'd use -ea -javaagent:../lib/quasar.jar
Alternatively, you can edit the default JUnit run config to use the Quasar javaagent by default, avoiding you having to do this every time you pick a new test to run.
This is a basic error that you get if you don't set Quasar, you need to select your test-> go to Intellij top bar-> Run -> Edit Configurations and then set up like this photo in VM options:
From template readme
We recommend editing your IntelliJ preferences so that you use the Gradle runner - this means that the quasar utils plugin will make sure that some flags (like -javaagent - see below) are set for you.
To switch to using the Gradle runner:
Navigate to Build, Execution, Deployment -> Build Tools -> Gradle ->
Runner (or search for runner) Windows: this is in "Settings" MacOS:
this is in "Preferences" Set "Delegate IDE build/run actions to
gradle" to true Set "Run test using:" to "Gradle Test Runner" If you
would prefer to use the built in IntelliJ JUnit test runner, you can
run gradlew installQuasar which will copy your quasar JAR file to the
lib directory. You will then need to specify -javaagent:lib/quasar.jar
and set the run directory to the project root directory for each test.
Btw, if you face same error in VSCode, you can add
"java.test.config": {
"vmArgs": ["-ea", "-javaagent:../lib/quasar.jar"]
},
to settings.json. The path ../lib/quasar.jar may be different in your project.

Running PHPUnit test in PhpStorm adds "--teamcity" option causing error

I have the latest PhpStorm (2016.2) and PHPUnit phar (5.5.4). For some reason when I run a PHPUnit test in my project in PhpStorm, it is adding on --teamcity to the run command, resulting in a failure:
Testing started at 12:52 PM ...
Unit test suite invoked with a path to a non-unit test: --teamcity
Process finished with exit code 1
I have no idea where this --teamcity option is coming from, it happens no matter what test I run, and even when starting from a blank configuration. I also do NOT have the TeamCity plugin installed, I don't even use TeamCity.
Here's what the full command appears as:
/usr/local/Cellar/php70/7.0.9/bin/php /Users/name/bin/phpunit-5.5.4.phar --configuration /path/to/config/my-phpunit.xml ClassNameTest /Users/name/PhpstormProjects/path/to/tests/unit/app/ClassNameTest.php --teamcity
(sensitive information swapped out)
All I want to do is get rid of this --teamcity option, everything works if I run in a separate terminal window without that option. This only recently started happening, maybe after a PhpStorm update.
tl;dr
I only could resolve this by removing the system installed phpunit instance from my system (Linux):
sudo apt remove phpunit-*
Details
Even if the setting in PhpStorm was to use composer autoloader:
for some reason it ended up using TeamCity from /usr/share/php/PHPUnit/Util/Log/TeamCity.php:
Project's local PHPUnit was 6.2 while the system default was 5.1 -> they're incompatible.
I spent half a day struggling with this. The underlying issue is switching between PHPUnit versions (6.x.x -> 4.x.x). (Happened to me by switching branches)
A click on the refresh button in the PHPUnit preferences fixes it.
(Languages & Frameworks > PHP > PHPUnit)
Make sure the version of PHPUnit it thinks you have matches the one it reports.
This --teamcity option is used by PHPStorm to output tests result.
What you're facing is an issue caused by PHP7 and an old version of PHPUnit.
Remove your PHPUnit 5 and install the latest one (currently 6.2) with composer and use PHPUnit namespaces instead.
More info on this bug: https://github.com/sebastianbergmann/phpunit/issues/2460
Problem was internal to the project. PHPUnit does not contain that error message. Sorry!

Can't get Spring Boot devtools auto restart get to work with 1.3M5 with Eclipse

I cant get SpringBoot autorestart get to work. I simply create http://start.spring.io/ Gradle project with DevTools selected and run 'gradle eclipse' to create eclipse project and 'gradle bootRun' and now I can do some change in project in Eclipse and this doesnt trigger auto restart at all. There is no message in bootRun console, no change detection. Any idea whats wrong here? I tried several times making starter project with http://start.spring.io and no way with auto restart ...
https://spring.io/blog/2015/06/17/devtools-in-spring-boot-1-3
Gradle in Eclipse and Gradle on the command line use different directories for their compiled classes. The dev tools (launched via bootRun) will be looking in build/classes whereas Eclipse will be compiling your changes into bin/classes. Rather than launching your app using gradle bootRun, try launching it in Eclipse instead using Run As -> Java application.
In one terminal:
gradle build --continuous
In second terminal:
gradle bootRun
Reference: https://dzone.com/articles/continuous-auto-restart-with-spring-boot-devtools
BTW, I find it take longer time than the eclipse.

Resources