How to create a jar file from two projects on eclipse - eclipse

I have two projects in eclipse. I know how to create a jar file for each project individually, however I want to combine the two jar files again and create another jar from them? Ideally I would like to script it and automate it. Any help will be highly appreciated. If there is any example online, I will appreciate if you could share it.

You could have one project depend on the other, and use the maven-shade-plugin to build an uber-jar of the second project (thus containing the classes of the first project). You need to use Maven or other build tools for this to work though.

I have managed to solve this problem. I used the Maven one jar plugin.

Related

How to import then build multiples local jars (~100) into a maven project

First of all, sorry if my question seems to be duplicated but I have thoroughly search during hours and hours a solution without any success...
This is my current context :
I have developped a huge talend job which uses many others jobs
I have built my talend job as a standalone jar. That resulted in a zip file containing a lot of others jars (around 100). All of those jars are needed for my talend job to work. Those are secondary jobs or libraries, etc.
Then I have made a spring-boot java application (using maven...) that can run my talend job among others things.
In order to do that, I had to import every jars into my project => i.e build path. Those 100+ jars are all visible inside the "referenced libraries" folder.
When I run my app through Eclipse, everything is working well but now what I need is to build this app as a jar, or something I can run on another machine/server.
I don't know anything about maven, but if I understand well, I need to use the command maven-install in order to build my project... The problem is the command throw me errors because it doesn't find all my libraries.
I found many solutions that says to create a local repository, to use maven-install for each jar, or maven-deploy for each jar, then add dependencies into my pom file for each jar...
As you could understand, that's not a good solution for me and my 100+ jars...
I heard about nexus or something like that, but I am the only one person working on this project and this solution seems to be interresting when a whole team is working on the same project.
So, if any of you knows how I can manage that, I would be very grateful.
Thanks.

Is there a quick way to convert Eclipse "libraries" to Maven POM entries?

I've got an eclipse project with several "libraries", each containing a significant number (35-40) of individual jar files. For instance, a JBoss "library" will generally have several hundred .jar file associated with a particular runtime.
Is there a way to find/use the "library" objects with Maven so that I can specify them in my POM.xml, or am I stuck with individual entries for each individual .jar file?
Sorry Josh, think you're stuck.
We had this issue once (a legacy app with loads of jars that had to be moved to Maven) and what we did was write a little script that returned the SHA hash of all of the jar files, and searched the maven repository (given khmarbaise's link above) using that. This way you know that you're getting the exact jar that you're already using.
The best solution i can recommend is to use:
http://search.maven.org
For JBoss you need to use the search in JBoss repository.
https://repository.jboss.org/nexus/index.html
But better check the documentation at JBoss if there is a more up-to-date source for JBoss.

Maven: Prevent upload of default-jar - only upload jar-with-dependencies

I'm evaluating Maven 3 at work. For several example projects I have to deploy them to a server (no repository), but that's not the problem.
In my current example-project I'm trying to upload only the "jar-with-dependencies".
and exactly that's my problem.
It all works fine, except that the main-artifact AND the jar-with-dependencies (created by the assembly-plugin) are uploaded.
How do I prevent Maven or rather the deploy-phase from uploading the main-jar and only upload a given or specified file (in this case, the assembly-file "jar-with-dependencies")?
Referring to the question Only create executable jar-with-dependencies in Maven, I can't just alter the packaging-setting to pom, because it will also prevent the assembly-plugin from adding my classes to the JAR file. It only creates a JAR file with the files of the dependencies.
I hope I'm clear about my problem, and you can help me ;)
if you just looking how to add a file to be deployed you can take a look here:
http://mojo.codehaus.org/build-helper-maven-plugin/attach-artifact-mojo.html
May be this helps. If not express your needs more in detail.
There seems to be no way to configure the deploy plugin to filter out some of the artifacts from a project and selectively deploy the others. Faced with a similar problem, we solved this with the ease-maven-plugin. It fit well into our release process but might not be the right choice for everyone as it mandates a two-step approach. During the build you would make a list of all artifacts and filter out those that you want deployed. In a second step, you then run mvn deploy on a separate project (or separate profile) in which the list of artifacts is attached to the project as the only artifacts which then get deployed. See the examples in the source code of the ease maven plugin to better understand how it works.
The original version is not able to filter out specific artifacts of a project. I have forked the project and added patches that add this.

Setting up maven project structure with several components

a question: I have three maven projects that should make up one war file. The three projects are:
simple-domain
simple-weather
simple-webapp
where simple is the parent pom. I've tried a multi module project under eclipse but I had to add relative paths to the parent project. Can someone provide me a simple set of poms or examples that would help me achieve the following:
build all projects by running maven install on the parent, run each of the three sub projects by themselve ( so it should find the parent ) and avoid using relative paths.
the latter is important as I will deploy the projects to a hudson server where each project is a job where the relative paths might differ
kind regards,
Michael
You should use the standard Maven directory structure
simple
simple-domain
simple-weather
simple-webapp
Then remove any relative path and use m2eclipse to handle everything in Eclipse.
Also, set up one job for simple, not one for every module. Hudson handles multiple modules well.

Create single jar from many eclipse projects

I'm doing the build automation for a java app with ant. This is a client-server app which has many projects in eclipse. I would like to create a jar file for the client and one for the server, but since the class dependencies are all over the projects (in eclipse)... I had the idea to use a tool to automate the search for dependencies. I've been looking at GenJar witch is almost all I need but it's not been updated in a while. So I would like to know if there are any other tools like this one, maybe Maven?
You may also try FatJar
It kind of sounds like what you really want is a WAR file.
Personally I would go with Ant + Apache Ivy. Each project has its own build.xml file and publishes to a central Ivy repository. Other projects will simply download these dependencies as needed.
The advantage of having an Ant based build process is that you can very easily automate it and use a continuous server to build the entire product after each check-in.