Corda - Gradle Error With Quasar When Upgrading to Corda 4.3 - gradle

I've updated my build.gradle file to Corda 4.3, however applying this plugin...
apply plugin: 'net.corda.plugins.quasar-utils'
...causes the following error when trying to refresh gradle...
A problem occurred evaluating root project 'template'.
> Failed to apply plugin [id 'net.corda.plugins.quasar-utils']
> Could not create an instance of type net.corda.plugins.QuasarExtension_Decorated.
> No signature of method: org.gradle.api.internal.provider.DefaultPropertyState.convention() is applicable for argument types: (java.lang.String) values: [co.paralleluniverse]
Any ideas what is causing this?

I had the same problem executing Corda 4.4 release. Basically you have to update your gradle version to recognize some dependencies in gradle.
First of all, execute the comand: gradle -version
After that, you have to update your gradle version according to the gradle version supported by your current Corda version. In my case, It is supported by gradle version 5.4.1. So, to execute an upgrade, try this: ./gradlew wrapper --gradle-version 5.4.1
Next, check again your gradle version using ./gradlew --version (in the CorDapp directory)
Finally, you can execute your task. So, in my case I would like to execute a test with heap dump allocating more memory and check an OOM. I execute the follow command:
./gradlew test -Dlog4j.configurationFile=../config/test/log4j2.xml -Dcapsule.jvm.args=["-Xmx10G","-Xms512m","-XX:+UseG1GC","-XX:+HeapDumpOnOutOfMemoryError"]
That is it!

Have you tried with gradle-5.4.1?
Source : https://www.corda.net/blog/corda-version-upgrade-guide/

Related

Issue with Gradle and Gradlew

I have a project that has both gradle (6.3) and gradlew. When I do a "./gradlew build", all is fine. But when I do "gradle build" I have the following error:
What went wrong:
A problem occurred evaluating root project ....
> Failed to apply plugin [id '...']
> Could not create an instance of type ....
> org.gradle.api.file.ProjectLayout.directoryProperty()Lorg/gradle/api/file/DirectoryProperty;
Any idea what could cause the wrapper to work OK and not gradle?
Thanks - C
./gradlew build uses a different version of Gradle than what gradle build uses. That's exactly the reason for the gradle wrapper: it will look at the contents of the file gradle/wrapper/gradle-wrapper.properties to figure out which version of Gradle to use, and then automatically downloads and uses that Gradle version. The Gradle you have installed, version 6.3, is newer than the one used by the gradlew (gradle wrapper) script. This is why gradle build does not work: your build script is incompatible with this new gradle version, it only works with the older one used by the gradlew script.
The error you see is caused by an incompatibility of your Gradle build script with a newer Gradle version. Let's look at the first part:
> Could not create an instance of type ....
> org.gradle.api.file.ProjectLayout.directoryProperty()Lorg/gradle/api/file/DirectoryProperty;
It tells you that Gradle is looking for a method directoryProperty in the class ProjectLayout. This member exists up to Gradle Version 5 (see https://docs.gradle.org/5.0/javadoc/org/gradle/api/file/ProjectLayout.html) but is no longer present in Gradle 6.3 (https://docs.gradle.org/current/javadoc/org/gradle/api/file/ProjectLayout.html). So the Gradle API changed, and your build script is no longer compatible.
The second part of the error:
> Failed to apply plugin [id '...']
tells you that this happened in the implementation of the plugin (given by the ... in the id). This means that to fix the error with newer gradle versions, the plugin needs to be modified.

gradlew wrapper update to new version error that you have old version

Why gradle build failed:
./gradlew wrapper --gradle-version 6.2
FAILURE: Build failed with an exception.
* Where:
Build file '/home/yburtsev/IdeaProjects/spring-io-testcontainers-workshop/build.gradle' line: 3
* What went wrong:
An exception occurred applying plugin request [id: 'org.springframework.boot', version: '2.2.4.RELEASE']
> Failed to apply plugin [id 'org.springframework.boot']
> Spring Boot plugin requires Gradle 4.10 or later. The current version is Gradle 4.4.1
* 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
BUILD FAILED in 0s
I manually edit distributionUrl in gradle-wrapper.properties to 6.2 version and than run gradlew wrapper command successfully.
link to project: https://github.com/bsideup/spring-io-testcontainers-workshop
The wrapper task will be run with the previous version of Gradle first. In your case, that is apparently 4.4.1. I don't know why it evaluates the whole project build for the wrapper task, but it does. And since you are using a plugin that is not compatible with that version, it fails.
As you already did, it can be circumvented by editing the file gradle/wrapper/gradle-wrapper.properties manually and set it to the new version. But remember to run the wrapper task again after you did that. This will make it download the new version and use that to update the other wrapper files if needed.
There is a corresponding Github issue for this problem. If you like, you can go put a "thumbs up" on it to give it more attention: https://github.com/gradle/gradle/issues/884.

"unable to resolve class" error after upgrading gradle 3 to gradle 4

Grails version: 3.2.9
Gradle initial version: 3.4.1 (everything works fine with this version)
Gradle upgraded version:4.10.3
Plugin: org.grails.grails-gsp
When I run gradlew war after upgrading gradle version to 4.10.3 I start to get the following error during execution of compileGroovyPages task:
dashboard_gsp.groovy: 2: unable to resolve class com.abnd.CarStatusEnum
# line 2, column 1.
import com.abnd.CarStatusEnum
^
Location of class com.abnd.CarStatusEnum is src/main/groovy/com/abnd/CarStatusEnum in the same project where the build is being run and gradlew war task completes successfully with gradle version 3.4.1. However when I upgrade gradle version to 4.10.3 then I start to get this error. Same happens with gradle version 4.1.
1) Any clue what can be the problem ?
2) Is that a good idea to use gradle version 4.x.x or 5.x.x with grails version 3.x.x as with gradle 5.x.x I start to get even more issues as some grails plugins(like grails-gsp v3.3.2 which is latest stable version) use some features that have been deprecated in gradle 4.x.x and removed from gradle 5.x.x (see the error bellow)?
Failed to apply plugin [id 'org.grails.grails-gsp']
Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.
1) Any clue what can be the problem ?
Yes. The error message is a clue that the GSP compiler can't find the enum class. This is because our plugin isn't compatible with Gradle 4.10.3.
2) Is that a good idea to use gradle version 4.x.x or 5.x.x with
grails version 3.x.x
No. Those Gradle versions are not supported with the version of Grails you are using.
I hope that helps.

How to run a single unit test using gradle wrapper 2.2.1 from command line

Using Android studio with gradle wrapper version 2.2.1, I am trying to run all the tests in one single test class, as well as a specific test inside that class and have tried using:
./gradlew test --tests DownloadsActivityTest
like the documentation suggests, as well as
-DandroidTest.single=DownloadsActivityTest
But neither of these versions work.
How do I run a single test class, and a single test from the command line using the gradle wrapper?
./gradlew --version
------------------------------------------------------------
Gradle 2.2.1
------------------------------------------------------------
Build time: 2014-11-24 09:45:35 UTC
Build number: none
Revision: 6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a
Groovy: 2.3.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_51 (Oracle Corporation 24.51-b03)
OS: Linux 3.17.6-200.fc20.x86_64 amd64
[16:33][j#localhost:~/myHomeDir]$ ./gradlew test --tests DownloadsActivityTest
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.3 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
FAILURE: Build failed with an exception.
* What went wrong:
Problem configuring task :app:test from command line.
> Unknown command-line option '--tests'.
* Try:
Run gradlew help --task :app:test to get task usage details. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.466 secs
To only run instrumentation tests (androidTests) in a specific test class, execute:
./gradlew app:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.example.android.testing.blueprint.ui.espresso.EspressoTest
To only run local tests ("unit", JVM tests) in a specific test class or package execute:
./gradlew :app:testDebugUnitTest --tests "com.example.android.testing.blueprint.unit.integrationTests.*"
./gradlew :<module name>:test<CapitalCasedBuildVariant> --tests "<Test name pattern>"
It is important to specify the module name where the test lives, otherwise, when gradle builds dependent modules, it will attempt to test them, and might fail because none of the tests fit the test pattern:
No tests found for given includes: [FooTest]
Also, unless you specify the fully-qualified-name (FQN) of the test, your test name pattern should start with a *.
In my case, I have a module named app and a variant named localDebug, and I wanted to test FooTest, so I ran:
./gradlew :app:testLocalDebug --tests "*FooTest"
This is supported in Android Studio 1.1, using the Android Gradle plugin v1.1.0.
Follow the guide here
The Android Gradle plugin, as of 1.0.0, doesn't have support for running single Android tests. The feature request for it is filed at https://code.google.com/p/android/issues/detail?id=74196.
I know that better test support in general is very high on the post-1.0 priority list, but I can't say with any certainty when this will be implemented.

Gradle plugin compatibility - how to find out?

Can Gradle plugins for 1.11+ be expected to work for 2.+, and if not, how can one find out the state of compatibility?
Specifically, I have had success using Gradle 1.11 in a project spring-boot project. When upgrading to Gradle 2.2, I noticed that the spring-boot plugin does not seem to be available, although I haven't found any references to a particular Gradle version in the Spring Boot Gradle documentation (http://docs.spring.io/autorepo/docs/spring-boot/1.2.0.BUILD-SNAPSHOT/reference/html/build-tool-plugins-gradle-plugin.html).
Using Gradle 2.2, I get:
* What went wrong:
A problem occurred evaluating root project 'NN'.
> Failed to apply plugin [id 'spring-boot']
> A problem occurred configuring project ':webapp'.
> Extension of type 'SpringBootPluginExtension' does not exist. Currently registered extension types: [DefaultExtraPropertiesExtension, DefaultArtifactPub
licationSet_Decorated, ReportingExtension_Decorated, DefaultProjectSourceSet_Decorated, DefaultBinaryContainer_Decorated]
It depends on the particular plugin, and would ideally be tested/documented there. 1.x to 2.x was a big jump in terms of the Groovy version used by Gradle, which can cause compatibility issues for plugins implemented in Groovy. Also, 1.x plugins using deprecated or internal APIs may not work in 2.x.

Resources