views:

686

answers:

4

Hi,

Why does every time I do "mvn jetty:run", maven tries to download some dependencies (apache poi and ojdbc jars) ? How can I disable this?

[INFO] Scanning for projects..    
[INFO] Searching repository for plugin with prefix: 'jetty'.
[INFO] ------------------------------------------------------------------------
[INFO] Building infolitReport
[INFO]    task-segment: [jetty:run]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing jetty:run
Downloading: http://repository.springsource.com/maven/bundles/release/org/apache/poi/com.springsource.org.apache.poi/3.6/com.springsource.org.apache.poi-3.6.pom
Downloading: http://repository.springsource.com/maven/bundles/external/org/apache/poi/com.springsource.org.apache.poi/3.6/com.springsource.org.apache.poi-3.6.pom
Downloading: http://repository.springsource.com/maven/bundles/milestone/org/apache/poi/com.springsource.org.apache.poi/3.6/com.springsource.org.apache.poi-3.6.pom
Downloading: http://repository.springsource.com/maven/bundles/snapshot/org/apache/poi/com.springsource.org.apache.poi/3.6/com.springsource.org.apache.poi-3.6.pom
Downloading: http://repo1.maven.org/maven2/org/apache/poi/com.springsource.org.apache.poi/3.6/com.springsource.org.apache.poi-3.6.pom
Downloading: http://repository.springsource.com/maven/bundles/release/com/oracle/ojdbc14/10.2.0.2/ojdbc14-10.2.0.2.pom
Downloading: http://repository.springsource.com/maven/bundles/external/com/oracle/ojdbc14/10.2.0.2/ojdbc14-10.2.0.2.pom
Downloading: http://repository.springsource.com/maven/bundles/milestone/com/oracle/ojdbc14/10.2.0.2/ojdbc14-10.2.0.2.pom
Downloading: http://repository.springsource.com/maven/bundles/snapshot/com/oracle/ojdbc14/10.2.0.2/ojdbc14-10.2.0.2.pom
Downloading: http://repo1.maven.org/maven2/com/oracle/ojdbc14/10.2.0.2/ojdbc14-10.2.0.2.pom
[INFO] [aspectj:compile {execution: default}]
A: 

why would you want to stop it? you can run it without downloading dependencies? if you still want to do so chk this out

http://maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html

Look at the exlude tags

c0mrade
A: 

Basically, the dependencies will be downloaded the first time when you run the command, but some dependencies may need to compare its versions and try to get most up-to-date ones for you in your next time run.

If you does not always have an internet connection or just want to short your build time, you can append -o parameter which means offline to run, for example mvn jetty:run -o

virsir
Maven doesn't download artifacts with fixed version again. The problem here is that it doesn't succeed at downloading the POM even once.
Pascal Thivent
ok. the culprits are ojdbc.jar and poi.jar
portoalet
+2  A: 

As explained in the chapter 3.5.5. Maven's Dependency Management:

A dependency in Maven isn’t just a JAR file; it’s a POM file that, in turn, may declare dependencies on other artifacts. These dependencies of dependencies are called transitive dependencies, and they are made possible by the fact that the Maven repository stores more than just bytecode; it stores metadata about artifacts.

So, when Maven downloads a JAR dependency, it doesn't only download a JAR but also the POM file. Here, Maven tries to download them, but they don't exist (only the jar files exist). So maven won't write them into the local repository and tries again next time.

There are 4 options here:

  1. Use good citizen artifacts with POM files (or ask the responsible to fix the problem).
  2. Use a repository manager and create and upload the POM files.
  3. Create the POM files in your local repository (for example using install:install-file).
  4. Live with it (sigh) and run mvn offline with the -o option to make it less painful.
Pascal Thivent
For ojdbc14, I edited my pom.xml, <repository> <id>repo1 maven org</id> <name>repo1 maven org</name> <url>http://repo1.maven.org/maven2</url></repository><dependency> <groupid>ojdbc</groupid> <artifactid>ojdbc</artifactid> <version>14</version> </dependency>But I had to download ojdbc14.jar manually and install ithttp://lydonchandra.blogspot.com/2010/03/springsource-tool-suite-oracle-jdbc.html
portoalet
A: 

Example of answer by Pascal Thivent

Create the POM files in your local repository (for example using install:install-file)

call mvn install:install-file -DgroupId=org.apache.commons -DartifactId=codec -Dversion=1.3 -Dpackaging=jar -Dfile=lib/commons-codec-1.3.jar -DgeneratePom=true
call mvn install:install-file -DgroupId=org.apache.commons -DartifactId=httpclient -Dversion=3.1 -Dpackaging=jar -Dfile=lib/commons-httpclient-3.1.jar -DgeneratePom=true
call mvn install:install-file -DgroupId=org.apache.commons -DartifactId=logging -Dversion=1.1 -Dpackaging=jar -Dfile=lib/commons-logging-1.1.jar -DgeneratePom=true