Projet

Général

Profil

MAY Project Setup » Historique » Version 55

Anonyme, 27/05/2014 18:57

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 54 Anonyme
		<may-lib-version>3.2.4</may-version>
32 48 Anonyme
	</properties>
33 1 Anonyme
34 54 Anonyme
	<dependencies>
35
		<dependency>
36
			<groupId>fr.irit.smac.lib.may</groupId>
37
			<artifactId>common-components</artifactId>
38
			<version>${may-lib-version}</version>
39
		</dependency>
40
	</dependencies>
41
42 47 Anonyme
	<build>
43
		<sourceDirectory>src</sourceDirectory>
44
		<plugins>
45
			<plugin>
46
				<artifactId>maven-compiler-plugin</artifactId>
47
				<version>3.1</version>
48
				<configuration>
49
					<source>1.7</source>
50
					<target>1.7</target>
51
				</configuration>
52
			</plugin>
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 in the generated maven artifact -->
70
					<execution>
71
						<id>add-resource</id>
72
						<goals>
73
							<goal>add-resource</goal>
74
						</goals>
75
						<configuration>
76
							<resources>
77
								<resource>
78
									<directory>${project.build.sourceDirectory}</directory>
79
									<includes>
80
										<include>**/*.speadl</include>
81
									</includes>
82
								</resource>
83
							</resources>
84
						</configuration>
85
					</execution>
86
				</executions>
87 53 Anonyme
			</plugin>
88 47 Anonyme
		</plugins>
89
	</build>
90
91
	<repositories>
92
		<repository>
93
			<id>fr.irit.smac</id>
94
			<url>http://www.irit.fr/~Victor.Noel/maven-repos/</url>
95
		</repository>
96
	</repositories>
97 29 Anonyme
</project>
98 6 Anonyme
</pre>
99
100 48 Anonyme
h1. Using Maven for Code Generation
101
102
It is possible to use maven to generate code so that Eclipse is not needed anymore.
103
One possible workflow for doing that is to use another IDE and executing <pre>mvn generate-sources</pre> after modifying the speadl file.
104
105
In order to do that, use the following POM file (which add some things to the previous one):
106
107
<pre>
108
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
109
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
110
	<modelVersion>4.0.0</modelVersion>
111
	<groupId>XXX</groupId>
112
	<artifactId>XXX</artifactId>
113
	<version>0.0.1-SNAPSHOT</version>
114
115
	<properties>
116
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
117 52 Anonyme
		<xtext-version>2.5.4</xtext-version>
118
		<may-version>3.2.4</may-version>
119 55 Anonyme
		<may-lib-version>3.2.4</may-lib-version>
120 48 Anonyme
	</properties>
121
122 52 Anonyme
	<dependencies>
123
		<dependency>
124
			<groupId>fr.irit.smac.lib.may</groupId>
125 1 Anonyme
			<artifactId>common-components</artifactId>
126 55 Anonyme
			<version>${may-lib-version}</version>
127 52 Anonyme
		</dependency>
128
	</dependencies>
129
130 48 Anonyme
	<build>
131
		<plugins>
132
			<plugin>
133
				<groupId>org.codehaus.mojo</groupId>
134
				<artifactId>build-helper-maven-plugin</artifactId>
135
				<version>1.8</version>
136
				<executions>
137
					<execution>
138
						<id>add-source</id>
139
						<goals>
140
							<goal>add-source</goal>
141
						</goals>
142
						<configuration>
143
							<sources>
144
								<source>speadl-gen</source>
145
							</sources>
146
						</configuration>
147
					</execution>
148
					<!-- The following is only needed so that speadl files are included in the generated maven artifact -->
149
					<execution>
150
						<id>add-resource</id>
151
						<goals>
152
							<goal>add-resource</goal>
153
						</goals>
154
						<configuration>
155
							<resources>
156
								<resource>
157
									<directory>src/main/java</directory>
158
									<includes>
159
										<include>**/*.speadl</include>
160
									</includes>
161
								</resource>
162
							</resources>
163
						</configuration>
164
					</execution>
165
				</executions>
166
			</plugin>
167
			<plugin>
168
				<groupId>org.apache.maven.plugins</groupId>
169
				<artifactId>maven-clean-plugin</artifactId>
170
				<version>2.5</version>
171
				<executions>
172 1 Anonyme
					<execution>
173 52 Anonyme
						<!-- hack in order for the file not to be removed on clean but only 
174
								prior to code generation from xtext-maven-plugin -->
175
						<phase>generate-sources</phase>
176 48 Anonyme
						<goals>
177
							<goal>clean</goal>
178
						</goals>
179 1 Anonyme
						<configuration>
180 52 Anonyme
							<excludeDefaultDirectories>true</excludeDefaultDirectories>
181 48 Anonyme
							<filesets>
182
								<fileset>
183
									<directory>speadl-gen</directory>
184
								</fileset>
185
							</filesets>
186
						</configuration>
187
					</execution>
188
				</executions>
189
			</plugin>
190
			<plugin>
191 1 Anonyme
				<groupId>org.eclipse.xtext</groupId>
192 48 Anonyme
				<artifactId>xtext-maven-plugin</artifactId>
193 52 Anonyme
				<version>${xtext-version}</version>
194 48 Anonyme
				<executions>
195
					<execution>
196
						<goals>
197
							<goal>generate</goal>
198
						</goals>
199
					</execution>
200
				</executions>
201
				<configuration>
202
					<languages>
203
						<language>
204
							<setup>fr.irit.smac.may.speadl.SpeADLStandaloneSetup</setup>
205
							<outputConfigurations>
206
								<outputConfiguration>
207
									<outputDirectory>speadl-gen</outputDirectory>
208
								</outputConfiguration>
209
							</outputConfigurations>
210
						</language>
211
					</languages>
212
				</configuration>
213
				<dependencies>
214 1 Anonyme
					<dependency>
215 48 Anonyme
						<groupId>fr.irit.smac.may</groupId>
216
						<artifactId>fr.irit.smac.may.speadl</artifactId>
217 52 Anonyme
						<version>${may-version}</version>
218 48 Anonyme
					</dependency>
219
				</dependencies>
220
			</plugin>
221
		</plugins>
222
	</build>
223
</project>
224
</pre>
225
226 47 Anonyme
h1. Possible issues and resolutions
227 1 Anonyme
228 48 Anonyme
h2. Maven Eclipse Error
229
230
If Maven in Eclipse gives the following error:
231
232
 Plugin execution not covered by lifecycle configuration: org.eclipse.xtext:xtext-maven-plugin:2.5.0:generate (execution: default, phase: generate-sources)
233
234
In the Overview view of the pom.xml file, click on the error and select the Quick Fix named:
235
236
 Permanently mark goal generate in pom.xml as ignored.
237
238
This will prevent the maven plugin in Eclipse to generate the source code while Eclipse also does it internally.
239 8 Anonyme
240 10 Anonyme
h2. Project configuration is not up-to-date
241
242 5 Anonyme
You may get an error message saying your project configuration is out of date with your new pom.xml
243 36 Anonyme
Update it : right click on your project / Maven / Update Project Configuration... and click Ok.
244 7 Anonyme
245 1 Anonyme
!https://wwwsecu.irit.fr/redmine/attachments/download/337/update_project_conf.jpg!