2.1. Installing a Plug-in from a Remote RepositoryAll your Java buddies are using the latest and greatest version of some fancy Maven plug-in, and you are starting to feel left out and ignored. How did they get the plug-in? And once they obtained it, how did they install it? To demonstrate the process of installing a plug-in, install the Apache Axis plug-in in your Maven installation. 2.1.1. How do I do that?The first thing you need to know is the location of the Maven remote repository where the plug-in you wish to install is located. In the case of the Apache Axis plug-in, the repository is at http://maven-plugins.sourceforge.net/maven/. However, this repository is synced every few hours to the ibiblio repository at http://www.ibiblio.org/maven/. The ibiblio repository is the default Maven remote repository and the one that will be used if you don't tell Maven otherwise. Should you still wish to add the remote repository to your Maven configuration, you should modify your build.properties file (or project.properties file if you want to share the settings with others) and include the following property: maven.repo.remote=http://www.ibiblio.org,http://maven-plugins.sf.net/maven However, as this repository is synced with ibiblio, it's not necessary for installing the Axis plug-in. At the time of this writing, the latest version of the Axis plug-in (as can be seen at http://www.ibiblio.org/maven/maven-plugins/plugins/) is version 0.7. To install it, you need to use the plugin:download goal of the Plugin plug-in, passing it some properties, as shown shortly. In the same manner you define a groupId, an artifactId, and a version when you create a dependency in your project.xml file, you need to pass the same properties to the Plugin plug-in so that it knows the exact location of the plug-in you want to download and install. Issue the following command from any directory to install version 0.7 of the Axis plug-in: C:\>maven plugin:download -DgroupId=maven-plugins ^ More? -DartifactId=maven-axis-plugin -Dversion=0.7 _ _ _ _ | \/ |_ _ _Apache_ _ _ _ _ | |\/| / _` \ V / -_) ' \ ~ intelligent projects ~ |_| |_\_ _,_|\_/\_ _ _|_||_| v. 1.0.2 build:start: plugin:download-artifact: [echo] repo is 'http://www.ibiblio.org/maven' [echo] trying to download http://www.ibiblio.org/maven/maven-plugins/plugins/ maven-axis-plugin-0.7.jar 11K downloaded plugin:download: [copy] Copying 1 file to C:\apps\maven-1.0.2\plugins BUILD SUCCESSFUL Total time: 2 seconds You may wonder how to extract the groupId, artifactId, and version information from the plug-in URL. Figure 2-1 shows how to perform this mapping for the Axis plug-in. Figure 2-1. Convention for locating a plug-in in remote repository
Note that you can also run the plugin:download goal in interactive mode by simply executing the plugin:download goal with no options: C:\>maven plugin:download _ _ _ _ | \/ |_ _ _Apache_ _ _ _ _ | |\/| / _` \ V / -_) ' \ ~ intelligent projects ~ |_| |_\_ _,_|\_/\_ _ _|_||_| v. 1.0.2 What is the artifactId of the plugin to download (e.g. maven-axis-plugin)? maven-axis-plugin What is the groupId of the plugin to download? [maven] maven-plugins What is the version of the plugin to download? 0.7 build:start: plugin:download-artifact: [echo] repo is 'http://www.ibiblio.org/maven' [echo] trying to download http://www.ibiblio.org/maven/maven-plugins/plugins/ maven-axis-plugin-0.7.jar 11K downloaded plugin:download: [copy] Copying 1 file to C:\apps\maven-1.0.2\plugins BUILD SUCCESSFUL Total time: 33 seconds In order to verify that the plug-in has been installed successfully, try listing its goals by typing maven -P axis. You should see a list of goals available in the Axis plug-in. Note: In Maven 2, plug-ins will be downloaded on demand. The first time a plug-in is used, it will be downloaded from a remote repository. To check that the correct version of the plug-in is installed (version 0.7 for this lab), type maven -i: C:\>maven -i [...] maven-aspectj-plugin-3.2 maven-aspectwerkz-plugin-1.2 maven-axis-plugin-0.7 maven-caller-plugin-1.1 maven-castor-plugin-1.2 [...] That's it! The Axis plug-in is installed and available, and all you had to do was execute the plugin:download goal. 2.1.2. What about......the other Maven remote repositories? At the time of this writing, there are several well-known public Maven remote repositories that are automatically synced with the main ibiblio repository:
If you are using the main ibiblio repository there is no reason to add these repositories to your own list of remote repositories, as they all serve as sources for the default repository. |