Does quarkus-maven-plugin support multi-module projects? - quarkus

I'm trying to convert a multi-module Maven project from vanilla Java EE 8 to Quarkus, and it seems that ArcAnnotationProcessor throws exceptions about unsatisfied dependencies for all injection points referencing dependencies located in a different module.
Is there any workaround, short of merging the modules?

Answering my own question:
According to the Quarkus CDI guide,
The bean archive is synthesized from:
the application,
application dependencies that contain a beans.xml descriptor or a generated Jandex index (META-INF/jandex.idx),
and Quarkus integration code.
After adding a beans.xml to each of my reactor modules, ArC no longer complains about missing dependencies.

Related

Managing runtime dependencies in a maven reactor project

I have a maven reactor project with a rest module and a war module. The war module is a wrapper for the rest module along with the web.xml file. I am trying to understand if it's a good practice to maintain all the runtime dependencies in war module. For instance, if I am pulling in a dependency X (which has an interface X) in the rest module, I want to pull the runtime dependency of X as part of the war module. This way all the compile scoped dependencies are in the rest layer pom and all the runtime dependencies are in the war layer.
Note: I don't see a case where the rest layer will be pulled in by any other pom file other than the war project.
Can anyone see a problem with this approach? Am I missing anything that I would regret down the road?
Example:
Project A has two modules: project-rest and project-war. Project-war is a wrapper for the project-rest and has some web filters around authentication in the web.xml (there is no source code in this module).
Project-rest obviously has REST resources and makes calls to the service layer. The service layer is divided into different projects based on the implementations, project-service is the interface and project-service-hibernate is the implementation. As far as managing dependencies in project-rest, all I need is the compile-time dependencies for the project to build. I am planning to add the project-service dependency to the project-rest pom file and project-service-hibernate as a runtime dependency on the project-war pom file. The goal here is to separate out and manage all the runtime dependencies in the war module and the compile-time dependencies in the rest module.
Actually, I would prefer to pack all the dependencies (both the runtime and the compile dependencies) into the rest module.
In this way, you see what compile and runtime dependencies belong together.
Especially, if the war has no source code, I would not add dependencies.

Spring boot war file with unnecessary jars

I am making war packaging of my spring boot. made spring boot starter tomcat as provided, removed spring boot maven plugin.
But I still see tomcat jdbc and tomcat juli, to name a few (even junit, but it could be from other custom dependencies, so discounting this for this question). I am using logback, but I see log4j over slf4j from starter web.
Can I ask, how to skip unwanted jars and keep my package nice and tidy
Maven has the concept of "scope" for dependencies. You probably know the scope test which is used for unit test dependencies which should not go into the final product. Use this scope for junit.
What you need is the scope provided for the Tomcat dependencies. This tells Maven: "Don't include it; when the code is run, someone else will make sure this dependency is on the classpath".
The dependency log4j-over-slf4j is necessary when one of your dependencies still uses log4j to log. log4j-over-slf4j contains the code to redirect those calls to logback.
Now you will face the case where you can't change the scope because it's in a POM of someone else.
The correct solution here is to define the dependency with the correct scope (and version) in a dependencyManagement element in your POM. This definition will be used when any POM asks for this group+artifactId. So even when some deep dependency of Spring Boot pulls that in, your WAR will be build with the version and scope from the dependencyManagement element.
See also:
Dependency Scopes
Dependency Management

Spring Boot - package application classes as a jar in BOOT-INF/lib

I am using Spring Boot 1.4.1 with Gradle 3.1. The module which has the Spring Boot plugin applied creates its own jar with the jar task, and also has the 'fat' jar created with bootRepackage. However, the classes from that module are in BOOT-INF/classes, but I would like them to be in a separate jar in BOOT-INF/lib. How to do this?
EDIT: I know I can move the code to a separate module, but for various reasons I can't make such a split (unless there is no other way). I am looking for a single-module solution, if one exists.
You'll need to set up a multi-project build and move all of your Jersey-related classes into a separate project. You can then depend upon this new project in your Spring Boot project using a project dependency. For example:
dependencies {
compile project(':jersey-endpoints')
}

Liferay plugin package dependencies and Maven

I'm starting to develop a Spring-MVC Portlet project. I did all the configuration needed in portlet.xml and web.xml but still a little bit confused about the Spring dependencies that have been declared in liferay-plugin-package.properties. In fact, should I add the required dependencies in this file and declare them as provided in the project pom.xml?
I use Maven as the build and dependency management tool and all examples I've found are based on the ANT project.
How does Liferay is processes the dependencies declared in liferay-plugin-package.properties ?
Besides, a maven compile fails since it does not find Spring MVC libraries required for the Spring MVC portlet project. What do you think is missing (or) incorrect in the configuration to create Spring MVC portlet ?
thanks in advance
The easiest way to go about this is to use the Maven Archetype that's been provided by liferay.
The Maven dependency is:
<dependency>
<groupId>com.liferay.maven.archetypes</groupId>
<artifactId>liferay-portlet-spring-mvc-archetype</artifactId>
<version>6.2.10.15</version>
Install this archetype in your local repository and then create a Maven project from this archetype.
This will have all the prerequisites needed for your project.
It is not necessarily to put any dependencies into liferay-plugin-package.properties file. All you need for your Spring MVC Portlet project should be presented in the project pom.xml file.
All dependencies are accessible from maven repo, e.g. http://mvnrepository.com/artifact/org.springframework/spring-webmvc-portlet

What is the difference between spring-context and spring-core dependencies?

Hello I am new to the Spring and maven world, and I want to know what is the difference between this 2 dependencies?
Its a simple question.. I am having trouble with my pom.xml file, so I want to know everything :).
Thanks in advance.
These are actually 2 of many Spring Framework modules. You can easily find what packages these artifacts contain, using this site:
http://mvnrepository.com/artifact/org.springframework/spring-core/3.1.1.RELEASE
This can give you information about classes contained within a particular artifact and probably about the its purpose.
For Spring Framework, spring-core contains mainly core utilities and common stuff (like enums) and because it's really critical for Spring, probably all other Spring modules depend on it (directly or transitively).
In turn spring-context provides Application Context, that is Spring's Dependency Injection Container and it is probably always defined in POMs of artifacts that use Spring Framework somehow. In fact, spring-context depends on spring-core so by defining spring-context as your dependency, you have spring-core in your classpath as well.

Resources