How to build renamed POM xml - maven-2

I am relatively new to Maven. I actually wanted to know how to build the renamed pom.xml i.e.
there is a XML file with the name parent-pom.xml. Shall I directly name it to pom.xml and try building it or is there some other way to do it?

Maven looks for the pom.xml file, so you should rename it that for it to work.
You could use another file name using the -f option.
mvn -f parent-pom.xml.

Related

Convert web application project to maven project and convert corresponding .classpath file to pom.xml

Is it possible to convert project .classpath file to pom.xml after converting a simple web application project to maven project? Because if my project uses many jars and I want to convert it to maven then I will do configure->convert to maven but then it is not possible to add all the jars dependencies in pom.xml manually. So is there any tool to convert this.
First there is no tool to do such things. The problem is usually that you have a larger number of dependencies which you don't need to put into the pom.xml file, cause Maven handles transitive dependencies which means you only need to add only direct dependencies. The best thing is to look at the current projects jar files and try to find them in Maven Central and cut&paste the information form the search output into your pom. And of course test the build via Maven on command line.

Maven Unique Version in Jar File Name

I am using Maven with Nexus for building my project with hudson ci. Everytime when I am deploying a new snapshot artifact he is doing this with a unique version in nexus. Which is OK for me as Nexus is giving me always the latest version.
Now I looked into the war file of my project which is using this snapshot dependency and its having the following jar file in its lib directory which is absolutely not fine:
framework-client-1.1-20120302.141044-3.jar
The problem is that I am using EBean as an ORM and I need to specify the jar name in the ebean.properties to let him know where to find its models.
How can I prevent such behaviour so that the latest snapshot dep is always call framework-client-1.1-SNAPSHOT.jar?
Thank you!
Just rename the jar in the war file to whatever name you like. Details are here
Renaming Maven dependency in WAR's WEB-INF/lib folder

How to compile pom.xml without generating project in Maven?

I have pom.xml file that contains dependencies and files to checkout from svn so there is no no need to generate project. I just need these libraries and those files, so is there any way to get them without generating a project with maven directory structure?
I'm not sure from your question what do you want. If you have pom.xml file and you want to download all dependencies defined in it, you can call
mvn dependency:copy-dependencies
For more options look maven copy-dependencies task page
If you are asking how to create pom that will contain no code, but only dependencies, you can do that by specifying pom packaging.

maven install file manually without version

How do I add a jar file to my local repository without appending the version number to the jar file?
Lets say I have a jar file named abc.jar and run the following command, it will create abc-1.0.jar and if I bundle this artifact in a war file, the resulting file name will be abc-1.0.jar. If I remove the -Dversion, the command fails. If I mention blank value -Dversion="", then abc-.jar is created. How do I keep the original jar's filename(abc.jar)?
mvn install:install-file -Dfile="d:\abc.jar" -DgroupId=grp1 -DartifactId=art1 -Dversion=1.0 -Dpackaging=jar
How do I add a jar file to my local repository without appending the version number to the jar file?
You can't.
This works for war packages. I haven't tried it for jars.
<build>
<!-- Ensures that the version number is not included in the packaged file name -->
<finalName>myrenamedpackage</finalName>
</build>
You can not change the name of the arifact in your maven repository, but you can configure the war plugin to use a specific nming scheme for the libs it bundles in WEB-INF/lib using the outputFileNameMapping option. To remove version information and classifiers the mapping pattern would be #{artifactId}#.#{extension}#. If the artifact id matches the original filename this should give the wanted result.

Java-Maven: How to add manually a library to the maven repository?

I'm trying to generate a jasperReport, but I receive this:
net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'Times New Roman' is not available to the JVM. See the Javadoc for more details.
After searching on the net, I found that I need to add a jar to the classpath with the font. So, I create a jar file with the ttf files and now I want to add this as a dependency to my pom file.
So: I installed the file :
mvn install:install-file -Dfile=tf.jar -DgroupId=tf -DartifactId=tf -Dversion=1.0.0 -Dpackaging=jar
and in my pom, I added these lines:
<dependency>
<groupId>tf</groupId>
<artifactId>tf</artifactId>
<version>1.0.0</version>
</dependency>
but I receive this: Dependency 'tf:tf:1.0.0' not found less
I checked the repository folder and the jar file is there, in ... tf\tf\1.0.0\
What I'm doing wrong?
The syntax of the command used to install your 3rd party jar looks identical to the reference (I would just also generate a pom by adding -DgeneratePom=true), the snippet to declare the dependency in your pom looks fine. What you're doing seems ok.
Could you provide the exact trace?