`
www-hello
  • 浏览: 100437 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Configuring Build Environment for Flexmojos

    博客分类:
  • flex
阅读更多

网址:http://www.sonatype.com/books/maven-book//reference/flex-dev-sect-config-build.html

 

20.2. Configuring Build Environment for Flexmojos

Before you attempt to compile Flex libraries and applications with Maven, you will need to complete two configuration tasks:

  • Configure your Maven settings to reference a repository which contains the Flex framework

  • Add the Flash Player to your PATH to support Flex unit testing

  • (Optional) Configure your Maven Settings to include the Sonatype plugin group

20.2.1. Referencing a Repository with the Flex Framework

To setup your Maven environment, you can install a simple ~/.m2/setting.xml file which references the Sonatype public repository directly, or you can install Nexus and add the Sonatype public repository as a proxy repository in your own repository manager. While the most straightforward option is to use the Maven Settings shown in section Section 20.2.1.1, “Using Sonatype's Repository Directly” , downloading and installing Nexus will give you the control and flexibility you need to cache and manage artifacts generated by your own build. If you are just interested in getting up and running with Flexmojos, read Section 20.2.1.1, “Using Sonatype's Repository Directly” next. If you are interested in a long-term solution which can be deployed to support a development team, continue to Section 20.2.1.2, “Proxying Sonatype's Repository with Nexus” .

If your organization is already using Sonatype Nexus to proxy remote repositories, you probably already have a customized ~/.m2/settings.xml file which points to a single Nexus group. If this is your situation, you should add a Proxy repository for the Sonatype public repository group at http://repository.sonatype.com/content/groups/public . Adding a proxy repository for this remote group and then adding this group to your Nexus installation's public repository group will give clients of your Nexus instance access to the artifacts from the Sonatype repository.sonatype.com Nexus instance.

20.2.1.1. Using Sonatype's Repository Directly

Before you run Maven against Flexmojos, you need to configure you ~/.m2/settings.xml to contain the following XML:

Example 20.1. Settings XML for Sonatype Repository

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://repository.sonatype.org/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!—-Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!—-make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>
 

Note

We suggest that you place the contents of Example 20.1, “Settings XML for Sonatype Repository” in you ~/.m2/settings.xml because it is the default location for Maven Settings. But, if you have already customized your ~/.m2/settings.xml you can also put the the contents of this file in another settings file such as ~/.m2/sonatype-settings.xml . If you do this, you just have to remember to specify the location of the settings file on every Maven command line. For example, mvn install would become mvn -s ~/.m2/sonatype-settings.xml install .

The XML shown in Example 20.1, “Settings XML for Sonatype Repository” , will configure Maven to retrieve all artifacts from the Sonatype Nexus installation which is available at http://repository.sonatype.org . This Nexus installation provides a public group which combines a number of different repositories into a single repository group. Instead of configuring your clients to retrieve artifacts from several different repositories, the Sonatype Nexus repository manager allows you centralizing clients to one point of contact: a single Nexus repository group. Builds with use the Flexmojos plugin rely on Flex artifacts which are not yet available from standard repositories like the Central Maven Repository. Pointing your build at the Sonatype repository allows you to retrieve the necessary libraries, SWFs, and SWCs which are required when building Flex applications.

20.2.1.2. Proxying Sonatype's Repository with Nexus

Instead of pointing directly at the Sonatype public repository, Sonatype recommends that you install a repository manager and proxy the Sonatype public repository. When you proxy a remote repository with a repository manager such as Nexus, you gain a level of control and stability not possible when your build relies directly on external resources. In addition to this control and stability, a repository manager also provides you with an deployment target for binary artifacts generated by your own builds. For instructions on downloading, installing, and configuring Nexus, refer to the Installation chapter in Repository Management with Nexus . Once Nexus is installed and started, complete the following steps to add a proxy repository for the Sonatype public repository.

To add a new proxy repository, click on the Repositories link under Views/Repositories in the Nexus menu on the left-hand side of the Nexus user interface. Clicking on Repositories will load the Repositories panel. In the Repositories panel, click on the Add.. button and select Proxy Repository as shown in Figure 20.1, “Adding a Proxy Repository to Sonatype Nexus” .

 

Figure 20.1. Adding a Proxy Repository to Sonatype Nexus

 

Figure 20.1. Adding a Proxy Repository to Sonatype Nexus


Once you've created a new Proxy repository, you will need to configure it to point to the Sonatype public repository. Select the new repository, and then select the Configuration tab in the lower half of the window. Populate the following field with the values shown in Figure 20.2, “Configuring the Sonatype Public Proxy Repository” .

     Figure 20.2. Configuring the Sonatype Public Proxy Repository

Figure 20.2. Configuring the Sonatype Public Proxy Repository


Once you have populated the fields shown in Figure 20.2, “Configuring the Sonatype Public Proxy Repository” click the Save button to save the proxy repository and start proxying the Sonatype public repository. Nexus ships with a public repository group, which combines several repositories into a single point of contact for Maven clients. To complete our setup of the new proxy repository, you should add this new proxy repository to the Nexus public group. To do this, return to the list of repositories which should now be visible in the upper half of the Repositories panel as shown in Figure 20.2, “Configuring the Sonatype Public Proxy Repository” . Click on the Public Repositories group and then click on the Configuration tab in the lower half of the Repository panel. Clicking the Configuration tab will expose the Group configuration form shown in Figure 20.3, “Adding the Sonatype Public Proxy to the Public Repositories Group” .

 

 Figure 20.3. Adding the Sonatype Public Proxy to the Public Repositories Group

Figure 20.3. Adding the Sonatype Public Proxy to the Public Repositories Group


To add the Sonatype Public Proxy to the Public Repositories group simply drag and drop the Sonatype Public Proxy repository from the Available Repositories list to the Ordered Group Repositories list. Click Save , and you have successfully added a proxy of the Sonatype public repository to your Nexus installation. Whenever a client requests an artifact from this repository group, if Nexus has not already cached a matching artifact, it will query the Sonatype public repository at http://repository.sonatype.org/content/groups/public . Your Nexus installation will maintain a local cache of all artifacts retrieved from the Sonatype repository. This local cache gives you more control and contributes to a more stable build environment. If you are setting up a group of developers to rely upon artifacts from the Sonatype public repository, you'll have a completely self-contained build environment that won't be subject to the availability of the Sonatype repository.

The final step to connecting your Maven installation to the Nexus instance you just configured is to update your Maven Settings to use your Nexus repository group as a mirror for all repositories. To do this, you need to put the following XML in your ~/.m2/settings.xml file.

Example 20.2. Settings XML for Local Nexus Instance

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!—-Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!—-make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>
 

This XML file configures Maven to consult a single public repository group for all configured repositories and plugin repositories. It is a simple way to guarantee that every request for an artifact is made through your Nexus installation.

Note

The only difference between Example 20.2, “Settings XML for Local Nexus Instance” and Example 20.1, “Settings XML for Sonatype Repository” is the settings/mirrors/mirror/url element. The first example addresses the Sonatype public repository directly which the second example references a public group on a Nexus instance you maintain. You use Nexus because it allows you to control the repositories and artifacts that are used in your build system. You can think of Nexus as something of a firewall or a centralized point of contact between your builds and the external environment.

 

 

 

 

 

 

 

  • 大小: 65.8 KB
  • 大小: 89.3 KB
  • 大小: 80.4 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics