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