Getting a "cannot find proxyClass" when using vertx's WebApiServiceGen - gradle

I'm following this example https://github.com/vert-x3/vertx-examples/tree/master/web-api-service-example. Instead of using Java and Maven I'm trying to do it in Kotlin and Gradle. When I run the project I get a Cannot find proxyClass: error. My build.gradle file has this
annotationProcessor "io.vertx:vertx-codegen:$vertxVersion:processor"
annotationProcessor "io.vertx:vertx-web-api-service:$vertxVersion"
compileOnly "io.vertx:vertx-codegen:$vertxVersion"
compile "io.vertx:vertx-web-api-service:$vertxVersion"`
I can build successfully with Gradle

Related

QueryDSL annotation processor - jpa classifier no longer works

My annotation processing has suddenly stopped working. I've made no known changes to my configuration and haven't been able to find any references to the error I'm getting.
Gradle Version: 7.5.1
QueryDSL Version: 5.0.0
build.gradle:
implementation "com.querydsl:querydsl-core:${querydslVersion}"
implementation "com.querydsl:querydsl-jpa:${querydslVersion}"
implementation "com.querydsl:querydsl-apt:${querydslVersion}"
...
annotationProcessor ("javax.annotation:javax.annotation-api:1.3.2")
annotationProcessor ("org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final")
annotationProcessor ("com.querydsl:querydsl-apt:${querydslVersion}")
annotationProcessor ("com.querydsl:querydsl-apt:${querydslVersion}:jpa")
Error:
* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':annotationProcessor'.
> Could not find querydsl-apt-5.0.0-jpa.jar (com.querydsl:querydsl-apt:5.0.0).
Searched in the following locations:
file:/Users/devuser/.m2/repository/com/querydsl/querydsl-apt/5.0.0/querydsl-apt-5.0.0-jpa.jar
Found a work around (9/24):
The version of querydsl-jpa is controlled by my JHipster BOM, which pulls in 5.0.0. But if I specify the 4.4.0 version in my annotation processor it works. So it seems like the behavior changed in 5.0.0, or the classifier needs to be specified in some other way. But this is how I got it to work again.
implementation group: 'com.querydsl', name:'querydsl-jpa', version:'+'
annotationProcessor group: 'com.querydsl', name: 'querydsl-apt', classifier: 'jpa', version: '4.4.0'

java.lang.NoSuchMethodError: org.mockito.MockingDetails.getMockCreationSettings() - Gradle links same class twice for Mockito jar

I have configured the following dependencies in the build.gradle file.
testCompile "org.springframework.boot:spring-boot-starter-test"
testCompile "org.mockito:mockito-all:1.10.19"
And when running the tests getting the following error stack trace.
java.lang.NoSuchMethodError: org.mockito.MockingDetails.getMockCreationSettings()Lorg/mockito/mock/MockCreationSettings;
at org.springframework.boot.test.mock.mockito.MockReset.get(MockReset.java:107)
at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.resetMocks(ResetMocksTestExecutionListener.java:81)
at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.resetMocks(ResetMocksTestExecutionListener.java:69)
at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.beforeTestMethod(ResetMocksTestExecutionListener.java:56)
at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:289)
And I've tried to debug it. Found something weird in the IntelliJ linked jar files. Almost most of the classes in the Mockito jar displayed twice.
Refreshing gradle dependencies or cache clear both did not work.
After so many days, I figured out that the issue is with the mockito jar version mismatch.
Changing the version from mockito-all to mockito-core build.gradle to
testCompile "org.mockito:mockito-core:2.24.0"
testCompile ("org.springframework.boot:spring-boot-starter-test") {
exclude group: "org.mockito", module: "mockito-all"
}
fixed my problem.
Thanks

IntelliJ IDE 2018.3 Ultimate + Gradle 5.2.1 AND compileOnly

I was about building a gradle 5 project in IDEA.
The lombok dependency was set to compileOnly in the build.gradle file and running it resulted in success from command line and IDEA gradle tool as well.
"Funny" fact, that lombok isn't included in Source Sets, so my lombok imports are failing....
I googled for it, and in theory since IDEA 2017.2 + Gradle 4 it's a fixed issue, IDEA should pick up compileOnly dependencies as well.
In the reality, it does not work.
Any Gradle plugin, or idea to solve this issue? :)
Thanks.
ui.:
VERSION 1
Using compileOnly & annotationProcessor both for prod code and tests resulted in
from command-line, gradle is able to run everything with SUCCESS
from IDEA, it's impossible, imports are failing with lombok
VERSION 2
Using compile & annotationProcessor
from command-line, gradle is able to run everything with SUCCESS
from IDEA, imports are OK, everything is fine
dependencies {...compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor("org.projectlombok:lombok:${lombokVersion}")
testCompileOnly "org.projectlombok:lombok:${lombokVersion}"
testAnnotationProcessor("org.projectlombok:lombok:${lombokVersion}")...}
According to https://projectlombok.org/setup/gradle
you need to write in your build.gradle
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.6'
annotationProcessor 'org.projectlombok:lombok:1.18.6'
}
It works for me
You can upgrade the IDEA version to 2019.1 or use the 4.x version of Gradle.

Could not find method annotationProcessor() for arguments

Following is my build.gradle file. My project compiles locally (IntelliJ-IDEA is my IDE), but when I push it to GitHub, the travis-ci build fails. My gradle version is gradle-5.2.
apply plugin: "java"
apply plugin: 'jacoco'
sourceCompatibility = 1.8
version = "1.0"
repositories {
mavenCentral()
}
dependencies {
annotationProcessor 'org.projectlombok:lombok:1.18.2'
compileOnly 'org.projectlombok:lombok:1.18.2'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.2'
testCompileOnly 'org.projectlombok:lombok:1.18.2'
}
FAILURE: Build failed with an exception.
Where: Build file '/home/travis/build/XXX/PROJECT/build.gradle' line: 33
What went wrong: A problem occurred evaluating root project 'PROJECT'.
Could not find method annotationProcessor() for arguments [org.projectlombok:lombok:1.18.2] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
The annotationProcessor in build.gradle seems not to be parsed, I'm not sure what the underlying issue is. Any help would be appreciated. Thanks.
As #M.Ricciuti said, the annotationProcessor is available from gradle versions 4.6 and later. So what we should do is just confirm that gradle's version >= 4.6. We'd be better off using the Wrapper.Thanks, that's all.
A ery easy way to update the gradle version of your project in intellij is to go to inside your project, gradle, wrapper, gradle-wrapper.properties and update the version in the line below:
disributionUrl=https://services.gradle.org/distributions/gradle-4.6-bin.zip

Where is the "compileOnly" task in a gradle project?

I created a minimal build.gradle file:
apply plugin: "java"
and put a minimal set of Java files in src/main/java.
When I run:
gradle dependencies
I see various tasks with no dependencies, such as:
compileOnly - Compile only dependencies for source set 'main'.
No dependencies
However, when I try to run one of them:
gradle compileOnly
I see:
Task 'compileOnly' not found in root project '21-java'.
So where is this task and how can I see it?

Resources