Does sbt/maven includes the complete dependency in jar file? - maven

I am building a rest API for a previous project. If I add it as dependency to my new rest API project, will all the functionality will be added to my rest API jar file or only the methods which I use? My old project jar is 181M, so the whole will be added to Rest API jar?
Thanks,

Without special configuration, Maven will not include any dependencies in your jar at all. Just the compiled classes from your source code (and generated classes) are included. If you want to include dependencies, you have to tell maven using the maven-assembly-plugin, as described in How can I create an executable JAR with dependencies using Maven?. When you use a different packaging, the dependencies can be included automatically, depending on the packaging type. E. g. when using war, all compile dependencies are added to WEB-INF/lib.
When you include dependencies, always the complete dependency-jar is added to your jar. There will be no checking, if everything is needed. So, your resulting jar will contain all 181M of dependencies as well as the source code of the new project.

Related

Meaning of SCOPE tag in Maven Dependency

When we use scope tag while providing dependencies in POM file of Maven, we can give several valid values (compile, run, provided etc..). I understand that tag is applicable for only transitive dependencies (i.: list of JARs required by direct dependencies that we give in POM).
When we give the scope as provided, will the dependency not be downloaded from Maven central repository ? Can someone please confirm.
Thanks!
Dependencies with scope provided are meant to be provided by the container in which the application runs (e.g. provided by jboss).
This means that they are downloaded by Maven, put on the compile and test classpath, but not included into the final WAR or EAR you are building.

Gradle get what repository a dependency was resolved from (smart fat jar)

I have a use case where I need to create a smart fat jar. What, exactly does that mean?
Essentially I have different repositories which our application dependencies can be resolved from, some of them exist in a globally replicated file share (which is served as an ivy repository), while others exist in a private maven repository that is not productionized, and should not be used directly by applications in production.
I would like to create a fat jar in a smart way, such that:
If the dependency came from the private maven repository, it should be added to the fat jar.
If the dependency came from the file share, it points to the jar'directly in that file share (i.e. that fat jar's manifest adds that jar to the classpath.
Do any facilities exist for me to be able to distinguish where a dependency is resolved from?
For example:
repositories {
stableIvy()
unreliableMaven()
}
dependencies {
...
}
As of Gradle 5.2 there is no API that allows you to acces that information. However this is internally known by Gradle. You could file a feature request against the project.

Configure manifest.mf classpath in ear

I have an ear application which has 3 modules:
web.war
services.jar(ejb)
domain.jar(ejb)
I worked with maven tutorial:tutorial
At the end author says about problems with manifest.mf in web module and suggesting some solutions. But this not worked for me. I think configuration is broken not only in that case. In my ear MANIFEST (classpath) i have also prefix "lib/" before services module(services are separated jar as ejb module in my app).
I saw i can use my specific prepared Manifest.mf, but i don't know how to configure it manually. Could I duplicate jars in my app modules? For example add domain.jar in services and web? Is it correct?
I have specific structure:
1.sample-ear with web and services module
2.sample-web with sample servlet(without dependencies from other project in code).
3.sample-services with dao classes(using entities)
4.sample-domain with entity beans
I tried modify manifests in every package, but I didn't find a solution. When i want to run my application on WildFly10 i get NoDefClassError (Class from domain.jar used in service.jar). Could anyone help to configure it?
On the other hand maybe you have better maven configuration in project and manually configuring the manifest.mf is not needed.

Maven ships dependencies inside war but not in jar

I have two maven projects, one (I will call it core) is an ejb-jar (ejb) and the other a war (client).
My client project consumes some ejbs inside my core...so far so good.
But I'm getting a ClassNotFoundException inside my core application because it can't find one class from apache-beanutils...I have set this dependency with compile scope in it's pom.xml but it does not get shipped inside the output jar.
When I check my client.war package I see every compile-scoped dependency inside the WEB-INF/lib folder...but in my core.jar I don't see any of it's dependencies...I'm totally confused about this.
Can someone help me? I tried to google it before asking but I didn't find anything useful so far..thanks.
You can use the maven assembly plugin to bundle all the jars in one super jar.
See this: question

Maven, NetBeans Platform, Wrapper Modules and Annotation Processors on dependencies

I have a Maven NetBeans platform application. One of its modules is a wrapper to a java project (jar) that exposes some services to the Lookup. In the wrapped project I use the maven-processor-plugin to process the annotations so everything gets registered in the Lookup. I’m unable to see the exposed classes on the wrapped module. I tried running the maven-processor-plugin but it is skipped since there are no source files in the wrapped module. Even if there were it wouldn’t fix the problem.
You can get the code here, in the Marauroa Server Manager project, Module: jWrestling Wrapper.
The code for the wrapped module can be found here. Annotated classes within the modules work fine.
Is there a way to execute the annotation processors on the dependencies of a project? Am I missing something obvious?
the wrapped jar project cannot contain nb.org annotations. these generate META_INF/generated-layer.xml file that is only read from a MODULE jar, not the wrapped non-module jar
the binary dependency contains some netbeans-originating annotations? and you want to process it through the maven plugin? that won't work. Most if not all netbeans annotations are compile-time only, meaning that they are processed at compile time and not retained in the bytecode. so only su
Besides for Netbeans annotations (which are based on jdk 1.6 annotation processors, you don't need the processor plugin, compile plugin should be sufficient.

Resources