Include one Maven assembly inside another? - maven-2

My project generates 3/4 assemblies, 3 jars and 1 war.[I need to use assemblies itself]
I need to include 2 of these assembly jars into my war.
How can I ensure that before assembly war creation , other 2 jars are created ?
Please respond

You have three choices:
define all the assembly executions in one plugin configuration, and order them as needed.
See this answer for more details.
Define an earlier phase for your jar assemblies so that they have all been packaged before the war is packaged.
Move the jar content into separate projects and specify them as dependencies of the war project so they are packaged automatically. This is the "Maven way" of handling this. It would also allow you to potentially reuse the jars in other wars.
I'd recommend option 3 myself, but the other two should both work.

Related

Recompile Dependencies in Maven 2

In the pom for a webapp, I'm looking for a way to recompile the local source code for two dependencies, then copy those jars over to the webapp's WEB-INF/lib directory. Is there a Maven 2 plugin that would allow me to do this, or some better approach using Maven 2?
I don't know if there is an easy way to do that.
One solution is to put all three projects in a reactor (a project with ), they will build in the right order when the reactor project is invoked.

MANIFEST.MF in RAD not listing all dependencies

In my RAD, when I open up the MANIFEST.MF file for an ejb project, because I need to add dependencies, in the UI, I see (under dependencies):
Select other JARs or modules contained by the EAR that are required by this JAR or module. Only valid or existing dependencies are shown.
What does it mean by Only valid or existing dependencies. I say this because not all projects in the workspace are listed under Dependencies. And the project that I need to add as dependency is not listed here. What is the reason for this?
I found the solution although do not understand the reason. I need to add the project jar under JAVA EE Module Dependencies

Maven2: Possible to deploy depends on artifact classifier?

In fact I have 2 different problems, but I think they are kind of related:
I have an artifact, with an assembly descriptor set which will build an extra JAR (with extra classifier). By default, Maven2/3 will deploy the assembly generated together with the main artifact to remove Maven repository. Is there any way that I can deploy only the main artifact but not the assembly?
I have an artifact, in which I have jar plugin generate another artifact with different classifier (more specific, an EJB artifact, and I generate an client JAR). I want to deploy only the client JAR to Maven repo coz I think the main EJB artifact is not really going to be shared by other project. Is it possible to do so?
Thanks a lot
editied to provide more info:
The reason for avoiding deploy the EJB, is because the EJB main artifact is not going to be depended by other project except the containing project. The containing project will build a EAR (which contains the EJB), and normally we only need that build locally (by mvn package). However, the EJB client is something that we will deploy to our repo to let other project share when they need to communicate with our application.
Honestly it doesn't harm to deploy the EJB too, but I just want to see if I can save unnecessary waste of disk space on our repository.
Similarly, for deploying assembly, it is because the project is something we want to deploy to let other project to depends on. However, when building that project, we also have a separate assembly created on the same time (for example, an all-in-one executable jar) which we only need that built locally, and it is not something that other projects will depends on.
Turn off the 'attach' option to the assembly plugin. Then it won't be officially an artifact and it won't deploy; it will just lurk in the target directory, sulking that you don't love it as much as it's elder sibling and plot revenge.
Based on your first question i would like to know why do you create the supplemental assembly which is usually deployed as well as the main artifact. If you wan't to prevent you can put the creation of the assembly into a profile but this means you will not generate the supplemental artifact in your usual build only by activating the profile.

Adding external jars to EJB project using EAR content folder

i have EAR and an EJB project. I noticed eclipse (sts) creates and earContent folder so I assume this is where I need to add external jars.
I added my hibernate and log4j jars on this folder but my EJB classes cannot resolve Logger class and hibernate classes.
What's the correct way of adding these jars? or should I just add them to the EJB build path?
Add jars to ear project EarContent folder
In Eclipse Right click ejb project, Properties
Deployment Assembly - Manifest Entries - Add
Choose your jars to add, OK
OK
jars now added to manifest in ejb project, should work.
I'm looking at this in a project for the first time, I'd be very surprised if there wasn't a better solution to this that doesn't require Maven. The Java EE Tools - Update EAR Libraries option looks particularly suspicious, but doesn't seem to do the above. Note I'm on Helios still.
Add those jars under folder EarContent/lib directly , then all is done.
I.E., EarContent/lib/foo.jar will work but EarContent/lib/dir/foo.jar won't.

maven multi-module assembly

I have a multi-module maven project, and I'm trying to create an assembly for the project. The assembly should be a zip file, including all of the jars from the dependent projects as well as all of the resources from those projects (this is for legacy support reasons - I know this isn't a good practice, but in this case, we really can't do much about it).
I have an assembly that builds a zip and includes the contents of the build output directory (which will get the resources). If I run that from the parent pom, it doesn't actually build a zip (presumably because the parent project is of type pom, not a jar). If I run an assembly from one of the individual projects, it does include the jars and all the dependencies (I specified including the dependencies). It includes the output directory for that project, but not the child projects.
Do I need to do something like run an assembly from the parent that iterates over the child projects and runs their assemblies (the assemblies for each of the child projects would be the same though - it would include the jar, the dependencies and the output directory)? I'm not even sure this is possible ... any guidance would be appreciated.
I suggest to check the whole Section 8. Maven Assemblies of the Maven: The Complete Reference book and in particular the following subsection 8.2.4. Assembling Assemblies via Assembly Dependencies. It describes a very similar requirement and a setup.