Red Hat JBoss Developer Studio 7.0 Maven Tools Reference Guide Provides information about the use of Maven within the JBoss Developer Studio. Isaac Rooskov Red Hat JBoss Developer Studio 7.0 Maven Tools Reference Guide Provides information about the use of Maven within the JBoss Developer Studio. Isaac Ro o sko v Legal Notice Copyright © 2012 Red Hat. T his document is licensed by Red Hat under the Creative Commons Attribution-ShareAlike 3.0 Unported License. If you distribute this document, or a modified version of it, you must provide attribution to Red Hat, Inc. and provide a link to the original. If the document is modified, all Red Hat trademarks must be removed. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law. Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries. Linux ® is the registered trademark of Linus T orvalds in the United States and other countries. Java ® is a registered trademark of Oracle and/or its affiliates. XFS ® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries. MySQL ® is a registered trademark of MySQL AB in the United States, the European Union and other countries. Node.js ® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project. T he OpenStack ® Word Mark and OpenStack Logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community. All other trademarks are the property of their respective owners. Abstract T he Maven T ools Reference Guide explains how to utilize Maven from within the JBoss Developer Studio. Table of Contents Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3. . . . . . . . . . Preface . . . . . . . . . 1. Chapter . . .Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . . . . . . . . . . . 2. Chapter . . .Creating .........a . . Maven . . . . . . . .Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5. . . . . . . . . . . . . . . . . . . 3. Chapter . . .Creating . . . . . . . . . a. . Maven . . . . . . . Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 ............ .........4 Chapter . ...Adding . . . . . . . .Maven . . . . . . .support . . . . . . . . .to . . an . . . existing . . . . . . . . . project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 ............ .Getting . . . . . . . .Help . . . . .and . . . . Giving . . . . . . . .Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 ............ A.1. Do You Need Help? 26 A.2. Give us Feedback 26 . . . . . . . . . .History Revision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 ............ 1 Red Hat JBoss D eveloper Studio 7.0 Maven Tools Reference Guide 2 Preface Preface T his manual uses several conventions to highlight certain words and phrases and draw attention to specific pieces of information. T o get more information on these conventions please refer to the Docum ent Conventions manual, which can be found on the Red Hat Documentation website under the JBoss Developer Studio section. 3 Red Hat JBoss D eveloper Studio 7.0 Maven Tools Reference Guide Chapter 1. Introduction In the context of application development, Maven allows you to extend your applicaitons by referencing and utilizing resources from local and remote repositories. Covered in this reference guide is how to create Maven projects and modules, and how to add Maven functionality to an existing project or application. T his guide does not cover how to setup a Maven repository. For information on how to setup a Maven repository consult the documentation associated with your application server or framework kit. 4 Chapter 2. Creating a Maven Project Chapter 2. Creating a Maven Project T o create a new Maven Project, from your workspace navigate to File → New → Other and from the wizard selection screen select Maven → Maven Project. Figure 2.1. Selecting the Maven Project wizard T he first screen of the wizard will ask you if you wish to create a simple project (selecting this will skip the ability to select an archetype), to select a location for the project and if any projects should be added to the working set. 5 Red Hat JBoss D eveloper Studio 7.0 Maven Tools Reference Guide Figure 2.2. Maven project location and basic settings You can also select Advanced options concerning existing workspace projects and the naming convention to use. 6 Chapter 2. Creating a Maven Project Figure 2.3. Maven project location and advanced settings T he following screen is the Archetype selection screen, and will only appear when you have not selected to create a sim ple project on the previous screen. Select an archetype based on the purpose of the project you are creating. 7 Red Hat JBoss D eveloper Studio 7.0 Maven Tools Reference Guide Figure 2.4 . Archetype selection T he final screen of the wizard is where you will set the Group Id, Artifact Id and project Version. T he Package name will be created based on the Group Id and Artifact Id values. You can also add specific properties associated with the chosen archetype, to the project. 8 Chapter 2. Creating a Maven Project Figure 2.5. Final project naming Clicking Finish will bring you back to the workbench and your Maven project will appear in the Project Explorer. 9 Red Hat JBoss D eveloper Studio 7.0 Maven Tools Reference Guide Figure 2.6. Project in the Project Explorer 10 Chapter 3. Creating a Maven Module Chapter 3. Creating a Maven Module A Maven module is a sub-project. T o create a Maven module you will need to already have a Maven project available. T he parent project must have its Packaging option pre-configured to pom, for a module to be created and associated with it. T o ensure your parent project has this option set correctly before proceeding, double-click on the pom .xm l file of your parent project in the Project Explorer. In the Overview settings page that is now displayed in your workbench, confirm that the option Packaging is set to pom. If it is not, select pom from the list menu and save the changes to your pom .xm l file. Figure 3.1. Parent project pom.xml file settings From your workspace navigate to File → New → Other and from the wizard selection screen select Maven → Maven Module. 11 Red Hat JBoss D eveloper Studio 7.0 Maven Tools Reference Guide Figure 3.2. Selecting the Maven Module wizard T ype a name for the module in the Module Nam e field. 12 Chapter 3. Creating a Maven Module Figure 3.3. Naming the module Click the Browse button beside the Parent Project field. T his will launch a project selection box. Select the project to be used as the parent project of the module you are creating, and click OK. 13 Red Hat JBoss D eveloper Studio 7.0 Maven Tools Reference Guide Figure 3.4 . Selecting the parent project You will be returned to the Select a parent project screen and the Parent Project field will contain the name of the project you selected. 14 Chapter 3. Creating a Maven Module Figure 3.5. Parent Project field populated with project name Click the Next button. Select an archetype available in the list displayed. For the purposes of this example the mavenarchetype-quickstart is selected. 15 Red Hat JBoss D eveloper Studio 7.0 Maven Tools Reference Guide Figure 3.6. Archetype selection screen Click the Next button. Specify archetype parameters Group Id and Version. Ensure that the values you specify for these fields are unique from those set in the parent project. In this example, the Group Id and Version settings of the parent project used are set to group_id and 0.0.1-SNAPSHOT respectively. For the module, Group Id and Version settings are being specified as sub_group_id and 0.1.1-SNAPSHOT respectively, to avoid conflict. 16 Chapter 3. Creating a Maven Module Figure 3.7. Archetype parameter settings Click the Finish button. T he module will now be created and appear in your Project Explorer. 17 Red Hat JBoss D eveloper Studio 7.0 Maven Tools Reference Guide Figure 3.8. Created module in the Project Explorer You can view and change settings associated with the module by selecting the module's pom .xm l file from the Project Explorer and double-clicking on it. T his will launch an Overview screen containing the module settings. 18 Chapter 3. Creating a Maven Module Figure 3.9. Module Overview screen 19 Red Hat JBoss D eveloper Studio 7.0 Maven Tools Reference Guide Chapter 4. Adding Maven support to an existing project Select the project that Maven support will be added to from the Project Explorer. Figure 4 .1. Selecting Maven project conversion Right-click on the project to bring up the context menu and click on Properties. From the Properties screen click on Project Facets. 20 Chapter 4. Adding Maven support to an existing project Figure 4 .2. Project Facets screen Select JBoss Maven Integration from the facets list. You will notice that a Further configuration required button appears at the bottom of the screen. Figure 4 .3. Maven Integration facet selected 21 Red Hat JBoss D eveloper Studio 7.0 Maven Tools Reference Guide Click on the Further configuration required button and you can either modify or accept the default values for all fields. Click the OK button to return to the facets screen. Figure 4 .4 . Maven Integration facet settings T he Further configuration required button has now changed to Further configuration available. Click the Apply button and then the OK button to complete the addition of Maven support to your project. 22 Chapter 4. Adding Maven support to an existing project Figure 4 .5. Maven Integration facet configured Maven support has been added to the project, and a new pom .xm l file appears in the list of files for the project. T his can be viewed in the Project Explorer. 23 Red Hat JBoss D eveloper Studio 7.0 Maven Tools Reference Guide Figure 4 .6. New pom.xml file Double-click on the pom .xm l file to view the settings associated with it. T he settings here were set in the Further configuration required step, and can be edited from this Overview screen. It is recommended that you change the Packaging option to pom to avoid any issues in expansion of the project with Maven modules in the future. 24 Chapter 4. Adding Maven support to an existing project Figure 4 .7. Overview screen for pom.xml 25 Red Hat JBoss D eveloper Studio 7.0 Maven Tools Reference Guide Getting Help and Giving Feedback A.1. Do You Need Help? If you experience difficulty with a procedure described in this documentation, visit the Red Hat Customer Portal at http://access.redhat.com. T hrough the customer portal, you can: search or browse through a knowledgebase of technical support articles about Red Hat products. submit a support case to Red Hat Global Support Services (GSS). access other product documentation. Red Hat also hosts a large number of electronic mailing lists for discussion of Red Hat software and technology. You can find a list of publicly available mailing lists at https://www.redhat.com/mailman/listinfo. Click on the name of any mailing list to subscribe to that list or to access the list archives. A.2. Give us Feedback If you find a typographical error, or know how this guide can be improved, we would love to hear from you. Submit a report in Bugzilla against the product JBoss Developer Studio and the component Maven T ools Reference Guide. T he following link will take you to a pre-filled bug report for this product: http://bugzilla.redhat.com/. Fill out the following template in Bugzilla's Description field. Be as specific as possible when describing the issue; this will help ensure that we can fix it quickly. Document URL: Section Number and Name: Describe the issue: Suggestions for improvement: Additional information: Be sure to give us your name so that you can receive full credit for reporting the issue. 26 Revision History Revision History Revision 7.0.0-1.4 00 Rebuild with publican 4.0.0 2013-10-31 Rüdiger Landmann Revision 7.0.0-1 Released for 7.0.0 Fri Sep 13 2013 Michelle Murray 27
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
advertisement