NetBeans installation provides some additional Java software, including tomcat, glassfish and maven. If you download some .jar packages and want to use them in your project, you should know that NetBeans can provide non-standard paths for its software. Additionally, installing NetBeans will not mark any packages installed on your system. For example, installing NetBeans with tomcat and installing tomcat from debian packages will result in having two distinct tomcat installations on your system.
where are maven repos stored
Let's focus on Maven right now - we want to check where are local maven repositories stored. Switch to Services tab:
Expand Maven Repositories and right-click Properties on Local repositories: You can see where maven stores its repos: They're stored in the displayed directory, all structured in the same way as Java packages:tomasz@workshop:~/.m2/repository/org$ ls -al razem 36 drwxrwxr-x 9 tomasz tomasz 4096 2013-02-20 20:58 . drwxrwxr-x 28 tomasz tomasz 4096 2013-02-20 19:15 .. drwxrwxr-x 8 tomasz tomasz 4096 2013-02-20 20:50 apache drwxrwxr-x 3 tomasz tomasz 4096 2013-02-20 19:15 aspectj drwxrwxr-x 4 tomasz tomasz 4096 2013-01-10 19:46 beanshell drwxrwxr-x 5 tomasz tomasz 4096 2013-01-10 19:46 codehaus drwxrwxr-x 5 tomasz tomasz 4096 2013-02-20 20:58 slf4j drwxrwxr-x 5 tomasz tomasz 4096 2013-01-10 19:49 sonatype drwxrwxr-x 4 tomasz tomasz 4096 2013-02-20 19:45 springframework tomasz@workshop:~/.m2/repository/org$ cd springframework/ tomasz@workshop:~/.m2/repository/org/springframework$ ls -al razem 16 drwxrwxr-x 4 tomasz tomasz 4096 2013-02-20 19:45 . drwxrwxr-x 9 tomasz tomasz 4096 2013-02-20 20:58 .. drwxrwxr-x 3 tomasz tomasz 4096 2013-02-20 19:15 spring-core drwxrwxr-x 3 tomasz tomasz 4096 2013-02-20 19:45 spring-expression
how to add local repos to maven
The easiest way to download local repositories and store them in Maven is to download packages for existing projects. Take a look at maven repositories for Apache Tiles. Now, add new dependencies to your project by extending pom.xml:
<dependencies> ... <dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-jsp</artifactId> <version>3.0.1</version> </dependency> </dependencies>Now take a look: tiles-jsp-3.0.1.jar has shown up: We set maven to download the packages and store them locally: And build the project (maven will download the sources during build):
cd /var/www/Java/lyricsBaseMaven; JAVA_HOME=/usr/lib/jvm/default-java /home/tomasz/netbeans-7.2.1/java/maven/bin/mvn install
Scanning for projects...
------------------------------------------------------------------------
Building lyricsBaseMaven 1.0-SNAPSHOT
------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/org/apache/tiles/tiles-jsp/3.0.1/tiles-jsp-3.0.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/tiles/tiles-jsp/3.0.1/tiles-jsp-3.0.1.pom (6 KB at 4.3 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/tiles/tiles-parent/3.0.1/tiles-parent-3.0.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/tiles/tiles-parent/3.0.1/tiles-parent-3.0.1.pom (16 KB at 17.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/tiles/tiles-master/4/tiles-master-4.pom
...
[install:install]
Installing /var/www/Java/lyricsBaseMaven/target/lyricsBaseMaven-1.0-SNAPSHOT.war to /home/tomasz/.m2/repository/com/blogspot/symfony-world/lyricsBaseMaven/1.0-SNAPSHOT/lyricsBaseMaven-1.0-SNAPSHOT.war
Installing /var/www/Java/lyricsBaseMaven/pom.xml to /home/tomasz/.m2/repository/com/blogspot/symfony-world/lyricsBaseMaven/1.0-SNAPSHOT/lyricsBaseMaven-1.0-SNAPSHOT.pom
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 22.113s
Finished at: Wed Feb 20 20:59:06 CET 2013
Final Memory: 8M/65M
------------------------------------------------------------------------
As you can see from the console, the artifact was downloaded with all its dependencies. If you take a look at project dependencies in NetBeans, you'll see them with gray jar icons. This means that they were not mentioned directly, but they're here as necessary dependencies:
If you download jars and store them locally in maven, it won't have to download them from the internet each time you build a clean project.







No comments:
Post a Comment