IntelliJ doesn't generate metamodel classes after configuration (with gradle) - java

What I did so far:
Enabled annotation processing in idea's preferences and selected Obtain processors from project classpath, then selected Module content root
Added compileOnly group: 'org.hibernate', name: 'hibernate-jpamodelgen', version: '5.6.0.Final' dependency to build.gradle
Built the project
I can see the route build/generated/sources/annotationProcessors/main where main is a generated source route but it's empty and no metamodel classes there.
I can find these simple steps everywhere but unable to create metamodel classes.
What am I missing or doing wrong?

I managed to fix the issue with the following additional dependency: annotationProcessor group: 'org.hibernate', name: 'hibernate-jpamodelgen', version: '5.6.0.Final'
Just for future reference.

Related

gwt-user.jar with Java 11 - The package javax.xml.parsers is accessible from more than one module: <unnamed>, java.xml

I am trying to switch to GWT 2.10 and Java 11 (using Eclipse container for GWT and gradle for dependencies), but because some java packages are bundled in gwt-user.jar I get the error:
The package javax.xml.parsers is accessible from more than one module: <unnamed>, java.xml
Searching the web, the solutions I found were either to repackage the gwt-user.jar by removing the packages or to turn my project into a module (which I don't see it recommended and also I don't know what implications/chain reaction has). Neither of these options seem good.
Is there an alternative to solve this issue?
In the end, I solved my issue by getting the dependencies from com.google.gwt bundle. But I had a lot of issues here because I am using gwt material, which at that moment was also getting the "big jars" dependencies. So my gradle looks like this now:
//for Eclipse with GWT plugin (which creates the gwt classpath container):
classpath {
...
containers GWT_CONTAINER //from my gradle properties - com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER/gwt-2.10.0
}
def gmdVersion = '2.6.0' //library GWT Material
def gwtVersion = GWT_VERSION//from my gradle properties file - 2.10.0
def gwtNamespace = 'com.google.gwt' //org.gwtproject in the future i think
api (group: "${gwtNamespace}", name: 'gwt-dev', version: GWT_VERSION)
api (group: "${gwtNamespace}", name: 'gwt-user', version: GWT_VERSION)
api (group: 'com.github.gwtmaterialdesign', name: 'gwt-material', version: "${gmdVersion}") {
exclude group:"${gwtNamespace}", module: "gwt-user"
exclude group:"${gwtNamespace}", module: "gwt-dev"
...
}
api (group: 'com.github.gwtmaterialdesign', name: 'gwt-material-jquery', version: "${gmdVersion}") {
exclude group:"${gwtNamespace}", module: "gwt-user"
exclude group:"${gwtNamespace}", module: "gwt-dev"
...
}
api (group: 'com.github.gwtmaterialdesign', name: 'gwt-material-addins', version: "${gmdVersion}") {
exclude group:"${gwtNamespace}", module: "gwt-user"
exclude group:"${gwtNamespace}", module: "gwt-dev"
...
}
Depending on each person's project structure, some other dependencies might also cause a similar issue, so if this doesn't work from the start, you need to check which other classes are imported from multiple dependency jars. Or, you can try to create a new project where you can simulate the error just for GWT related classes (just a simple new empty project where you configure just basic dependencies), then you try this solution and it should work.

How to resolve the DNS issue with GCP Pub/Sub

Background:
I'm working on creating a messaging library that basically abstracts GCP Pub/Sub. Accordingly, I am creating a fat JAR with relocated packages, and this fat JAR is imported in other projects. The point to isolate the fat JAR's dependencies from those of the importing projects.
When I test this locally from an IDE, the fat JAR works fine. However, when I export a project to a JAR and run it, I get the following error.
I have also checked the logs and found the following which I have found in this issue that these configurations are correct.
Is there something wrong with the address provided here, or should I configure anything on my end?
These are the dependencies I'm fetching for the library via Gradle.
implementation group: 'io.grpc', name: 'grpc-okhttp', version: '1.40.1'
implementation group: 'io.perfmark', name: 'perfmark-impl', version: '0.25.0'
implementation group: 'com.google.cloud', name: 'google-cloud-pubsub', version: '1.114.6'
implementation group: 'io.grpc', name: 'grpc-context', version: '1.42.2'
implementation group: 'org.slf4j', name: 'slf4j-api', version: "${slf4jApiVersion}"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testImplementation "org.junit.jupiter:junit-jupiter:5.8.1"
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
Thanks.

Why does my java project still work even though its missing some packages?

I am working on a Dubbo project and when I digging a little deep into its source code. I found these code in Dubbo's source code:
I think this shows that my project missing the org.jboss.*package
(IDEA has mark these packages in red)
But somehow this project still working, doesn't it supposed to not working due to it has some package missing?
By the way my project is organized by gradle and the build.gradle is like this:
dependencies
{
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
compile group: 'org.apache.dubbo', name: 'dubbo-spring-boot-starter', version: '2.7.8'
compile group: 'org.apache.zookeeper', name: 'zookeeper', version: '3.6.2'
compile group: 'org.apache.curator', name: 'curator-framework', version: '5.1.0'
}
If this wouldn't be some library's de-compiled byte-code but your application's source code, this would rather be an issue. And it's not missing anything, but Gradle will pull in org.jboss.netty on demand, which will then pull in another 8 libraries, which may evetually even pull in further libraries.

How can I use third party dependencies in custom task under buildSrc in Gradle

I have followed this guide for creating a custom task with Gradle.
http://www.ysofters.com/2015/02/26/how-to-create-gradle-project-with-custom-task-classes-in-groovy/
I also had a look at the gradle doc. https://docs.gradle.org/current/userguide/custom_tasks.html
It's very clear, and I can get the examples to compile and use the tasks, so everythings fine so far.
However, examples only show the import of gradle api-files, i.e.
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction
I want to add some more dependencies i.e
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean
import org.springframework.core.io.FileSystemResource
but I can do that - gradle will complain and say "unable to resolve class .."
I tried to also set up spring-core and apache-commons under the buildscript->dependencies closure in build.gradle but it didn't make any difference i.e.
buildscript {
dependencies {
classpath group: 'org.springframework', name: 'spring-core', version: springVersion
classpath group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
.....
So, what am I missing - how can I use third party dependencies in my custom task class?
you need to put a build.gradle file into your buildSrc directory. You can checkout the buildSrc/build.gradle file from the gradle project itself as an example: https://github.com/gradle/gradle/blob/v4.1.0/buildSrc/build.gradle

How do I get IntelliJ to resolve Gradle dependencies for custom source sets?

When IntelliJ opens a build.gradle file it will generate an IntelliJ project with the Gradle dependencies resolved and added to the project scope. This works great for the "compile" source set and the "test" source set, however I can not get this to work for custom source sets.
I want to have IntelliJ resolve the dependencies for my componentTest source set. How do I tell IntelliJ to resolve these dependencies and add them to scope?
dependencies {
// main source set, "compile" scope in IntelliJ
compile(group: 'com.google.guava', name: 'guava', version: '18.0')
// test source set, "test" scope in IntelliJ
testCompile(group: 'junit', name: 'junit', version: '4.11')
// my custom source set, not added to any scope in IntelliJ
componentTestCompile(group: 'org.springframework', name: 'spring', version: '3.0.7')
}
Details: IntelliJ 13.1.2, Gradle 1.11
This is described in Gradle user guide - http://www.gradle.org/docs/current/userguide/idea_plugin.html and http://www.gradle.org/docs/current/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html
You will need to add something like:
idea {
module {
scopes.TEST.plus += [ configurations.componentTestCompile ]
}
}
to your build.gradle file.

Categories