Maven jetty download dependencies - maven-2

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}]

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:
Use good citizen artifacts with POM files (or ask the responsible to fix the problem).
Use a repository manager and create and upload the POM files.
Create the POM files in your local repository (for example using install:install-file).
Live with it (sigh) and run mvn offline with the -o option to make it less painful.

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

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

Example of answer by Pascal Thivent
Create the POM files in your local repository (for example using install:install-file)
mvn install:install-file -DgroupId=org.apache.commons -DartifactId=codec -Dversion=1.3 -Dpackaging=jar -Dfile=lib/commons-codec-1.3.jar -DgeneratePom=true
mvn install:install-file -DgroupId=org.apache.commons -DartifactId=httpclient -Dversion=3.1 -Dpackaging=jar -Dfile=lib/commons-httpclient-3.1.jar -DgeneratePom=true
mvn install:install-file -DgroupId=org.apache.commons -DartifactId=logging -Dversion=1.1 -Dpackaging=jar -Dfile=lib/commons-logging-1.1.jar -DgeneratePom=true

Related

Maven child modules not being built

I have a relativey simple multi module maven buid with a parent pom. This includes the 2 child modules as follows:
<modules>
<module>WebApp</module>
<module>WebService</module>
</modules>
When I run mvn clean install on the top level pom it cleans & installs each child module as expected. However I am now trying to add a plugin (codehaus weblogic) goal to deploy the WebApp .war to Weblogic 10.3.4 e.g. mvn clean install weblogic:deploy. For some reason this does not run the clean and install phases but does the deploy. If I run the command from within the WebApp directory it does do the clean and install before doing the deploy.
Is there some gotcha I'm missing that will not run the child life cycle phases if running a goal at the top level. Here's the command line output:
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO] SupportClient
[INFO] SupportClient-WebServices
[INFO] SupportClient-WebApp
[INFO] Searching repository for plugin with prefix: 'weblogic'.
[INFO] org.apache.maven.plugins: checking for updates from central
[INFO] org.codehaus.mojo: checking for updates from central
[INFO] ------------------------------------------------------------------------
[INFO] Building SupportClient
[INFO] task-segment: [clean, install, weblogic:deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] [site:attach-descriptor]
[INFO] [install:install]
[INFO] Installing C:\Development\Destin8SupportClient\pom.xml to C:\Users\finchaj.HPH\.m2 \repository\com\mcpplc\supportClient\supportClient\1.0\supportClient-1.0.pom
[INFO] [weblogic:deploy]
[INFO] Weblogic Deployment beginning with parameters DeployMojoBase[adminServerHostName = localhost, adminServerProtocol = t3, adminServerPort = 8001, userId = xx, password = ****, artifactPath = C:\Development\Destin8SupportClient/WebApp/target/WebApp.war, projectPackaging = war, name = support-client-webapp, targetNames = AdminServer, remote = false]
[INFO] Weblogic Deployment parameters [-adminurl, t3://localhost:8001, -username, xx, -password, xx, -name, support-client-webapp, -targets, AdminServer, -source, C:\Development\Destin8SupportClient/WebApp/target/WebApp.war, -deploy]
weblogic.Deployer invoked with options: -adminurl t3://localhost:8001 -username xx-name support-client-webapp -targets AdminServer -source C:\Development\Destin8SupportClient/WebApp/target/WebApp.war -deploy
The file, 'C:\Development\Destin8SupportClient/WebApp/target/WebApp.war', does not exist.
It is running the weblogic:deploy goal on the top-level (pom!) module. This goal can only be run on a war or ear module.
You need to bind that goal in the WebApp sub-module to run in the install phase.
It is currently running on the top-level (pom!) module.
e.g. try adding the following to your weblogic configuration in the Webapp sub-module.
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
See also Example C-1 in this documentation
If you wish to have this run at the end of your build, once all other modules have been built, you will need to either:
re-order your sub-modules, so WebApp is last, then do as above
or, add another sub-module that will execute last, which depends on your WebApp submodule. Then, tell the weblogic plugin to use that .war file by specifying the following property maven.weblogic.war . You may want to use the dependency:copy goal first, to get the into the target dir of that last sub-module.
If you want to run the install phase first for all projects and after that deploy your projects to your webserver, you have to split the maven calls.
mvn clean install
mvn weblogic:deploy
By default, maven execute all tasks per project and to separate maven tasks the only solution to run them separately.
maven runs all the specified goals first on the parent project and then on the chldren.
From the logs it is evident that maven ran the clean and install goals of the parent and then tried to run the weblogic:deploy goal. Now, weblogic:deploy evidently is not a goal which is relevant to the parent, since it is meant to deploy a child webapp. maven does not know that and thus the failure.
Perhaps you should reconsider npellow's solution since it should work for your requirement.

Why i always gets the [INFO] Unable to find resource in repository?

greetings all
I am using maven 2 in my spring project
and when I try to build the project from the terminal using the commands (mvn clean-mvn install)
it cannot download any dependency from any of the repos, and I always gets Info like :
Downloading: http://repo1.maven.org/maven2/velocity-tools/velocity-tools-generic/1.4/velocity-tools-generic-1.4.pom
[INFO] Unable to find resource 'velocity-tools:velocity-tools-generic:pom:1.4' in repository first (http://repo1.maven.org/maven2)
Downloading: http://mirrors.ibiblio.org/pub/mirrors/maven2//velocity-tools/velocity-tools-generic/1.4/velocity-tools-generic-1.4.pom
[INFO] Unable to find resource 'velocity-tools:velocity-tools-generic:pom:1.4' in repository second (http://mirrors.ibiblio.org/pub/mirrors/maven2/)
Downloading: http://repository.jboss.com/maven2//velocity-tools/velocity-tools-generic/1.4/velocity-tools-generic-1.4.pom
[INFO] Unable to find resource 'velocity-tools:velocity-tools-generic:pom:1.4' in repository jboss (http://repository.jboss.com/maven2/)
Downloading: http://maven.jahia.org/maven2/velocity-tools/velocity-tools-generic/1.4/velocity-tools-generic-1.4.pom
[INFO] Unable to find resource 'velocity-tools:velocity-tools-generic:pom:1.4' in repository additional (http://maven.jahia.org/maven2)
Downloading: http://208.79.234.53:8081/artifactory/libs-releases-local/velocity-tools/velocity-tools-generic/1.4/velocity-tools-generic-1.4.pom
[WARNING] Unable to get resource 'velocity-tools:velocity-tools-generic:pom:1.4' from repository host.varaza.com (http://208.79.234.53:8081/artifactory/libs-releases-local): Error transferring file: Connection timed out
any ideas, why such thing occurs ?
From the repository link, it looks like this dependency does not have an associated pom file. This is the reason for the warning.
Typically, dependencies in the repository also have a pom file, which describes the project, as well as specifies its dependencies. Maven first downloads this pom file, so that it can resolve transitive dependencies, if any.
Maven is just trying to get the pom files from your repositories and will try for as long as it can't download them.
This is happening most probably because the libraries (dependencies) you reference don't have a pom file in any of the remote repositories available. This is probably normal.
However if you want to get rid of the message you could deploy minimal pom files for those dependencies in your company's repository. You can choose to just install them locally but then other developers in your team would still have those messages.
Maven can't reach the sites where dependencies are located.
Try running
ping repo1.maven.org
or opening it in your web browser. Maybe you should set the firewall to allow Maven downloading stuff from internet.
I used the following dependency - works for me.
<dependency>
<groupId>velocity-tools</groupId>
<artifactId>velocity-tools-generic</artifactId>
<version>1.4</version>
</dependency>

Maven Plugin - mvn release:prepare

Hi i'm checking via new created plugin (mpc) some parts of the pom (scm area)...but now i faced that during the mvn release:prepare of a different modules which uses the created plugin (mpc) I got the following messages:
[INFO] [INFO] Scanning the projects...
[INFO] [INFO] ...
[INFO] [INFO] not a working copy....
The output "not a working copy" ...is because I'm checking the svn info output...
The question is can I recogdnize this state during the mvn release:prepare somehow ? for example via roperties or checking an attribute of the current project ? Which means in other words that I know inside my maven plugin (mpc) that currently the release:prepare cycle is running?
I found a solution. I simply check if the current build is building an SNAPSHOT version or not (ArtifactUtil.isSnapshot() very helpfull).

Maven grails plugin issue

I'm trying to create the pom for an existing grails project via:
mvn grails:create-pom -DgroupId=ourcompany.com
Now, we have our maven repository available in a local nexus repo:
http://ourcompany.com/nexus
But when i run the above, i get the below error
Downloading: http://ourcompany.com/nexus/content/groups/public/ourcompany/com/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA.jar
[INFO] Unable to find resource 'ourcompany.com:hibernate-core:jar:3.3.1.GA' in repository
central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
But it is in there at simply:
http://ourcompany.com/nexus/content/groups/public/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA.jar
Ie, w/o the "ourcompany.com" path. From my perspective, it should just try to pull down hibernate w/o inserting the groupId, but maybe i'm not understanding how i'm supposed to run this command?
What happens is you just run:
mvn grails:create-pom

How do I stop Maven 2.x from trying to retrieve non-existent pom.xml files for dependencies every build?

In my project, there are a number of dependencies that are transitively included from other dependencies that do not have pom.xml files available in any of our corporate repositories. These are internal jar-only libraries supported by various teams which have been uploaded into repositories for convenience from non-Maven teams, however these repositories are unfortunately not mine to play with.
For these dependencies, Maven insists on trying to retrieve the poms from each of my repository list every time I run a build, or mvn dependency:list. This means maven tries to retrieve 8x pom files from 7 different repository locations, and given this is over the global corporate WAN; it's really slow.
e.g. for one particular dependency
C:\Working\dev\workspace\project>mvn dependency:list
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] ------------------------------------------------------------------------
[INFO] Building project
[INFO] task-segment: [dependency:list]
[INFO] ------------------------------------------------------------------------
[WARNING] Unable to get resource 'aGroupId:anArtifactId:pom:4.0.14i' from repository inhouse (http://someRepo1/proximity/repository/inhouse): While configuring wagon for 'inhouse': Unable to apply wagon configuration.
Downloading: http://someRepo1/proximity/repository/extFree/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository extFree (http://someRepo1/proximity/repository/extFree)
Downloading: http://someRepo1/proximity/repository/externalNonFree/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository extNonFree (http://someRepo1/proximity/repository/externalNonFree)
Downloading: http://someRepo2/efs/dist/maven/maven2-repository/incr/common/lib/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository efsRepo (http://someRepo2/efs/dist/maven/maven2-repository/incr/common/lib)
Downloading: http://someRepo2/efs/dist/btijava/maven2-repository/incr/common/lib/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository efsBTI (http://someRepo2/efs/dist/btijava/maven2-repository/incr/common/lib)
Downloading: http://someRepo3/maven/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository internal.repo (http://someRepo3/maven)
Downloading: http://repo1.maven.org/maven2/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository central (http://repo1.maven.org/maven2)`
...
etc
...
[INFO] [dependency:list {execution: default-cli}]
[INFO]
[INFO] The following files have been resolved:
... etc
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20 seconds
[INFO] Finished at: Tue Jan 26 15:01:48 CST 2010
[INFO] Final Memory: 31M/74M
[INFO] ------------------------------------------------------------------------
On the other hand, for POMs which are just invalid (older modelVersion, or corrupt/invalid XML, for example) it just checks my local repo, complains it's invalid and then continues. Which is fine; at least that doesn't try again over the WAN.
Is there a way (setting, override, repository config change) I can prevent Maven's dependency plugin/artifact resolver from repeatedly trying to locate missing POMs, if it already has the jar file in the local repo?
Specs:
Maven 2.2.1 (default superPOM plugin definitions)
JDK 1.6.0_18
Pascal's answer is correct for two local build workarounds. However, your best option is to request the owners of these projects to create POMs for the artifacts. They don't need to be complex, the simple alternative that Maven is using internally will work:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>aGroupId</groupId>
<artifactId>aArtifactId</artifactId>
<version>4.0.14i</version>
</project>
Downloading a POM is really a central concept in Maven to support transitive dependencies (actually, a dependency isn't just a JAR, see 3.5.5. Maven's Dependency Management for nice details on that) so I don't know if you can prevent it.
Of course, the right thing to do would be to fix the root cause of the problem. But if you can't, maybe you can run your build in offline mode (using the -o option). Or maybe you could just "install" the artifacts in your local repository using install:install-file and instruct the plugin to generate a pom for them using the generatePom optional parameter (but this obviously doesn't "scale" really well).
Set up a Nexus Repository (or similar) and upload the artifacts there. Nexus will automatically create basic poms for artifacts you upload.
download to local repo
setup nexus and upload
work offline
maybe the best idea is to get rid of maven all the way, it is horror !