MAY Maven Standalone Setup » Historique » Version 17
Anonyme, 30/10/2014 10:48
| 1 | 14 | Anonyme | h1. MAY Maven Standalone Setup |
|---|---|---|---|
| 2 | 1 | Anonyme | |
| 3 | 12 | Anonyme | h2. Use Cases |
| 4 | |||
| 5 | 2 | Anonyme | It is possible to use maven to generate code so that Eclipse is not needed anymore. |
| 6 | 10 | Anonyme | For example, one possible workflow is to use another IDE and executing |
| 7 | 11 | Anonyme | |
| 8 | 10 | Anonyme | <pre>mvn generate-sources</pre> |
| 9 | 11 | Anonyme | |
| 10 | 10 | Anonyme | after modifying the speadl file. |
| 11 | |||
| 12 | It is also included in all other maven calls such as: |
||
| 13 | |||
| 14 | <pre>mvn package</pre> |
||
| 15 | 12 | Anonyme | |
| 16 | 13 | Anonyme | All of this is of course compatible with the use of Eclipse (see the last section of this page on issues and their resolution). |
| 17 | |||
| 18 | 16 | Anonyme | h2. Prerequisites |
| 19 | |||
| 20 | Please read [[MAY Maven Eclipse Setup]] to better understand some of the concepts used here. |
||
| 21 | |||
| 22 | 12 | Anonyme | h2. Modifying the POM File |
| 23 | 1 | Anonyme | |
| 24 | 17 | Anonyme | The POM file resulting from using Maven and MAY together (as explained on the page [[MAY Maven Eclipse Setup]]) is as follow (omitting the dependencies for the components): |
| 25 | <pre> |
||
| 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 | <modelVersion>4.0.0</modelVersion> |
||
| 29 | <groupId>XXX</groupId> |
||
| 30 | <artifactId>XXX</artifactId> |
||
| 31 | <version>XXX</version> |
||
| 32 | 1 | Anonyme | |
| 33 | 17 | Anonyme | <build> |
| 34 | <sourceDirectory>src</sourceDirectory> |
||
| 35 | <resources> |
||
| 36 | <resource> |
||
| 37 | <directory>src</directory> |
||
| 38 | <excludes> |
||
| 39 | <exclude>**/*.java</exclude> |
||
| 40 | </excludes> |
||
| 41 | </resource> |
||
| 42 | </resources> |
||
| 43 | <plugins> |
||
| 44 | <plugin> |
||
| 45 | <artifactId>maven-compiler-plugin</artifactId> |
||
| 46 | <version>3.1</version> |
||
| 47 | <configuration> |
||
| 48 | <source>1.7</source> |
||
| 49 | <target>1.7</target> |
||
| 50 | </configuration> |
||
| 51 | </plugin> |
||
| 52 | <!-- This configure maven to take into account the SpeADL code in the speadl-gen directory --> |
||
| 53 | <plugin> |
||
| 54 | <groupId>org.codehaus.mojo</groupId> |
||
| 55 | <artifactId>build-helper-maven-plugin</artifactId> |
||
| 56 | <version>1.8</version> |
||
| 57 | <executions> |
||
| 58 | <execution> |
||
| 59 | <id>add-source</id> |
||
| 60 | <goals> |
||
| 61 | <goal>add-source</goal> |
||
| 62 | </goals> |
||
| 63 | <configuration> |
||
| 64 | <sources> |
||
| 65 | <source>speadl-gen</source> |
||
| 66 | </sources> |
||
| 67 | </configuration> |
||
| 68 | </execution> |
||
| 69 | <!-- The following is only needed so that speadl files are included |
||
| 70 | in the generated maven artifact --> |
||
| 71 | <execution> |
||
| 72 | <id>add-resource</id> |
||
| 73 | <goals> |
||
| 74 | <goal>add-resource</goal> |
||
| 75 | </goals> |
||
| 76 | <configuration> |
||
| 77 | <resources> |
||
| 78 | <resource> |
||
| 79 | <directory>${project.build.sourceDirectory}</directory> |
||
| 80 | <includes> |
||
| 81 | <include>**/*.speadl</include> |
||
| 82 | </includes> |
||
| 83 | </resource> |
||
| 84 | </resources> |
||
| 85 | </configuration> |
||
| 86 | </execution> |
||
| 87 | </executions> |
||
| 88 | </plugin> |
||
| 89 | </plugins> |
||
| 90 | </build> |
||
| 91 | </project> |
||
| 92 | </pre> |
||
| 93 | |||
| 94 | We need to tell Maven that we want to generate the SpeADL code from it, we must add the Xtext plugin taking care of that: |
||
| 95 | 2 | Anonyme | <pre> |
| 96 | 8 | Anonyme | <project ...> |
| 97 | 17 | Anonyme | ... |
| 98 | 2 | Anonyme | <properties> |
| 99 | <xtext-version>2.7.2</xtext-version> |
||
| 100 | 17 | Anonyme | <may-version>3.4.1</may-version> |
| 101 | 2 | Anonyme | </properties> |
| 102 | 17 | Anonyme | ... |
| 103 | 2 | Anonyme | <build> |
| 104 | <plugins> |
||
| 105 | 17 | Anonyme | ... |
| 106 | 2 | Anonyme | <plugin> |
| 107 | <groupId>org.apache.maven.plugins</groupId> |
||
| 108 | <artifactId>maven-clean-plugin</artifactId> |
||
| 109 | 17 | Anonyme | <version>2.6</version> |
| 110 | 2 | Anonyme | <executions> |
| 111 | 1 | Anonyme | <execution> |
| 112 | 17 | Anonyme | <!-- hack in order for the file not to be removed on clean but only |
| 113 | prior to code generation from xtext-maven-plugin --> |
||
| 114 | 2 | Anonyme | <phase>generate-sources</phase> |
| 115 | <goals> |
||
| 116 | <goal>clean</goal> |
||
| 117 | </goals> |
||
| 118 | <configuration> |
||
| 119 | 7 | Anonyme | <excludeDefaultDirectories>true</excludeDefaultDirectories> |
| 120 | 2 | Anonyme | <filesets> |
| 121 | <fileset> |
||
| 122 | <directory>speadl-gen</directory> |
||
| 123 | </fileset> |
||
| 124 | </filesets> |
||
| 125 | </configuration> |
||
| 126 | </execution> |
||
| 127 | </executions> |
||
| 128 | </plugin> |
||
| 129 | <plugin> |
||
| 130 | <groupId>org.eclipse.xtext</groupId> |
||
| 131 | <artifactId>xtext-maven-plugin</artifactId> |
||
| 132 | <version>${xtext-version}</version> |
||
| 133 | <executions> |
||
| 134 | <execution> |
||
| 135 | <goals> |
||
| 136 | <goal>generate</goal> |
||
| 137 | </goals> |
||
| 138 | </execution> |
||
| 139 | </executions> |
||
| 140 | <configuration> |
||
| 141 | <languages> |
||
| 142 | <language> |
||
| 143 | <setup>fr.irit.smac.may.speadl.SpeADLStandaloneSetup</setup> |
||
| 144 | <outputConfigurations> |
||
| 145 | <outputConfiguration> |
||
| 146 | <outputDirectory>speadl-gen</outputDirectory> |
||
| 147 | </outputConfiguration> |
||
| 148 | </outputConfigurations> |
||
| 149 | </language> |
||
| 150 | 1 | Anonyme | </languages> |
| 151 | </configuration> |
||
| 152 | <dependencies> |
||
| 153 | <dependency> |
||
| 154 | <groupId>fr.irit.smac.may</groupId> |
||
| 155 | 3 | Anonyme | <artifactId>fr.irit.smac.may.speadl</artifactId> |
| 156 | 5 | Anonyme | <version>${may-version}</version> |
| 157 | 3 | Anonyme | </dependency> |
| 158 | 6 | Anonyme | </dependencies> |
| 159 | </plugin> |
||
| 160 | 17 | Anonyme | ... |
| 161 | 3 | Anonyme | </plugins> |
| 162 | 5 | Anonyme | </project> |
| 163 | 1 | Anonyme | |
| 164 | 5 | Anonyme | h2. Possible Issues and Resolutions |
| 165 | 1 | Anonyme | |
| 166 | 5 | Anonyme | h3. Errors in the POM file |
| 167 | 1 | Anonyme | |
| 168 | 5 | Anonyme | If the POM file contains the following errors in Eclipse: |
| 169 | |||
| 170 | Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-clean-plugin:2.5:clean (execution: default, phase: generate-sources) |
||
| 171 | |||
| 172 | and |
||
| 173 | |||
| 174 | Plugin execution not covered by lifecycle configuration: org.eclipse.xtext:xtext-maven-plugin:2.6.2:generate (execution: default, phase: generate-sources) |
||
| 175 | |||
| 176 | When hovering on the error, choose the following quickfix: |
||
| 177 | 1 | Anonyme | |
| 178 | Permanently mark goal clean in pom.xml as ignored as ignored in Eclipse build. |
||
| 179 | |||
| 180 | and |
||
| 181 | |||
| 182 | Permanently mark goal generate in pom.xml as ignored as ignored in Eclipse build. |
||
| 183 | |||
| 184 | This will prevent the Maven plugin in Eclipse to generate the source code while Eclipse also does it internally. |