Projet

Général

Profil

MAY Project Setup » Historique » Version 51

Anonyme, 27/05/2014 18:51

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
						<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 49 Anonyme
			<version>3.2.4</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
	</properties>
118
119
	<build>
120
		<plugins>
121
			<plugin>
122
				<groupId>org.codehaus.mojo</groupId>
123
				<artifactId>build-helper-maven-plugin</artifactId>
124
				<version>1.8</version>
125
				<executions>
126
					<execution>
127
						<id>add-source</id>
128
						<goals>
129
							<goal>add-source</goal>
130
						</goals>
131
						<configuration>
132
							<sources>
133
								<source>speadl-gen</source>
134
							</sources>
135
						</configuration>
136
					</execution>
137
					<!-- The following is only needed so that speadl files are included in the generated maven artifact -->
138
					<execution>
139
						<id>add-resource</id>
140
						<goals>
141
							<goal>add-resource</goal>
142
						</goals>
143
						<configuration>
144
							<resources>
145
								<resource>
146
									<directory>src/main/java</directory>
147
									<includes>
148
										<include>**/*.speadl</include>
149
									</includes>
150
								</resource>
151
							</resources>
152
						</configuration>
153
					</execution>
154
				</executions>
155
			</plugin>
156
			<plugin>
157
				<groupId>org.apache.maven.plugins</groupId>
158
				<artifactId>maven-clean-plugin</artifactId>
159
				<version>2.5</version>
160
				<executions>
161
					<execution>
162
						<phase>clean</phase>
163
						<goals>
164
							<goal>clean</goal>
165
						</goals>
166
						<configuration>
167
							<filesets>
168
								<fileset>
169
									<directory>speadl-gen</directory>
170
								</fileset>
171
							</filesets>
172
						</configuration>
173
					</execution>
174
				</executions>
175
			</plugin>
176
			<plugin>
177
				<groupId>org.eclipse.xtext</groupId>
178
				<artifactId>xtext-maven-plugin</artifactId>
179 50 Anonyme
				<version>2.5.3</version>
180 48 Anonyme
				<executions>
181
					<execution>
182
						<goals>
183
							<goal>generate</goal>
184
						</goals>
185
					</execution>
186
				</executions>
187
				<configuration>
188
					<languages>
189
						<language>
190
							<setup>fr.irit.smac.may.speadl.SpeADLStandaloneSetup</setup>
191
							<outputConfigurations>
192
								<outputConfiguration>
193
									<outputDirectory>speadl-gen</outputDirectory>
194
								</outputConfiguration>
195
							</outputConfigurations>
196
						</language>
197
					</languages>
198
				</configuration>
199
				<dependencies>
200
					<dependency>
201
						<groupId>fr.irit.smac.may</groupId>
202
						<artifactId>fr.irit.smac.may.speadl</artifactId>
203 50 Anonyme
						<version>3.2.4</version>
204 48 Anonyme
					</dependency>
205
				</dependencies>
206
			</plugin>
207
		</plugins>
208
	</build>
209
</project>
210
</pre>
211
212 47 Anonyme
h1. Possible issues and resolutions
213 1 Anonyme
214 48 Anonyme
h2. Maven Eclipse Error
215
216
If Maven in Eclipse gives the following error:
217
218
 Plugin execution not covered by lifecycle configuration: org.eclipse.xtext:xtext-maven-plugin:2.5.0:generate (execution: default, phase: generate-sources)
219
220
In the Overview view of the pom.xml file, click on the error and select the Quick Fix named:
221
222
 Permanently mark goal generate in pom.xml as ignored.
223
224
This will prevent the maven plugin in Eclipse to generate the source code while Eclipse also does it internally.
225 8 Anonyme
226 10 Anonyme
h2. Project configuration is not up-to-date
227
228 5 Anonyme
You may get an error message saying your project configuration is out of date with your new pom.xml
229 36 Anonyme
Update it : right click on your project / Maven / Update Project Configuration... and click Ok.
230 7 Anonyme
231 1 Anonyme
!https://wwwsecu.irit.fr/redmine/attachments/download/337/update_project_conf.jpg!