How to add dependency to my pom.xml? - maven

I want to use https://code.google.com/p/droidpersistence/source/checkout but I don't know how add to my pom.xml..

The link you provided specifies a place you can download some code, using Subversion:
svn checkout http://droidpersistence.googlecode.com/svn/trunk/ droidpersistence-read-only
So run that command, and it will download the code. That particular code is designed to be built with ant, instead of maven. You need to write a little pom.xml file for it, so that when you build it on your computer with "mvn clean install", maven will generate a .jar file (the artifact), and put it in your local maven repository (.m2 directory). Then add a dependency on that jar to your pom file.
In general, to add a dependency to your pom using the latest version of IntelliJ Idea (12.1.6), click somewhere in your pom file, and press ALT-INSERT, then choose "dependency".
Hope this helps!

Related

How to skip download jar when open maven project in IDEA?

Sometimes I just want to see a small piece of code in a maven project. Every time I open a maven project, I need to download the jar defined in pom.xml. I can't see the source code without downloading it. What should I do?

How can I include the jboss-client.jar present in the Wildfly bin/client folder to my maven project?

I have a maven project to which I have to add a external jar jboss-client.jar which is located in Jboss Wildfly 10 bin folder(bin/client). There is no version specified in the jar name.
When I add the jar manually in build path-it works fine.
However, since this is a maven project, I require a better way of doing this.
Note: The project works with only this jar and not other versions specified in pom.xml which I tried downloading.
Also, if I try to specify the external dependency in pom.xml, it asks for version of the dependency. However, I cannot specify the same as it is not mentioned in the jar.
My ultimate aim is to deploy this project in Jboss Wildfly 10.
Is there any other alternate way, I can add the jar?
Copy your jar to some other location and unzip/decompress it, then find Manifest file located at META-INF\MANIFEST.MF path.
Open it in text editor and look for Implementation-Version.
It will give you the version.
Reference
You can use maven to install third party library in local.
https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
Using below command you can install.
mvn install:install-file -Dfile=path-to-file/jboss-client.jar -DgroupId=org.jboss -DartifactId=jboss-client -Dversion=1.0

How to convert a Maven build to Gradle?

I know I should be working with my build.gradle and init.gradle files but I don't know what to write or how to point to my project folder with the pom.xml file.
The first step is to run gradle init in the directory containing the (master) POM. This will convert the Maven build to a Gradle build, generating a settings.gradle file and one or more build.gradle files. For simpler Maven builds, this is all you need to do. For more complex Maven builds, it may be necessary to manually add functionality on the Gradle side that couldn't be converted automatically.
https://guides.gradle.org/migrating-from-maven/
as Peter Niederwieser said:
For more complex Maven builds, it may be necessary to manually add
functionality on the Gradle side that couldn't be converted
automatically.
although you have to write some parts manually by your self. there is an online service that may be an useful tool For complex Maven builds. maven2gradle is a project on github which can convert online dependencies element automatically from maven to gradle scripts.
for using it,
get to maven2gradle . URL
open and select contains of your maven file.
Paste your maven dependencies on the text box in that web page (with
or without the dependencies root element).
click Convert button.
for more information http://sagioto.github.io/maven2gradle/

maven's pom.xml ordering

I want to checkout code from svn, then compile it and then copy it to a remote location and then deploy the war file. can you please provide me a sample pom.xml file in which all these tasks have been performed in the above given ordering.
You can't do that in the POM cause Maven is not Ant...you can do that by using Jenkins/Hudson or any other CI solution.
Jenkins+Hudson can do this... But It don't mean that it cannot be done in Pom.xml. We can also use combination of ant scripts in pom.xml and we can use Maven AntRun Plugin to execute them. So by maven we can checkout code from svn, then compile it and then copy it to a remote location and then deploy the war file.
Check out this Usage Page

Maven beginner question, get m2eclipse to download jar and add to build path?

From what I have read, after adding the relevant maven repositories, maven should automatically download the necessary jars to satisfy dependencies in the pom.xml file.
However, no jars ever get downloaded for me after I add dependencies in eclipse. Am I missing some glaringly obvious step?
I'd recommend to start from creating your project with m2eclipse. See more details in this article.
Basically, you need to make sure the following:
your Eclipse project has a valid pom.xml and all dependencies are available (you should see errors on Maven console, in the Problems or Markers view or when opening pom.xml in m2eclipse's POM editor)
Maven support is enabled for this project (you can use Maven / Enable Dependency Management from popup menu on that project)
project configuration is in sync with pom.xml (you can use Maven / Update Project Configuration from the project popup menu)
you can also use Maven / Update Dependencies to refresh your dependencies (e.g. when you got them in your Local Maven repo from the command line)
Dependencies jars aren't in your project but in your local maven repository.
These jars will be automatically used when you compile you project with maven (or m2eclipse).
If you don't have the needed jar yet, maven will download it for you.

Resources