MAY Maven Eclipse Setup » Historique » Version 9
Anonyme, 16/10/2014 10:32
| 1 | 8 | Anonyme | h1. MAY Maven Eclipse Setup |
|---|---|---|---|
| 2 | 1 | Anonyme | |
| 3 | 3 | Anonyme | h2. Install the Maven Eclipse Plugin |
| 4 | 1 | Anonyme | |
| 5 | 3 | Anonyme | The Maven Eclipse Plugin, also named M2E, is available as part of the normal Eclipse distribution but must be explicitly installed. |
| 6 | |||
| 7 | Go to *Help* / *Install New Software...* and select the *All available site* in the drop-down list (it may take some time to load). |
||
| 8 | |||
| 9 | Expand the *Collaboration* category and select *m2e - Maven Integration for Eclipse*. |
||
| 10 | |||
| 11 | 4 | Anonyme | Click *Next*, finish the installation procedure and restart Eclipse when asked to. |
| 12 | 3 | Anonyme | |
| 13 | h2. Convert an Existing Project to Maven |
||
| 14 | |||
| 15 | 1 | Anonyme | The first step is to convert your project into a Maven project. |
| 16 | To do this, right click on your project and on *Configure* / *Convert to Maven Project*. |
||
| 17 | |||
| 18 | 5 | Anonyme | You will be asked to create a new POM file. Just click *Finish* after editing the package, name and version if desired. |
| 19 | 3 | Anonyme | |
| 20 | Alternatively, you can directly create a Maven project, this is out of scope of this document. |
||
| 21 | |||
| 22 | h2. Edit the POM File |
||
| 23 | 1 | Anonyme | |
| 24 | 9 | Anonyme | Next, open the POM file in the project and edit it as follows, explanations are included as comments: |
| 25 | 1 | Anonyme | <pre> |
| 26 | 7 | Anonyme | <project ...> |
| 27 | 1 | Anonyme | <modelVersion>4.0.0</modelVersion> |
| 28 | <groupId>XXX</groupId> |
||
| 29 | <artifactId>XXX</artifactId> |
||
| 30 | <version>XXX</version> |
||
| 31 | |||
| 32 | 9 | Anonyme | <!-- We store the version of the component library in a property used below --> |
| 33 | 1 | Anonyme | <properties> |
| 34 | <may-lib-version>3.3.0</may-lib-version> |
||
| 35 | </properties> |
||
| 36 | |||
| 37 | 9 | Anonyme | <!-- We declare the dependency to the component library. |
| 38 | Its dependencies will be also be available. --> |
||
| 39 | 1 | Anonyme | <dependencies> |
| 40 | <dependency> |
||
| 41 | <groupId>fr.irit.smac.lib.may</groupId> |
||
| 42 | <artifactId>common-components</artifactId> |
||
| 43 | <version>${may-lib-version}</version> |
||
| 44 | </dependency> |
||
| 45 | </dependencies> |
||
| 46 | |||
| 47 | 9 | Anonyme | <!-- We declare the repository where the component library can be found --> |
| 48 | 1 | Anonyme | <repositories> |
| 49 | <repository> |
||
| 50 | <id>fr.irit.smac</id> |
||
| 51 | <url>http://www.irit.fr/~Victor.Noel/maven-repos/</url> |
||
| 52 | </repository> |
||
| 53 | </repositories> |
||
| 54 | |||
| 55 | <build> |
||
| 56 | 7 | Anonyme | <!-- This is already present in the default POM --> |
| 57 | <sourceDirectory>src</sourceDirectory> |
||
| 58 | <resources> |
||
| 59 | <resource> |
||
| 60 | <directory>src</directory> |
||
| 61 | <excludes> |
||
| 62 | <exclude>**/*.java</exclude> |
||
| 63 | </excludes> |
||
| 64 | </resource> |
||
| 65 | </resources> |
||
| 66 | <plugins> |
||
| 67 | <!-- This is already present in the default POM --> |
||
| 68 | 5 | Anonyme | <plugin> |
| 69 | 7 | Anonyme | <artifactId>maven-compiler-plugin</artifactId> |
| 70 | <version>3.1</version> |
||
| 71 | <configuration> |
||
| 72 | <source>1.7</source> |
||
| 73 | 1 | Anonyme | <target>1.7</target> |
| 74 | 7 | Anonyme | </configuration> |
| 75 | </plugin> |
||
| 76 | 9 | Anonyme | <!-- This configure maven to take into account the SpeADL code in the speadl-gen directory --> |
| 77 | 7 | Anonyme | <plugin> |
| 78 | 1 | Anonyme | <groupId>org.codehaus.mojo</groupId> |
| 79 | <artifactId>build-helper-maven-plugin</artifactId> |
||
| 80 | <version>1.8</version> |
||
| 81 | <executions> |
||
| 82 | <execution> |
||
| 83 | <id>add-source</id> |
||
| 84 | <goals> |
||
| 85 | <goal>add-source</goal> |
||
| 86 | </goals> |
||
| 87 | <configuration> |
||
| 88 | <sources> |
||
| 89 | <source>speadl-gen</source> |
||
| 90 | </sources> |
||
| 91 | </configuration> |
||
| 92 | </execution> |
||
| 93 | 7 | Anonyme | <!-- The following is only needed so that speadl files are included |
| 94 | in the generated maven artifact --> |
||
| 95 | 1 | Anonyme | <execution> |
| 96 | <id>add-resource</id> |
||
| 97 | <goals> |
||
| 98 | <goal>add-resource</goal> |
||
| 99 | </goals> |
||
| 100 | <configuration> |
||
| 101 | <resources> |
||
| 102 | <resource> |
||
| 103 | <directory>${project.build.sourceDirectory}</directory> |
||
| 104 | <includes> |
||
| 105 | <include>**/*.speadl</include> |
||
| 106 | </includes> |
||
| 107 | </resource> |
||
| 108 | </resources> |
||
| 109 | </configuration> |
||
| 110 | </execution> |
||
| 111 | </executions> |
||
| 112 | </plugin> |
||
| 113 | </plugins> |
||
| 114 | </build> |
||
| 115 | </project> |
||
| 116 | </pre> |
||
| 117 | |||
| 118 | h2. Possible issues and resolutions |
||
| 119 | |||
| 120 | 5 | Anonyme | h3. Errors on the Project |
| 121 | |||
| 122 | 1 | Anonyme | You may get an error message saying your project configuration is out of date with your new pom.xml. |
| 123 | |||
| 124 | 6 | Anonyme | Update it: right click on your project *Maven* / *Update Project...* and click *Ok*. |
| 125 | 5 | Anonyme | |
| 126 | h3. Errors in the POM File |
||
| 127 | |||
| 128 | You also may get an error saying the following in the POM file: |
||
| 129 | |||
| 130 | Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:build-helper-maven-plugin:1.8:add-source (execution: add-source, phase: generate-sources) |
||
| 131 | |||
| 132 | Click on *Discover new m2e connectors*, it should pre-check *buildhelper*, simply click *Finish* to accept and do the installation. |