MAVEN Warehouse Rollup

Source: Internet
Author: User
Tags maven central sonatype

Source: http://tianya23.blog.51cto.com/1081650/3869081. Maven Warehouse Address:

A shared warehouse
http://repo1.maven.org/maven2/
http://repository.jboss.com/maven2/
http://repository.sonatype.org/content/groups/public/
http://mirrors.ibiblio.org/pub/mirrors/maven2/org/acegisecurity/

A private warehouse
http://repository.codehaus.org/
http://snapshots.repository.codehaus.org/
Http://people.apache.org/repo/m2-snapshot-repository
http://people.apache.org/repo/m2-incubating-repository/

At the same time can build their own MAVEN warehouse: the way to build the following: http://juvenshun.javaeye.com/blog/3495342, the collection of external warehouse address http://www.ibiblio.org/maven/ Mule/dependencies/maven2/attached: Maven Warehouse build Access http://nexus.sonatype.org/downloads/download Nexus.
To start a nexus is to start a Web server whose default address is localhost:8081. The Nexus runs in a servlet container called jetty, and it starts with a local service wrapper called Tanuki Java Service wrapper. This service wrapper can be configured to run the Nexus in the form of a Windows service or UNIX daemon thread. To start the nexus, you need to find the appropriate startup script for your platform. To view a list of available platforms, view the contents of the ${NEXUS_HOME}/BIN/JSW directory.
The executable file is under%nexus installation directory%\nexus-webapp-1.0.0\binjsw\windows-x86-32:
Installnexus.bat/uninstallnexus.bat is the install/uninstall Nexus for Windows service.
Nexus.bat is to start the Nexus directly on the command line, if you do not want to install the Nexus for Windows service, you can use this file to manually control the Nexus's startup exit.
1. Configure Nexus
First login, default address http://localhost:8081/nexus/, default username password is admin/admin123.
The Nexus default is to turn off the remote index download feature. How to open:
Click repositories below the Administration menu to place the three warehouses Apache Snapshots,codehaus Snapshots,maven Central
Download Remote indexes modified to True. Then right-click on each of the three warehouses and select Re-index so the Nexus will download the remote index file.
2. Managing warehouses
Log in as Admin user and click on the left navigation menu administration below repositories. Nexus offers three different warehouses.
(1) Agent Warehouse
An agent repository is a proxy to the remote repository. By default, the Nexus comes with a proxy repository configured as follows:
Apache Snapshots
This warehouse contains a snapshot version from the Apache Software Foundation. Http://people.apache.org/repo/m2-snapshot-repository
Codehaus Snapshots
This repository contains a snapshot version from Codehaus. http://snapshots.repository.codehaus.org/
Central Maven Repository
This is the central Maven repository (release version). http://repo1.maven.org/maven2/
(2) Host Warehouse
A host repository is a warehouse hosted by a nexus. Maven comes with a host repository configured as follows.
3rd party
This host repository should be used to store third-party dependencies that are not found in the public Maven repository. Examples of such dependencies are: Your organization uses, commercial, private libraries such as Oracle JDBC drivers.
Releases
This hosting repository is where your organization publishes its internal releases.
Snapshots
This host repository is where your organization publishes internal snapshot versions.
(3) Virtual Warehouse
A virtual warehouse exists as an adapter for Maven 1. Nexus comes with a central-m1 virtual warehouse
3. Management Group
Group is a powerful feature of Nexus that allows you to combine multiple warehouses in a single URL. The nexus comes with two groups: public and public-snapshots. The public group combines three host warehouses: 3rd party, releases, and snapshots, and the central Maven repository. In the Public-snapshots group, the Apache snapshots and Codehaus snapshots warehouses were combined.
4. Configure Maven
To have MAVEN use the Nexus as a repository, modify the ~/.m2/settings.xml.
XML code
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>local Private nexus</name>
<url>http://localhost:8081/nexus/content/groups/public</url>
</repository>
</repositories>
</profile>
<profile>
<id>nexus-snapshots</id>
<repositories>
<repository>
<id>nexus-snapshots</id>
<name>local Private Nexus Snapshots</name>
<url>http://localhost:8081/nexus/content/groups/public-snapshots</url>
</repository>
</repositories>
</profile>
</profiles><activeProfiles>
<activeProfile>nexus</activeProfile>
<activeProfile>nexus-snapshots</activeProfile>
</activeprofiles>5. Deploying artifacts to Nexus
To deploy artifacts to the Nexus, provide the warehouse URL in Distributionmanagement, and then run MVN deploy. Maven pushes the project Pom and widgets into your Nexus installation via a simple HTTP put. You need to configure the repository in the Distributionmanagement section of your project Pom.
XML code
<distributionManagement>
<repository>
<id>releases</id>
<name>internal releases</name>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>Snapshots</id>
<name>internal snapshots</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement> This is not the end, if the deployment will be error, but also in the ~/.m2/settings.xml to add the following server login information:
XML code
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>Snapshots</id>
<username>admin</username>
<password>admin123</password>
</server> deploy third-party artifacts:
A component might be a JDBC driver for a private database, such as Oracle, or you rely on another jar, which is neither open source nor freely available. In such cases, you will need to manually bring the artifacts and post them to your own warehouse. Nexus provides the host's "Third-party" warehouse for this purpose.
Use the following command to publish the file to the Nexus:
Java code
MVN Deploy:deploy-file-dgroupid=com.oracle-dartifactid=ojdbc14
-dversion=10.2.0.3.0-dpackaging=jar-dfile=ojdbc.jar
-durl=http://localhost:8081/nexus/content/repositories/thirdparty
-drepositoryid=thirdparty6. Nexus Listening Port
By default, the Nexus listens on port 8081. You can change this port by changing the value of the ${nexus_home}/conf/plexus.properties, stop the Nexus, change the value of the Applicationport in the file, and then restart the Nexus.
7.Maven Profiles
The profile in Maven is an optional set of configurations that you can use to set or override the configuration defaults. With profile, you can customize the build for different environments. Profile can be configured in Pom.xml and given an ID. You can then use the command-line tag to tell Maven to run the target in a specific profile when you run MAVEN. The following Pom.xml uses production profile to override the default compiler plug-in Settings.
XML code
<profiles>
<profile>
<id>production</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<debug>false</debug>
<optimize>true</optimize>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
To run MVN install using production profile, you need to pass in the-pproduction parameter at the command line. To verify that the production profile overrides the default compiler plug-in configuration, you can run Maven in such a way as to turn on debug output (-X).
If you start using MAVEN profile extensively, you will want to separate the profiles from the Pom, using a separate file such as Profiles.xml. You can mix and use profiles defined in Pom.xml and external profiles.xml files. Just put the profiles element in the Profiles.xml file in the ${basedir} directory and run Maven as usual. The approximate contents of the Profiles.xml file are as follows:
XML code
<profiles>
<profile>
<id>development</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<debug>true</debug>
<optimize>false</optimize>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>production</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<debug>false</debug>
<optimize>true</optimize>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles> settings profile can be applied to all projects that you build with Maven. You can define settings profile in two places: User-specific settings profiles defined in ~/.m2/settings.xml, or defined in ${m2_home}/conf/ The global settings profile in Settings.xml.

MAVEN Warehouse Rollup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.