Dário Luís Coneglian Oliveros ha scritto:
> Thanks for the reply.
> As a matter of fact packaging is not really my problem. Assembly plug-in 
> would definitely do that work.
> What I am trying to do is to create an offline environment where a user could 
> compile a maven project without having to search for artifacts on either 
> internet or intranet. So I was thinking of packaging a repo together with my 
> maven project and as far as I know I would have to convert a local repo to a 
> remote one if I wanted to use this repo as if it were a mirror of central 
> (please see thread "[M2] Howto Set Up Quickly an Offline Internal 
> Repository?" for more info).
> 
> Any thoughts ?


In the Apache JAMES project we wanted to use a local repository for
direct dependencies (not for plugin dependencies) so that an offline
build is possible when plugins are available.

We defined a "local" profile in our parent pom disabling all repositories:
    <profile>
      <id>local</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>http://repo1.maven.org/maven2</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
        <repository>
          <id>apache.releases</id>
          <name>Apache Main M2 Repository</name>

<url>http://people.apache.org/repo/m2-ibiblio-rsync-repository</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
        <repository>
          <id>apache.snapshots</id>
          <name>Apache Snapshot Repository</name>
          <url>http://people.apache.org/repo/m2-snapshot-repository</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>
    </profile>


Then in the project pom we define a local repository:

  <repositories>
    <repository>
      <id>local-mime4j-stage-repository</id>
      <name>Local mime4j stage repository</name>
      <!-- Please note that due to
http://jira.codehaus.org/browse/MNG-2896 -->
      <!-- If you don't have james-project checked out in
../james-project -->
      <!-- you will have to place your absolute path to the project
instead -->
      <!-- of ${basedir}, or, otherwise, manually install the parent
poms -->
      <!--
           mvn -fignorepom.xml install:install-file
              -Dfile=stage\org.apache.james\poms\james-parent-1.1.pom
              -Dpackaging=pom
              -DgroupId=org.apache.james
              -DartifactId=james-parent
              -Dversion=1.1
           mvn -fignorepom.xml install:install-file
              -Dfile=stage\org.apache.james\poms\james-project-1.1.pom
              -Dpackaging=pom
              -DgroupId=org.apache.james
              -DartifactId=james-project
              -Dversion=1.1
       -->
      <url>file://${basedir}/stage</url>
      <layout>legacy</layout>
      <snapshots>
        <enabled>true</enabled>
        <checksumPolicy>ignore</checksumPolicy>
      </snapshots>
      <releases>
        <enabled>true</enabled>
        <checksumPolicy>ignore</checksumPolicy>
      </releases>
    </repository>
  </repositories>

and we created a "stage" folder in our sourcetree including a "legacy
style" repository:
http://svn.apache.org/repos/asf/james/mime4j/trunk/stage/

this way the mvn -Plocal takes the dependencies from the stage folder
and does not lookup remote repositories.


The use of ${basedir} in the url of a repository have 2 issues:
1) when maven lookups for the parent pom the ${basedir} is not yet
resolved (or at least maven is ignoring that repository anyway).
2) when you have a reactor build every module will search in its own
stage folder and not in the stage folder for the parent pom.

To solve 1 I run the install-file for the parent pom (like I wrote in
the comments above.

To solve 2 I add also a file://${basedir}/../stage to module
repositories so they look in the parent stage folder.

I know they are hacks, but until maven won't provide a good solution for
selfcontained/offline builds we opted for this solution.

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to