Am Sonntag, 6. November 2011 schrieb Paolo Castagna :

> Hi Fabian
>
> On 6 November 2011 15:05, Fabian Christ 
> <[email protected]<javascript:;>>
> wrote:
> > Hi Paolo,
> >
> > Am Sonntag, 6. November 2011 schrieb Paolo Castagna :
> >
> >> I was using Maven v2.2.1.
> >> I noticed that after I run mvn clean install, if I run mvn clean
> package it
> >> works (probably because some necessary artifact in this case is already
> >> in my Maven local repository.
> >> However, if your cache does not have any org.apache.stanbol artifact
> >> in it, when I run mvn clean package I get this error:
> >>
> >> Missing:
> >> ----------
> >> 1)
> >>
> org.apache.stanbol:org.apache.stanbol.commons.stanboltools.datafileprovider:jar:0.9.0-incubating-SNAPSHOT
> >>
> >> [...]
> >>
> >>  Path to dependency:
> >>        1)
> >>
> org.apache.stanbol:org.apache.stanbol.commons.solr.core:bundle:0.9.0-incubating-SNAPSHOT
> >>        2)
> >>
> org.apache.stanbol:org.apache.stanbol.commons.stanboltools.datafileprovider:jar:0.9.0-incubating-SNAPSHOT
> >>
> >> This is not really important, I can work around that using mvn clean
> >> install.
> >>
> >
> > This is normal behavior because the Stanbol modules have compile
> > dependencies. So Maven ensures that based on the dependencies everything
> is
> > built in the correct order. Each built module has to be stored in the
> local
> > Maven repository to be available for other modules. Now a 'mvn package'
> > does not store anything in the local repo and therefore the modules are
> > missing and the dependencies can't be resolved. If you have a Maven
> project
> > with many dependent modules (artifacts), a 'mvn package' will never
> > succeed. You'll always have to use the 'mvn install' command. The 'mvn
> > package' is only useful when building a single artifact - not the whole
> > project.
>
> I though Maven would inspect the dependency graph and decide which order
> to compile stuff so that subsequent module will be ok.
>

Yes, that is the case. But after compiling the first artifact this artifact
needs to be installed in the local repo to be available for the next
artifacts. There is no other way Maven could pass compiled artifacts to
subsequent artifacts. So the local repo is used as the shared memory by
Maven. If something is not in the local repo the dependency can not be
resolved.

So to compile all artifacts only 'mvn install' works. If unsure, just use
'mvn clean install' as your default Maven command.

Best,
 - Fabian


-- 
Fabian
http://twitter.com/fctwitt

Reply via email to