Nexus Documentation - Nexus IQ Server 1.26 - Sonatype.com

Documentation Nexus IQ Server 1.26

Nexus IQ Server 1.26

Our documentation site has moved. For the most current version, please see http://help.sonatype.com

23.4. Using Sonatype CLM for Maven with Other IDEs

While the integration with Eclipse offered by Sonatype CLM for IDE is the most powerful tooling for developers available, users of other popular integrated development environments are not left without support. All common Java IDEs have powerful integration with Apache Maven and therefore can be used together with Sonatype CLM for Maven to evaluate projects against your Sonatype CLM server.

This chapter showcases the integration with IntelliJ IDEA from JetBrains and NetBeans IDE from Oracle.

23.4.1. Maven Plugin Setup

In our example setup for the usage with other IDE’s we are going to add a plugin configuration for Sonatype CLM for Maven into the pom.xml file of the project we want to analyze as documented in Example Configuration of Sonatype CLM for Maven. This configuration defines the serverUrl of the CLM server to be contacted for the evaluation, the applicationId used to identify the application in the CLM server to evaluate against and the stage configuration to use for the evaluation.

Example Configuration of Sonatype CLM for Maven.

<build>
  <pluginManagement>
    <plugins>
      <plugin>
        <groupId>com.sonatype.clm</groupId>
        <artifactId>clm-maven-plugin</artifactId>
        <version>2.6.0-01</version>
        <configuration>
          <serverUrl>http://localhost:8070</serverUrl>
          <applicationId>test</applicationId>
          <stage>develop</stage>
        </configuration>
      </plugin>
    </plugins>
  </pluginManagement>
</build>

With this configuration in place a user can kick off an evaluation with the command line mvn package clm:evaluate.

This will result in an output detailing the components to be analyzed, any policy violations, and a link to the resulting report in the Sonatype CLM server.

| | | | To speed the build up you can skip the test compilation and execution by
passing -Dmaven.test.skip=true on the command line invocation, since it is not
needed for the CLM evaluation. |

23.4.2. IntelliJ IDEA

IntelliJ IDEA supports Maven projects natively and you can simply open a project in the IDE by opening the pom.xml file.

Once your project is opened and you have added the plugin configuration for Sonatype CLM for Maven from Example Configuration of Sonatype CLM for Maven, you can create a configuration to run the desired Maven command.

Select Edit Configurations from the Run menu, press the + button and select Maven to add a new configuration. Enter the command line and other desired details as displayed in Figure 23.1, “Creating a Maven Run Configuration for a CLM Evaluation in IntelliJ”.

Figure 23.1. Creating a Maven Run Configuration for a CLM Evaluation in IntelliJ

After pressing OK in the dialog the new configuration will be available in the run configuration dropdown as well as the Maven Projects view. You can open the view using the View menu, selecting Tools Window and pressing Maven Projects. You will see the window appear in the IDE looking similar to Figure 23.2, “Maven Projects View with the CLM Evaluation Run Configuration in IntelliJ”. It displays the run configuration selector with the green play button on the top as well as the Maven project with the CLM evaluation run configuration.

Figure 23.2. Maven Projects View with the CLM Evaluation Run Configuration in IntelliJ

You can press the green play button beside the run configuration or the configuration entry itself in the Maven Projects window, to start a build. The build will run in an embedded console window in the IDE as displayed in Figure 23.3, “CLM for Maven Output in the Run Console in IntelliJ”, and show all the output from the Maven build including any error messages and the link to the produced report in the Sonatype CLM server. Policy violations can be configured to result in a build failure.

Figure 23.3. CLM for Maven Output in the Run Console in IntelliJ

23.4.3. NetBeans IDE

NetBeans IDE supports Maven projects natively and you can simply open a project in the IDE by choosing Open Project from the File menu and navigating to the directory that contains your project.

Once your project is opened, you can expand the Project Files section in the Projects window as displayed in Figure 23.4, “Project View with the pom.xml in NetBeans”. Double-click on the pom.xml file and add the plugin configuration for Sonatype CLM for Maven from Example Configuration of Sonatype CLM for Maven.

Figure 23.4. Project View with the pom.xml in NetBeans

If you right-click on the pom.xml file, you can choose Run Maven and Goals, to display the dialog displayed in Figure 23.5, “Maven Goal Setup for a CLM Evaluation in NetBeans”. Enter the configuration as displayed and don’t forget to select Remember as: providing a name. This will allow you to simply start this defined configuration from the Run Maven context menu of the pom.xml file.

Figure 23.5. Maven Goal Setup for a CLM Evaluation in NetBeans

After pressing OK the defined Maven execution will start and display the output including any error messages and the link to the produced report in the Sonatype CLM server in the Output window displayed in Figure 23.6, “CLM for Maven Output in the Output Window in NetBeans”. Policy violations can be configured to result in a build failure.

Figure 23.6. CLM for Maven Output in the Output Window in NetBeans