As an environmental activist, use Maven2 to manage Java class libraries

Source: Internet
Author: User

Looking at the log4j-2.13.jar being infinitely downloaded from every version of each project, you will feel that managing libraries with Maven2 is really environmentally friendly.

In addition, Java class libraries also urgently need to get rid of this situation where a jar package is deployed everywhere without identity or status. It is a good direction for Maven to name the Jar.

In fact, Ruby and php both have such management tools and official websites. All Ruby packages are installed on machines like rpm. Since Maven represents Java, I hope it can be well developed.

Using Maven to do everything is a little ahead of schedule. Therefore, I only use its library management function. What I really use is pesome.

1. Find the path of the Jar package on the official website.

Http://www.mavenregistry.com/It is too practical.

2. Use Ant to call Maven to manage JAR

SpringSide uses the ant task of maven2. You do not need to install maven and directly use the ant script to download the dependency package and copy it to $ springside_home/lib. The script is as follows:

<Typedef resource = "org/apache/maven/artifact/ant/antlib. xml" uri = "urn: maven-artifact-ant">
<Classpath>
<Pathelement location = "lib/maven-artifact-ant-2.0.2-dep.jar"/>
Classpath>
  Typedef>
<Artifact: dependencies pathId = "maven. classpath" filesetId = "maven. fileset">
<Artifact: pom file = "pom. xml"/>
  Artifact: dependencies>

<Copy todir = "lib/">
<Fileset refid = "maven. fileset"/>
<Mapper type = "flatten"/>
  Copy>

Read antlib. xml from the maven-artifact-ant-2.0.2-dep.jar and read a bunch of maven tasks.

The 2nd statement analyzes the jar in pom. xml.Http://repo1.maven.org/maven2Download the jar to the $ {user. home}/. m2/directory. And define all the jar files as ant's fileset object-maven. fileset.

In the first sentence, copy the jar file defined by maven. fileset in $ {user. home}/. m2/to the project lib directory.


However, Maven2 is relatively immature. For example, the pom of many projects is gibberish. For example, the speed on the maven official website is too low, and it often gets cramps, for example, there are some new official websites that you want.

 3. self-built private servers
 
Creating a private server on your own is a good idea. In fact, it is also simple. Just upload the $ {user. home}/. m2/directory to an http server.
In the pom file, write the http url of the private server in front of the official website.

<Repositories>
<Repository>
<Id> springside Id>
<Url> http://www.springside.org.cn/maven2 Url>
Repository>
<Repository>
<Id> maven Id>
&

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.