While the integration with Eclipse offered by Sonatype CLM for IDE is the most powerful tooling for developers available, user 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.
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.4.0</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 |
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 21.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 drop down as well 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 21.2, “Maven Projects View with the CLM Evalulation 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.
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 21.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.
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 21.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.
If you right-click on the pom.xml
file, you can choose Run Maven and
Goals, to display the dialog displayed in Figure 21.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.
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 21.6, “CLM for Maven Output in the Output Window in NetBeans”. Policy violations can be configured to result in a build failure.
Terms of Service Privacy Policy
Copyright ©
2008-present, Sonatype Inc. All rights reserved. Includes the
third-party code listed here. Sonatype and Sonatype Nexus are trademarks
of Sonatype, Inc. Apache Maven and Maven are trademarks of the Apache
Software Foundation. M2Eclipse is a trademark of the Eclipse Foundation.
All other trademarks are the property of their respective owners.
Sonatype Headquarters - 8161
Maple Lawn Blvd #250, Fulton, MD 20759
Tysons Office - 8251 Greensboro Drive #610, McLean, VA
22102
Australia Office - 5 Martin Place, Level 14, Sydney 2000, NSW, Australia