分享

[Maven 2] Repositories

 larrin 2007-04-13
$Revision: 1.9 $ $Name: $ $Date: 2006/04/13 13:54:09 $ Working with maven 2
$Source: /ppw/training/maven/repository/maven2/src/html/repositories.html,v $
Where Do All the Goodies Come From?
  • Things maven needs are downloaded JIT
    • Plugins
    • Dependencies for projects
  • From remote repositories on the ‘net
  • Cached in a local repository
    • ~/.m2/repository/

Remote Repositories

  • Many repositories
    • Central repository
      • Under control of the maven team
      • Contains all known Java artifacts that they are allowed to distribute
        • Could not be served by Apache because of Apache license politics
      • http://www./maven2/
      • Mirrors
      • ibiblio is constantly under strain (servers, bandwith)
        • Mirrors are not really fast either
        • Request not to rsync central
        • Special maven-proxy exists
    • 3th party repositories
      • Some providers choose to distribute their artifacts themselves
    • Company-local repositories
      • Own artifacts
      • Private artifacts (access protection)
      • Missing artifacts
        • License issues (access protection)
        • Obscure artifacts
        • Solution to artifact naming problems
  • Repositories can be accessed via any protocol supported by Wagon
    • HTTP, HTTPS, FTP, SFTP, SCP, WebDAV, …
      • In principle …
      • HTTP and HTTPS validated by the author
  • Our artifacts are also deployed to remote repositories for others to use
    • Private company release repository
      • Seperate snapshot repository: don‘t annoy other people with development versions
    • Public company release repository
    • Central repository

Typical setup

In practice, at PeopleWare

Project Server Layout

/
server in DMZ
|-- ppw/
            |    |-- projects/
 
|    |   |-- dgt/
directory per client
|    |   |   |-- cvs_repository/
CVS repository root; access via ssh only
|    |   |   |   |-- CVSROOT/...
 
|    |   |   |   |-- OSMOT/...
            |    |   |   |   |-- OSMOT2/...
            |    |   |   |   |-- expertPoll/...
            |    |   |   |   `-- expertPollWebapp/...
module per project
|    |   |   |-- public_html/
project web home
|    |   |   |   |-- .htaccess
access only for PeopleWare staff and client staff
|    |   |   |   |-- index.html
            |    |   |   |   |-- installation.html
            |    |   |   |   |-- contact.html
            |    |   |   |   .
            |    |   |   |   .
            |    |   |   |   .
            
information for the client
|    |   |   |   |-- developer/
            |    |   |   |   |   |-- OSMOT/...
            |    |   |   |   |   |-- OSMOT2/..
            |    |   |   |   |   |-- expertPoll/...
            |    |   |   |   |   `-- expertPollWebapp/...
maven generated project sites
|    |   |   |   `-- maven_repository/
            |    |   |   |       `-- be/
            |    |   |   |           `-- peopleware/
            |    |   |   |               `-- dgt/
            |    |   |   |                   |-- OSMOT/
            |    |   |   |                   |   |-- 1.0.0/...
            |    |   |   |                   |   .
            |    |   |   |                   |   .
            |    |   |   |                   |   .
            |    |   |   |                   |
            |    |   |   |                   |-- OSMOT2/...
            |    |   |   |                   |-- expertPoll/...
            |    |   |   |                   `-- expertPollWebapp/...
maven release repository for this client
|    |   |   `-- share/
            |    |   |       |-- public/...
smb; non-version controlled, private material
|    |   .       .
            |    |   .       .
            |    |   .       .
            .    |
            .    |-- sysadmin/...
            .    `-- training/...
 
  • un*x group per client

Configuring Which Repositories to Use

Configuring Mirrors

Configuring HTTP Proxies

Repository Layout

  • Directory structure based on groupId
    • s/\./\//
    • Like Java package structure
    • Suggestion to use reverse domain name of issuing entity as part of groupId
      • Like Java package names
    • E.g., groupId=be.peopleware.training.maven2
      • be/peopleware/training/maven2/
  • artifactId
    • be/peopleware/training/maven2/helloWorld/
  • version
    • be/peopleware/training/maven2/helloWorld/1.2.3/
  • Everything for this artifact/version in this directory
    • Artifact
      • be/peopleware/training/maven2/helloWorld/1.2.3/helloWorld-1.2.3.jar
    • Consolidated POM
      • be/peopleware/training/maven2/helloWorld/1.2.3/pom.xml
    • Potentially other assemblies
      • E.g., source zip
    • Checksums for each file
      • MD5
  • Have a look at central

Abberations

Maven 1 legacy

Standard Sun Specification API‘s

  • Package javax.…
  • Naming convention
    • Legacy issues
  • Some cannot be stored in public repository because of licensing issues
    • Only POM in central
    • Says where to download artifact
    • E.g., javax.mail
      • […]
                    <distributionManagement>
                    <downloadUrl>http://java./products/javamail/downloads/index.html</downloadUrl>
                    </distributionManagement>
                    […]
                    
  • Company missing-artifacts repository
    • Download artifact from given location
    • Install in company missing-artifacts repository, with POM, checksum

Local Installation

Try-out You‘re Own Stuff Locally First

  • Run mvn install
  • Artifact is added correctly to local repository
    • With POM
    • With checksum

Solve Repository Problems

  • Install artifacts in his local repository directly
  • Do it by hand, or
  • maven-install-plugin:install-file
    • mvn install:install-file -DgroupId=group-id         -DartifactId=artifact-id         -Dversion=version         -Dpackaging=packaging         -Dfile=fileToInstall
              
    • Copies the fileToInstall into the local repository, in the directory structure based on group-id, with file name artifcact-id-version.packaging
  • You should provide a POM and checksum too (by hand for now)
  • Bad practice in a group effort
    • The problem you are having, other people will encounter too
    • Better do it in a company repository from the start

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多