MAY Maven Eclipse Setup » Historique » Version 10
Anonyme, 16/10/2014 10:33
| 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 | 10 | Anonyme | <pre><code class="xml"> |
| 26 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||
| 27 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||
| 28 | 1 | Anonyme | <modelVersion>4.0.0</modelVersion> |
| 29 | <groupId>XXX</groupId> |
||
| 30 | <artifactId>XXX</artifactId> |
||
| 31 | <version>XXX</version> |
||
| 32 | |||
| 33 | 9 | Anonyme | <!-- We store the version of the component library in a property used below --> |
| 34 | 1 | Anonyme | <properties> |
| 35 | <may-lib-version>3.3.0</may-lib-version> |
||
| 36 | </properties> |
||
| 37 | |||
| 38 | 9 | Anonyme | <!-- We declare the dependency to the component library. |
| 39 | Its dependencies will be also be available. --> |
||
| 40 | 1 | Anonyme | <dependencies> |
| 41 | <dependency> |
||
| 42 | <groupId>fr.irit.smac.lib.may</groupId> |
||
| 43 | <artifactId>common-components</artifactId> |
||
| 44 | <version>${may-lib-version}</version> |
||
| 45 | </dependency> |
||
| 46 | </dependencies> |
||
| 47 | |||
| 48 | 9 | Anonyme | <!-- We declare the repository where the component library can be found --> |
| 49 | 1 | Anonyme | <repositories> |
| 50 | <repository> |
||
| 51 | <id>fr.irit.smac</id> |
||
| 52 | <url>http://www.irit.fr/~Victor.Noel/maven-repos/</url> |
||
| 53 | </repository> |
||
| 54 | </repositories> |
||
| 55 | |||
| 56 | <build> |
||
| 57 | 7 | Anonyme | <!-- This is already present in the default POM --> |
| 58 | <sourceDirectory>src</sourceDirectory> |
||
| 59 | <resources> |
||
| 60 | <resource> |
||
| 61 | <directory>src</directory> |
||
| 62 | <excludes> |
||
| 63 | <exclude>**/*.java</exclude> |
||
| 64 | </excludes> |
||
| 65 | </resource> |
||
| 66 | </resources> |
||
| 67 | <plugins> |
||
| 68 | <!-- This is already present in the default POM --> |
||
| 69 | 5 | Anonyme | <plugin> |
| 70 | 7 | Anonyme | <artifactId>maven-compiler-plugin</artifactId> |
| 71 | <version>3.1</version> |
||
| 72 | <configuration> |
||
| 73 | <source>1.7</source> |
||
| 74 | 1 | Anonyme | <target>1.7</target> |
| 75 | 7 | Anonyme | </configuration> |
| 76 | </plugin> |
||
| 77 | 9 | Anonyme | <!-- This configure maven to take into account the SpeADL code in the speadl-gen directory --> |
| 78 | 7 | Anonyme | <plugin> |
| 79 | 1 | Anonyme | <groupId>org.codehaus.mojo</groupId> |
| 80 | <artifactId>build-helper-maven-plugin</artifactId> |
||
| 81 | <version>1.8</version> |
||
| 82 | <executions> |
||
| 83 | <execution> |
||
| 84 | <id>add-source</id> |
||
| 85 | <goals> |
||
| 86 | <goal>add-source</goal> |
||
| 87 | </goals> |
||
| 88 | <configuration> |
||
| 89 | <sources> |
||
| 90 | <source>speadl-gen</source> |
||
| 91 | </sources> |
||
| 92 | </configuration> |
||
| 93 | </execution> |
||
| 94 | 7 | Anonyme | <!-- The following is only needed so that speadl files are included |
| 95 | in the generated maven artifact --> |
||
| 96 | 1 | Anonyme | <execution> |
| 97 | <id>add-resource</id> |
||
| 98 | <goals> |
||
| 99 | <goal>add-resource</goal> |
||
| 100 | </goals> |
||
| 101 | <configuration> |
||
| 102 | <resources> |
||
| 103 | <resource> |
||
| 104 | <directory>${project.build.sourceDirectory}</directory> |
||
| 105 | <includes> |
||
| 106 | <include>**/*.speadl</include> |
||
| 107 | </includes> |
||
| 108 | </resource> |
||
| 109 | </resources> |
||
| 110 | </configuration> |
||
| 111 | </execution> |
||
| 112 | </executions> |
||
| 113 | </plugin> |
||
| 114 | </plugins> |
||
| 115 | </build> |
||
| 116 | </project> |
||
| 117 | 10 | Anonyme | </code></pre> |
| 118 | 1 | Anonyme | |
| 119 | h2. Possible issues and resolutions |
||
| 120 | |||
| 121 | 5 | Anonyme | h3. Errors on the Project |
| 122 | |||
| 123 | 1 | Anonyme | You may get an error message saying your project configuration is out of date with your new pom.xml. |
| 124 | |||
| 125 | 6 | Anonyme | Update it: right click on your project *Maven* / *Update Project...* and click *Ok*. |
| 126 | 5 | Anonyme | |
| 127 | h3. Errors in the POM File |
||
| 128 | |||
| 129 | You also may get an error saying the following in the POM file: |
||
| 130 | |||
| 131 | Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:build-helper-maven-plugin:1.8:add-source (execution: add-source, phase: generate-sources) |
||
| 132 | |||
| 133 | Click on *Discover new m2e connectors*, it should pre-check *buildhelper*, simply click *Finish* to accept and do the installation. |