[Maven 2] Repositories

来源:百度文库 编辑:神马文学网 时间:2024/04/30 08:20:22
$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.ibiblio.org/maven2/ Mirrorshttp://mirrors.dotsrc.org/maven2/http://public.planetmirror.com/pub/maven2/
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 byWagon HTTP, HTTPS, FTP, SFTP, SCP, WebDAV, … In principle … HTTP and HTTPS validated by the author HTTPS issue:self-signed certificates Can be configure to do authentification
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, atPeopleWare
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
Most often project-related All developers for a project need same setup Project dependent settings go in pom.xml
Authentification depends on particular user Access settings (username, password) go in ~/.m2/settings.xml -element
Setting up Multiple Repositories
Configuring Mirrors
Depends on particular user User-dependent settings go in~/.m2/settings.xml -element
Using Mirrors for Repositories
Configuring HTTP Proxies
Depends on particular user User-dependent settings go in~/.m2/settings.xml -element
Configuring a proxy
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 atcentral
Abberations
Maven 1 legacy
Directory structure based on groupId is new since maven 2 To be backward compatible, old maven 1 structure is kept too E.g., Apache Jakarta CommonsgroupId=commons-XXX groupId=org.apache.… ???
E.g., HibernategroupId=hibernate (Hibernate 1-3)groupId=net.sf.hibernate (Hibernate 1-2)groupId=org.hibernate (Hibernate 3)
Migration is in progress
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 […] http://java.sun.com/products/javamail/downloads/index.html […]
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 Last-but-one phase indefault build lifecycle
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, ormaven-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 andchecksum 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
This work is licensed under aCreative CommonsAttribution 2.0 Belgium License.Jan DockxPeopleWare n.v., © 2005