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

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.

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.

Tell SBT to not use staging area

I want to be able to compile my project once and pass it through multiple build steps on a CI server. But SBT puts files in a staging area like the one below.
/home/vagrant/.sbt/0.13/staging/
This means the project is not stand-alone and for every CI step it is going to compile it again.
How can I tell SBT to keep things simple and stand-alone and to make sure everything it needs is inside the project directory?
FYI, the staging area is used for the target files when the source folder is not read/write. Making the source folder read/write should fix this.
If you pass -Dsbt.global.staging=./.staging to sbt when starting it up, the staging directory will be .staging in the project's directory.
I figured that out by looking at the sbt source and patching that together with how Paul P's sbt runner passes the value for the sbt boot path.
If that doesn't accomplish what you want, then you might be able to make something go with a custom resolver. The sbt Build Loaders page talks about creating a custom resolver that lets you specify more detail about where dependencies are written. If my solution doesn't get you what you want, you'd probably need to do something like that.

ant deployment issues

i am looking to make our deployments here not suck and i need some help, if you can help me with these few things i owe you beer
right now whenever i make a change thats not to the jsps i need to clean-including-tomcat otherwise my change doesnt take. this is really annoying.
any clues as to what i can change to make it work?
my current build is really simple, just the regular old, javac, war, deploy
one thing that isnt done is that there is no build dir, the project itself contains a web-inf and the javac is done in place, then the war excludes all the .java resources and wars the project.
edit:
I am looking to fix this problem with least amount of effort - so while switching to maven and learning how to use it might solve this problem, but it will create another problem ;)
You've already identified some of the weaknesses, in your current build.
The easiest way that I can suggest to clean it up would be to start with the directory structure.
I highly recommend using the maven directory structure, I would go further to suggest using maven as a build tool instead of ant, however for some folk that remains open for debate.
The maven directory structure has been well thought out, I really like working on projects that use the maven directory structure, because they follow a convention that allows me to save a lot of time, by knowing from previous experience where to find the application components
java source
unit test source
resources etc.
Also by following the convention, the maven plugins work with less configuration required.
Another useful advantage that I get from working on maven based projects is good code metrics, to measure the health of the application. There are various report available as maven plugins, which will give you new insight into your codebase, including:
checkstyle
pmd
findbugs
and more.
Created a build directory where everything got copied before build
Added some flags to not copy over things that rarely change, like images (also to not remove them on clean)
Started using ant-reload task after deploying code
Now i don't need to restart tomcat on every build, and build takes much less time.

Set up an Eclipse Dynamic Web Project referencing another project

I've got a simple Dynamic Web project set up in Eclipse 3.6 Helios, but am having trouble getting it to make use of the code in another project that I've got.
I've added a reference to my other project to the build path of my web project, and I've got no problems in terms of compiling, only in terms of deploying and testing the result. The built web application doesn't have a jar in the WEB-INF/lib directory, so fair enough it can't find the code. The question is how I set this up. I've looked through the help that I can find and googled a bit but can't find anything obvious that helps out.
How do I set up my web project so that on deploying it it magically has the code from my dependent project inside it?
Thanks.
Note: Ideally I'd like a solution that doesn't involve setting up some kind of build tool. The web project deploys itself without recourse to any build tool (or at least none visible to end user), so was rather hoping that a references project could be integrated into that easily.
What goes in the deployment is determined not by the build path but by the Deployment Assembly entry in Preferences for the dynamic web project.
Use some build tool like ANT or Ivy or Maven that, on build, copies all the dependencies to WEB-INF/lib
Using a build tool is a good practice to automate build, test and deployment. You may also be interested in plug-ins like Maven Reactor.

How to deal with Maven projects containing several internal artifacts?

I'm about to start working on a web-application and I'll be using Maven. I want the web-application to be an individual artifact. The web-application will end up depending on a couple of self written libraries (for example text-formatting), and each of these libraries should be an individual artifact.
What's the recommended way of achieving this separation while making it simple to code for both artifacts? I was thinking of creating one project for each artifact and import them one by one in Eclipse. However, if the pom for web-application has a dependency pointing at the self written library, I'll end up having to deploy a snapshot every time I want to see if the change I made stopped the web-application from crashing (in example).
I hope you understand what I am getting at. I'll be working with a couple more developers, and we're using Nexus to maintain our shared artifact repository.
I was thinking of creating one project for each artifact and import them one by one in Eclipse.
Yes, that's the recommended way.
However, if the pom for web-application has a dependency pointing at the self written library, I'll end up having to deploy a snapshot every time I want to see if the change I made stopped the web-application from crashing
During development, you can use "workspace resolution" i.e. configure Eclipse to resolve dependencies from the workspace. This way changes are immediately visible from the webapp. This is possible whether you are using m2eclipse or the maven eclipse plugin (and is actually the default behavior for both).
Below, an illustration for m2eclipse:
A good maven plugin for eclipse is capable of "workspace resolution", i.e. it will recognize if the dependency is also present in the workspace, and refer to the other project directly rather than adding a JAR to the build path.