MAY Project Setup » Historique » Version 48
Anonyme, 13/12/2013 17:29
| 1 | 1 | Anonyme | *Draft version...* |
|---|---|---|---|
| 2 | |||
| 3 | h1. SpeADL MAY Project SetUp |
||
| 4 | |||
| 5 | 37 | Anonyme | _Estimated time: 3 minutes_ |
| 6 | |||
| 7 | 18 | Anonyme | h2. A classic JAVA project to start with... |
| 8 | |||
| 9 | 47 | Anonyme | First, create a java project, choose a name, and click finish. |
| 10 | 1 | Anonyme | |
| 11 | 40 | Anonyme | Then, create a new file with the speadl extension within the src folder: |
| 12 | |||
| 13 | !https://wwwsecu.irit.fr/redmine/attachments/download/434/new_file_speadl1.png! |
||
| 14 | !https://wwwsecu.irit.fr/redmine/attachments/download/435/new_file_speadl2.png! |
||
| 15 | 5 | Anonyme | |
| 16 | 1 | Anonyme | h2. Using Maven |
| 17 | |||
| 18 | The next step is to convert your project into a Maven project. To do this, right click on your project / Configure / Convert to Maven Project. |
||
| 19 | You will be asked to create a new POM file. Just click finish and edit it manually like this: |
||
| 20 | |||
| 21 | <pre> |
||
| 22 | 47 | Anonyme | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 23 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||
| 24 | <modelVersion>4.0.0</modelVersion> |
||
| 25 | <groupId>XXX</groupId> |
||
| 26 | <artifactId>XXX</artifactId> |
||
| 27 | <version>0.0.1-SNAPSHOT</version> |
||
| 28 | |||
| 29 | 48 | Anonyme | <properties> |
| 30 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||
| 31 | </properties> |
||
| 32 | |||
| 33 | |||
| 34 | 47 | Anonyme | <build> |
| 35 | <sourceDirectory>src</sourceDirectory> |
||
| 36 | <plugins> |
||
| 37 | <plugin> |
||
| 38 | <artifactId>maven-compiler-plugin</artifactId> |
||
| 39 | <version>3.1</version> |
||
| 40 | <configuration> |
||
| 41 | <source>1.7</source> |
||
| 42 | <target>1.7</target> |
||
| 43 | </configuration> |
||
| 44 | </plugin> |
||
| 45 | <plugin> |
||
| 46 | <groupId>org.codehaus.mojo</groupId> |
||
| 47 | <artifactId>build-helper-maven-plugin</artifactId> |
||
| 48 | <version>1.8</version> |
||
| 49 | <executions> |
||
| 50 | <execution> |
||
| 51 | <id>add-source</id> |
||
| 52 | <phase>generate-sources</phase> |
||
| 53 | <goals> |
||
| 54 | <goal>add-source</goal> |
||
| 55 | </goals> |
||
| 56 | <configuration> |
||
| 57 | <sources> |
||
| 58 | <source>speadl-gen</source> |
||
| 59 | </sources> |
||
| 60 | </configuration> |
||
| 61 | </execution> |
||
| 62 | <!-- The following is only needed so that speadl files are included in the generated maven artifact --> |
||
| 63 | <execution> |
||
| 64 | <id>add-resource</id> |
||
| 65 | <goals> |
||
| 66 | <goal>add-resource</goal> |
||
| 67 | </goals> |
||
| 68 | <configuration> |
||
| 69 | <resources> |
||
| 70 | <resource> |
||
| 71 | <directory>${project.build.sourceDirectory}</directory> |
||
| 72 | <includes> |
||
| 73 | <include>**/*.speadl</include> |
||
| 74 | </includes> |
||
| 75 | </resource> |
||
| 76 | </resources> |
||
| 77 | </configuration> |
||
| 78 | </execution> |
||
| 79 | </executions> |
||
| 80 | </plugin> |
||
| 81 | </plugins> |
||
| 82 | </build> |
||
| 83 | |||
| 84 | <dependencies> |
||
| 85 | <dependency> |
||
| 86 | <groupId>fr.irit.smac.lib.may</groupId> |
||
| 87 | <artifactId>common-components</artifactId> |
||
| 88 | <version>3.2.1</version> |
||
| 89 | </dependency> |
||
| 90 | </dependencies> |
||
| 91 | |||
| 92 | <repositories> |
||
| 93 | <repository> |
||
| 94 | <id>fr.irit.smac</id> |
||
| 95 | <url>http://www.irit.fr/~Victor.Noel/maven-repos/</url> |
||
| 96 | </repository> |
||
| 97 | </repositories> |
||
| 98 | 29 | Anonyme | </project> |
| 99 | 6 | Anonyme | </pre> |
| 100 | |||
| 101 | 48 | Anonyme | h1. Using Maven for Code Generation |
| 102 | |||
| 103 | It is possible to use maven to generate code so that Eclipse is not needed anymore. |
||
| 104 | One possible workflow for doing that is to use another IDE and executing <pre>mvn generate-sources</pre> after modifying the speadl file. |
||
| 105 | |||
| 106 | In order to do that, use the following POM file (which add some things to the previous one): |
||
| 107 | |||
| 108 | <pre> |
||
| 109 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||
| 110 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||
| 111 | <modelVersion>4.0.0</modelVersion> |
||
| 112 | <groupId>XXX</groupId> |
||
| 113 | <artifactId>XXX</artifactId> |
||
| 114 | <version>0.0.1-SNAPSHOT</version> |
||
| 115 | |||
| 116 | <properties> |
||
| 117 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||
| 118 | </properties> |
||
| 119 | |||
| 120 | <build> |
||
| 121 | <plugins> |
||
| 122 | <plugin> |
||
| 123 | <groupId>org.codehaus.mojo</groupId> |
||
| 124 | <artifactId>build-helper-maven-plugin</artifactId> |
||
| 125 | <version>1.8</version> |
||
| 126 | <executions> |
||
| 127 | <execution> |
||
| 128 | <id>add-source</id> |
||
| 129 | <goals> |
||
| 130 | <goal>add-source</goal> |
||
| 131 | </goals> |
||
| 132 | <configuration> |
||
| 133 | <sources> |
||
| 134 | <source>speadl-gen</source> |
||
| 135 | </sources> |
||
| 136 | </configuration> |
||
| 137 | </execution> |
||
| 138 | <!-- The following is only needed so that speadl files are included in the generated maven artifact --> |
||
| 139 | <execution> |
||
| 140 | <id>add-resource</id> |
||
| 141 | <goals> |
||
| 142 | <goal>add-resource</goal> |
||
| 143 | </goals> |
||
| 144 | <configuration> |
||
| 145 | <resources> |
||
| 146 | <resource> |
||
| 147 | <directory>src/main/java</directory> |
||
| 148 | <includes> |
||
| 149 | <include>**/*.speadl</include> |
||
| 150 | </includes> |
||
| 151 | </resource> |
||
| 152 | </resources> |
||
| 153 | </configuration> |
||
| 154 | </execution> |
||
| 155 | </executions> |
||
| 156 | </plugin> |
||
| 157 | <plugin> |
||
| 158 | <groupId>org.apache.maven.plugins</groupId> |
||
| 159 | <artifactId>maven-clean-plugin</artifactId> |
||
| 160 | <version>2.5</version> |
||
| 161 | <executions> |
||
| 162 | <execution> |
||
| 163 | <phase>clean</phase> |
||
| 164 | <goals> |
||
| 165 | <goal>clean</goal> |
||
| 166 | </goals> |
||
| 167 | <configuration> |
||
| 168 | <filesets> |
||
| 169 | <fileset> |
||
| 170 | <directory>speadl-gen</directory> |
||
| 171 | </fileset> |
||
| 172 | </filesets> |
||
| 173 | </configuration> |
||
| 174 | </execution> |
||
| 175 | </executions> |
||
| 176 | </plugin> |
||
| 177 | <plugin> |
||
| 178 | <groupId>org.eclipse.xtext</groupId> |
||
| 179 | <artifactId>xtext-maven-plugin</artifactId> |
||
| 180 | <version>2.5.0</version> |
||
| 181 | <executions> |
||
| 182 | <execution> |
||
| 183 | <goals> |
||
| 184 | <goal>generate</goal> |
||
| 185 | </goals> |
||
| 186 | </execution> |
||
| 187 | </executions> |
||
| 188 | <configuration> |
||
| 189 | <languages> |
||
| 190 | <language> |
||
| 191 | <setup>fr.irit.smac.may.speadl.SpeADLStandaloneSetup</setup> |
||
| 192 | <outputConfigurations> |
||
| 193 | <outputConfiguration> |
||
| 194 | <outputDirectory>speadl-gen</outputDirectory> |
||
| 195 | </outputConfiguration> |
||
| 196 | </outputConfigurations> |
||
| 197 | </language> |
||
| 198 | </languages> |
||
| 199 | </configuration> |
||
| 200 | <dependencies> |
||
| 201 | <dependency> |
||
| 202 | <groupId>fr.irit.smac.may</groupId> |
||
| 203 | <artifactId>fr.irit.smac.may.speadl</artifactId> |
||
| 204 | <version>3.2.1</version> |
||
| 205 | </dependency> |
||
| 206 | </dependencies> |
||
| 207 | </plugin> |
||
| 208 | </plugins> |
||
| 209 | </build> |
||
| 210 | </project> |
||
| 211 | </pre> |
||
| 212 | |||
| 213 | 47 | Anonyme | h1. Possible issues and resolutions |
| 214 | 1 | Anonyme | |
| 215 | 48 | Anonyme | h2. Maven Eclipse Error |
| 216 | |||
| 217 | If Maven in Eclipse gives the following error: |
||
| 218 | |||
| 219 | Plugin execution not covered by lifecycle configuration: org.eclipse.xtext:xtext-maven-plugin:2.5.0:generate (execution: default, phase: generate-sources) |
||
| 220 | |||
| 221 | In the Overview view of the pom.xml file, click on the error and select the Quick Fix named: |
||
| 222 | |||
| 223 | Permanently mark goal generate in pom.xml as ignored. |
||
| 224 | |||
| 225 | This will prevent the maven plugin in Eclipse to generate the source code while Eclipse also does it internally. |
||
| 226 | 8 | Anonyme | |
| 227 | 10 | Anonyme | h2. Project configuration is not up-to-date |
| 228 | |||
| 229 | 5 | Anonyme | You may get an error message saying your project configuration is out of date with your new pom.xml |
| 230 | 36 | Anonyme | Update it : right click on your project / Maven / Update Project Configuration... and click Ok. |
| 231 | 7 | Anonyme | |
| 232 | 1 | Anonyme | !https://wwwsecu.irit.fr/redmine/attachments/download/337/update_project_conf.jpg! |