Creating and using Maven assets

If you enabled the Maven library, you can create and use assets that can be used with Maven.

Before you begin

Before you can create and use Maven assets, a repository administrator must enable the Maven model library. For more information, see Enabling the Maven library.

The mvn client can integrate with Rational Asset Manager, using Rational Asset Manager as a Maven repository.

Additional configuration of the Maven client is required if the Rational Asset Manager server is using the HTTPS protocol. If you are using certificates signed by a certificate authority, see Remote repository access through authenticated HTTPS in the Maven documentation for more information. If you are using self-signed certificates, you must add the server's certificate as a trusted certificate to the keystore on the client computer. Details on this procedure are beyond the scope of this documentation. One option is to use InstallCert.java, which is available for download on the web, to add the self-signed certificate to the local keystore.

Procedure

  1. Create and submit an asset for each Maven asset. Add the Group.Id attribute to the asset. To learn more about creating and submitting assets, see Creating and submitting assets. The name of the asset in Rational Asset Manager corresponds to the artifactId element in Maven. The version of the asset corresponds to the version element in Maven.
  2. If you have created a pom.xml file for the Maven project, add the pom.xml file to the asset. To learn more about the Project Object Model (POM), see the POM Reference in the Maven documentation.
  3. Run the POM Generation policy on the asset. To learn more about policies, see Policies for lifecycles in Rational Asset Manager. The POM Generation policy adds metadata required by Maven to the asset.
  4. On the computer where you plan to run Maven, open the settings.xml file in the user_home/.m2 directory.
  5. In the settings.xml file, add server, profile, and activeProfile elements for your Rational Asset Manager server, as described in the following example.
    <?xml version="1.0" encoding="UTF-8"?>
    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
              xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    
    <servers>
        <server>
          <id>rational.repo</id>
          <username>user</username>
          <password>pass</password>
        </server>
      </servers>
    
      <profiles>
        <profile>
          <id>assetmanager</id>
    	  <repositories>
            <repository>
              <id>rational.repo</id>
    		  <url>http://server.example.com:9080/ram.ws/maven2/Sample%20Open%20Source/Maven%20Artifact/</url>
            </repository>
    	  </repositories>
        </profile>
      </profiles>
    
      <activeProfiles>
        <activeProfile>assetmanager</activeProfile>
      </activeProfiles>
    
    </settings>
    id
    There are two different types of id elements that you must configure. The id elements can be any unique identifiers. As shown in the example file, the id of the server element must match the id of the repository element. The id of the profile element must match the activeProfile element.
    username
    The username to use for authentication with the Rational Asset Manager server.
    password
    The password to use for authentication with the Rational Asset Manager server.
    url
    Specify the Rational Asset Manager repository by typing a URL with the following format: http://hostname:portnumber/web_services_context-root/maven2/community_name/asset_type. The example file shows a typical URL for a Rational Asset Manager server running on port 9080 at server.example.com, for assets of type Maven Artifact in the Sample Open Source community
    activeProfile
    The activeProfile element must match the id of the profile element.
    For general information on editing the settings.xml file in Maven, see the Settings Reference in the Maven documentation.

Results

When you run Maven (the mvn client), it accesses the files stored in Rational Asset Manager.
Note: Only Maven 2 is supported.

Feedback