Showing posts with label Maven. Show all posts
Showing posts with label Maven. Show all posts

Saturday, October 13, 2012

Installing Maven 3 in Ubuntu 12.04 Precise

Ubuntu needs to no explanation and Maven is software project management tool. It manages software dependencies and how your code is compiled and deployed. Its pretty handy because now I don't have to hunt down jars that my other jars need and no more copying the binaries to target folders.

Unfortunately, the Ubuntu repos are a bit slow. The repos only have Maven2. Now, let's get to installing Maven3.

1. Install the Nate Carlson's PPA for Maven3
2. Open a terminal console and type in: sudo apt-get update
3. After update finishes, type in: apt-get install Maven3

You now have Maven3 installed but you can't run it from the terminal because you didn't set the paths. If you try to type: mvn --version; That should fail. To fix this you have to make a symbolic link from where Maven3 is installed to where it can be run it "globally" from the terminal.

$ sudo ln -s /usr/share/maven3/bin/mvn /usr/bin/mvn

You just created a symbolic link in /usr/bin/mvn. The mvn command now should work in your terminal.

Update (3/29/2013):
Caution: command "sudo add-apt-repository ppa:natecarlson/maven3" did not work on my Ubuntu and and had to run "sudo add-apt-repository -rm ppa:natecarlson/maven3" to get my apt-get to work again. ~AmirHD
See this Stackoverflow thread.

Friday, July 13, 2012

Install local jars with maven

I don't know why it took me a long time to write about this.

There are a lot of Java jars that isn't on the maven repository but you still need or like to manage these jars via Maven. To install a jar into your local Maven repo:

 
mvn install:install-file -Dfile={file} -DgroupId={groupname} -DartifactId={artifactname} -Dversion={versionnumber} -Dpackaging=jar
 
For example, you want to add Microsoft MSSQL jdbc driver into your local Maven repo then the procedure would be:
  1. Download and extract the file.
  2. Open the command line and type in:
  3.  
    mvn install:install-file -Dfile=sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=mssqljdbc4 -Dversion=4.0 -Dpackaging=jar
     
    
You can then add it to your project with:
<dependency>  
<groupId>com.microsoft.sqlserver</groupId>  
<artifactId>mssqljdbc4</artifactId>  
<version>4.0</version>  
</dependency>

Monday, August 1, 2011

Maven and db4o

db4o (database for objects) is an embeddable open source object database for Java and .NET developers. It is developed, commercially licensed and supported by Versant.

I use db4o on a lot of personal projects. I even have started using db4o on a few of my Android projects. But I keep looking up that Maven snippet for adding db4o. So that snippet goes something like this:

<project>
  <repositories>
    <repository>
      <id>source.db4o</id>
      <url>http://source.db4o.com/maven/</url>
    </repository>
  </repositories>
  ...
  <dependencies>
    <dependency>
      <groupid>com.db4o</groupid>
      <artifactid>db4o-core-java5</artifactid>
      <version>8.1-SNAPSHOT</version>
    </dependency>
    ...
  </dependencies>
</project>

By adding this snippet to my Maven POM file. I should be adding the latest db4o jars to my project. db4o is currently right now on its 8th version.

Thanks to Pascal Thivent for this. Hey, you gotta give credit where credit is due. Edit(5/1/2012): changed repository url and artifactId