Is it possible to add dependencies in a pom.xml file? - maven

My question may seem very simple but I did not know how to write it correctly ...
Here is my problem : I am testing an application using Cucumber and other libraries.
To do that, I had to add different dependencies to the pom.xml file of the Maven project I am testing.
In order to use all the work I made for further projects, I am now trying to create a settings.xml file in order to configure all others Maven projects with this document (avoiding copy/paste for all the pom.xml files). The fact is I manage to create profiles (which eases a little the work) but I can't find a way to automatically include all the dependencies I need.
Is there an easy way to do that ?
I hope my question is clear,
Thank you

You can't add dependencies from settings.xml profiles.
You need to add them in projects pom.xml files (or in the parent of those).

Thank you all for your answers !! I think I will have no other solution than copy/paste each time all my dependencies then...
Regards

Related

Maven Enhancing / Exploding war file

first of all sorry if this is a stupid question, but i am quite new to the topic of Maven. So please correct me if i am doing something wrong or not best practise like
Currently I have following issue:
I have an 3rd party application in several war-files which i would like to extend (this 3rd party party allows to extend the software with own individual implementation).
Therefore i have created a Maven Project where i added the required war-files as dependencies in my pom.xml
My assumption is:
I have to somehow unpack the war file and then have to add my new implementation to it and then have to compile everything and then have to repack everything into a new war.
Is that correct or not?
How would i do it?
Thanks a lot for your help
The Maven War Plugin supports overlays that allow you to do exactly what you desire.

How to install artifact using maven-antrun-plugin?

I have a project that some ant files target to extract different packages (I'm the guy who comes and see this ugliness, not the one who did it).
So, one package, one ant, one jar.
And different OTHERS projects use one or more of this jars.
I can't touch the folder structure.
I have to migrate this (and the other projects) to maven, but other than make several poms that exclude all others packages and compile it's own, I don't know how to solve this problem.
I'm not very good with ant, but I read here that ant-task can install into the local repository, so it can make easy for the dependent projects to use those jars.
Can anyone can help me with an example of how to use the ant-task-plugin to achive this, or a better approach?
What I do and work for me was to add a new maven-jar project and change the source folder so it points to the mentioned folder.
Then I exclude the packages so it can generate the required jar.
Repeat for every jar I have to make this way.
Add this projects to the parent pom, so the can be created at once with the dependent projects.
Hope this help someone.

Maven war plugin copy arbitrary files

I apologize that this is surely basic maven/war plugin stuff, but I'm totally not a maven user. I just have to hack this one thing into a project that is maven based.
What I need to do is to copy an (essentially arbitrary) directory and files into the root of my war. I need them to appear as resources available via HTTP when the war deploys.
I cannot simply put them in the "right place" in the source tree. This is because the files in question are actually the source files of my project. I realize this is a bit odd, but this is a documentation project, and I need to show the source and the effect all in the same war.
So, in the general case, how would I configure the maven war plugin to copy a given directory, along with it's contents, to the root of my war? (BTW, I have tried to make sense of the documentation of this tool, but it seems to be predicated on so much understanding of maven that it feels like I'll never understand it without learning maven first, and I'm a bit too pressed for time to do that just now!)
Many TIA
Toby.
You could try:
use the copy-resources plugin. Use the plugin to copy your source files under target prior to when the war is packaged.
or, configure the maven-war-plugin to include additional resources.
Thanks Drew, that got me where I needed to go. Bottom line, I added the sample pom fragment from the link you gave for copy-resources to my pom.xml with the following changes:
<outputDirectory>target/${project.name}-${project.version}/sources ...
<directory>src/main/java ...
I copied this from the link you gave, then edited the element to point at src/main/java, which picked up my files, and the outputDirectory to the aggregate target/${project.name}-${project.version}/sources . I found that ${project.name} mapped to the project, and the version came from ${project.version}, which seemed to resolve the last little bits of issue.
Thanks again.
Toby

How to point Maven IDEA plugin what type of module to generate?

I have a project that consists of several modules (app. 10-12). I use maven idea plugin to generate .iml for each module, but I have one problem. All modules are of JAVA_MODULE type, but plugin generates main module as J2EE_WEB_MODULE. I think it is because there's .war files and WEB_INF folders in target folder, but these ones are for Tomcat usage. Anyway, at the end I must edit .iml file and change J2EE_WEB_MODULE to JAVA_MODULE.
Is there any way to make maven plugin generate a module of specific type? Or maybe there's a workaround that lets one change with maven, using regexp, module type in .iml?
Thank you in advance.
Do not use the maven-idea-plugin, it is obsolete and has not been updated since 2008.
Just open the project by pointing to the pom.xml.
The guys at JetBrains has done a perfect job with their own maven integration.

Maven shipping scripts

I am completely new to Maven and come from an ant world. I am having lots of trouble something that might be really trivial.
I want to have a maven project that is made out of non-code items that I want to ship along my jars. These items are DDL scripts, installer scripts a couple of utility scripts, readmes etc.
I do not want to use "resources" in the corresponding java projects since I do not want them living in the actual product jars. I want them shipped as separate artifacts that just like any other jar.
It is acceptable to bundle them up in a jar or zip, etc.
Is there a way to do this?
Thanks!
Use the build helper plug-in to add additional artifacts to the Maven module.
Check out the answer to the following question
Ok, I found it and it was pretty simple. Just created a project added a simple pom with no plugin pacakging jar and I create the proper dir structure
src/main/resources/...
This builds it into a jar

Resources