Projet

Général

Profil

MAY Project Setup » Historique » Version 53

Anonyme, 27/05/2014 18:56

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 53 Anonyme
		<may-version>3.2.4</may-version>
32 48 Anonyme
	</properties>
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
						<goals>
53
							<goal>add-source</goal>
54
						</goals>
55
						<configuration>
56
							<sources>
57
								<source>speadl-gen</source>
58
							</sources>
59
						</configuration>
60
					</execution>
61
					<!-- The following is only needed so that speadl files are included in the generated maven artifact -->
62
					<execution>
63
						<id>add-resource</id>
64
						<goals>
65
							<goal>add-resource</goal>
66
						</goals>
67
						<configuration>
68
							<resources>
69
								<resource>
70
									<directory>${project.build.sourceDirectory}</directory>
71
									<includes>
72
										<include>**/*.speadl</include>
73
									</includes>
74
								</resource>
75
							</resources>
76
						</configuration>
77
					</execution>
78
				</executions>
79
			</plugin>
80
		</plugins>
81
	</build>
82
83
	<dependencies>
84
		<dependency>
85
			<groupId>fr.irit.smac.lib.may</groupId>
86
			<artifactId>common-components</artifactId>
87 53 Anonyme
			<version>${may-version}</version>
88 47 Anonyme
		</dependency>
89
	</dependencies>
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 48 Anonyme
	</properties>
120
121 52 Anonyme
	<dependencies>
122
		<dependency>
123
			<groupId>fr.irit.smac.lib.may</groupId>
124
			<artifactId>common-components</artifactId>
125
			<version>${may-version}</version>
126
		</dependency>
127
	</dependencies>
128
129 48 Anonyme
	<build>
130
		<plugins>
131
			<plugin>
132
				<groupId>org.codehaus.mojo</groupId>
133
				<artifactId>build-helper-maven-plugin</artifactId>
134
				<version>1.8</version>
135
				<executions>
136
					<execution>
137
						<id>add-source</id>
138
						<goals>
139
							<goal>add-source</goal>
140
						</goals>
141
						<configuration>
142
							<sources>
143
								<source>speadl-gen</source>
144
							</sources>
145
						</configuration>
146
					</execution>
147
					<!-- The following is only needed so that speadl files are included in the generated maven artifact -->
148
					<execution>
149
						<id>add-resource</id>
150
						<goals>
151
							<goal>add-resource</goal>
152
						</goals>
153
						<configuration>
154
							<resources>
155
								<resource>
156
									<directory>src/main/java</directory>
157
									<includes>
158
										<include>**/*.speadl</include>
159
									</includes>
160
								</resource>
161
							</resources>
162
						</configuration>
163
					</execution>
164
				</executions>
165
			</plugin>
166
			<plugin>
167
				<groupId>org.apache.maven.plugins</groupId>
168
				<artifactId>maven-clean-plugin</artifactId>
169
				<version>2.5</version>
170
				<executions>
171 1 Anonyme
					<execution>
172 52 Anonyme
						<!-- hack in order for the file not to be removed on clean but only 
173
								prior to code generation from xtext-maven-plugin -->
174
						<phase>generate-sources</phase>
175 48 Anonyme
						<goals>
176
							<goal>clean</goal>
177
						</goals>
178 1 Anonyme
						<configuration>
179 52 Anonyme
							<excludeDefaultDirectories>true</excludeDefaultDirectories>
180 48 Anonyme
							<filesets>
181
								<fileset>
182
									<directory>speadl-gen</directory>
183
								</fileset>
184
							</filesets>
185
						</configuration>
186
					</execution>
187
				</executions>
188
			</plugin>
189
			<plugin>
190 1 Anonyme
				<groupId>org.eclipse.xtext</groupId>
191 48 Anonyme
				<artifactId>xtext-maven-plugin</artifactId>
192 52 Anonyme
				<version>${xtext-version}</version>
193 48 Anonyme
				<executions>
194
					<execution>
195
						<goals>
196
							<goal>generate</goal>
197
						</goals>
198
					</execution>
199
				</executions>
200
				<configuration>
201
					<languages>
202
						<language>
203
							<setup>fr.irit.smac.may.speadl.SpeADLStandaloneSetup</setup>
204
							<outputConfigurations>
205
								<outputConfiguration>
206
									<outputDirectory>speadl-gen</outputDirectory>
207
								</outputConfiguration>
208
							</outputConfigurations>
209
						</language>
210
					</languages>
211
				</configuration>
212
				<dependencies>
213 1 Anonyme
					<dependency>
214 48 Anonyme
						<groupId>fr.irit.smac.may</groupId>
215
						<artifactId>fr.irit.smac.may.speadl</artifactId>
216 52 Anonyme
						<version>${may-version}</version>
217 48 Anonyme
					</dependency>
218
				</dependencies>
219
			</plugin>
220
		</plugins>
221
	</build>
222
</project>
223
</pre>
224
225 47 Anonyme
h1. Possible issues and resolutions
226 1 Anonyme
227 48 Anonyme
h2. Maven Eclipse Error
228
229
If Maven in Eclipse gives the following error:
230
231
 Plugin execution not covered by lifecycle configuration: org.eclipse.xtext:xtext-maven-plugin:2.5.0:generate (execution: default, phase: generate-sources)
232
233
In the Overview view of the pom.xml file, click on the error and select the Quick Fix named:
234
235
 Permanently mark goal generate in pom.xml as ignored.
236
237
This will prevent the maven plugin in Eclipse to generate the source code while Eclipse also does it internally.
238 8 Anonyme
239 10 Anonyme
h2. Project configuration is not up-to-date
240
241 5 Anonyme
You may get an error message saying your project configuration is out of date with your new pom.xml
242 36 Anonyme
Update it : right click on your project / Maven / Update Project Configuration... and click Ok.
243 7 Anonyme
244 1 Anonyme
!https://wwwsecu.irit.fr/redmine/attachments/download/337/update_project_conf.jpg!