Projet

Général

Profil

MAY Maven Standalone Setup » Historique » Version 12

Anonyme, 02/10/2014 11:47

1 1 Anonyme
h1. SpeADL MAY Maven SetUp
2
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
h2. Modifying the POM File
17 1 Anonyme
18 2 Anonyme
In order to do that, use the following POM file:
19 1 Anonyme
20
<pre>
21 7 Anonyme
<project ...>
22 1 Anonyme
	<modelVersion>4.0.0</modelVersion>
23
	<groupId>XXX</groupId>
24
	<artifactId>XXX</artifactId>
25
	<version>XXX</version>
26
27
	<properties>
28 7 Anonyme
		<may-lib-version>3.3.0</may-lib-version>
29 2 Anonyme
		<xtext-version>2.6.2</xtext-version>
30 1 Anonyme
		<may-version>3.3.1</may-version>
31
	</properties>
32
33
	<dependencies>
34
		<dependency>
35
			<groupId>fr.irit.smac.lib.may</groupId>
36
			<artifactId>common-components</artifactId>
37
			<version>${may-lib-version}</version>
38
		</dependency>
39
	</dependencies>
40
41 7 Anonyme
	<repositories>
42
		<repository>
43
			<id>fr.irit.smac</id>
44
			<url>http://www.irit.fr/~Victor.Noel/maven-repos/</url>
45
		</repository>
46
	</repositories>
47
48 9 Anonyme
	<pluginRepositories>
49
		<pluginRepository>
50
			<id>fr.irit.smac</id>
51
			<url>http://www.irit.fr/~Victor.Noel/maven-repos/</url>
52
		</pluginRepository>
53
	</pluginRepositories>
54
55 1 Anonyme
	<build>
56 7 Anonyme
		<!-- This is already present in the default POM -->
57
		<sourceDirectory>src</sourceDirectory>
58
		<resources>
59
			<resource>
60
				<directory>src</directory>
61
				<excludes>
62
					<exclude>**/*.java</exclude>
63
				</excludes>
64
			</resource>
65
		</resources>
66 1 Anonyme
		<plugins>
67 7 Anonyme
			<!-- This is already present in the default POM -->
68 1 Anonyme
			<plugin>
69 7 Anonyme
				<artifactId>maven-compiler-plugin</artifactId>
70
				<version>3.1</version>
71
				<configuration>
72
					<source>1.7</source>
73
					<target>1.7</target>
74
				</configuration>
75
			</plugin>
76
			<!-- This configure the maven to take into account the SpeADL code -->
77
			<plugin>
78 1 Anonyme
				<groupId>org.codehaus.mojo</groupId>
79
				<artifactId>build-helper-maven-plugin</artifactId>
80
				<version>1.8</version>
81
				<executions>
82
					<execution>
83
						<id>add-source</id>
84
						<goals>
85
							<goal>add-source</goal>
86
						</goals>
87
						<configuration>
88
							<sources>
89
								<source>speadl-gen</source>
90
							</sources>
91
						</configuration>
92
					</execution>
93 7 Anonyme
					<!-- The following is only needed so that speadl files are included 
94
						in the generated maven artifact -->
95 1 Anonyme
					<execution>
96
						<id>add-resource</id>
97
						<goals>
98
							<goal>add-resource</goal>
99
						</goals>
100
						<configuration>
101 2 Anonyme
							<resources>
102 1 Anonyme
								<resource>
103 7 Anonyme
									<directory>${project.build.sourceDirectory}</directory>
104 1 Anonyme
									<includes>
105
										<include>**/*.speadl</include>
106
									</includes>
107
								</resource>
108
							</resources>
109
						</configuration>
110
					</execution>
111 2 Anonyme
				</executions>
112
			</plugin>
113 8 Anonyme
			<!-- This is needed cleaning the generated file before regenerating them
114
			      But not when doing a clean -->
115 2 Anonyme
			<plugin>
116
				<groupId>org.apache.maven.plugins</groupId>
117
				<artifactId>maven-clean-plugin</artifactId>
118
				<version>2.5</version>
119
				<executions>
120
					<execution>
121
						<phase>generate-sources</phase>
122
						<goals>
123
							<goal>clean</goal>
124
						</goals>
125
						<configuration>
126
							<excludeDefaultDirectories>true</excludeDefaultDirectories>
127
							<filesets>
128 1 Anonyme
								<fileset>
129 2 Anonyme
									<directory>speadl-gen</directory>
130
								</fileset>
131
							</filesets>
132
						</configuration>
133
					</execution>
134
				</executions>
135
			</plugin>
136 7 Anonyme
			<!-- This is needed for generating the file directly from maven -->
137 2 Anonyme
			<plugin>
138
				<groupId>org.eclipse.xtext</groupId>
139
				<artifactId>xtext-maven-plugin</artifactId>
140
				<version>${xtext-version}</version>
141
				<executions>
142
					<execution>
143
						<goals>
144
							<goal>generate</goal>
145
						</goals>
146
					</execution>
147
				</executions>
148
				<configuration>
149
					<languages>
150
						<language>
151
							<setup>fr.irit.smac.may.speadl.SpeADLStandaloneSetup</setup>
152
							<outputConfigurations>
153
								<outputConfiguration>
154
									<outputDirectory>speadl-gen</outputDirectory>
155
								</outputConfiguration>
156
							</outputConfigurations>
157
						</language>
158
					</languages>
159
				</configuration>
160
				<dependencies>
161
					<dependency>
162
						<groupId>fr.irit.smac.may</groupId>
163
						<artifactId>fr.irit.smac.may.speadl</artifactId>
164
						<version>${may-version}</version>
165
					</dependency>
166
				</dependencies>
167 1 Anonyme
			</plugin>
168
		</plugins>
169
	</build>
170
</project>
171
</pre>
172 3 Anonyme
173 5 Anonyme
h2. Possible Issues and Resolutions
174 3 Anonyme
175 6 Anonyme
h3. Errors in the POM file
176
177 5 Anonyme
If the POM file contains the following errors in Eclipse:
178 3 Anonyme
179 5 Anonyme
 Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-clean-plugin:2.5:clean (execution: default, phase: generate-sources)
180 1 Anonyme
181 5 Anonyme
and
182 1 Anonyme
183 5 Anonyme
 Plugin execution not covered by lifecycle configuration: org.eclipse.xtext:xtext-maven-plugin:2.6.2:generate (execution: default, phase: generate-sources)
184 1 Anonyme
185 5 Anonyme
When hovering on the error, choose the following quickfix:
186
187
 Permanently mark goal clean in pom.xml as ignored as ignored in Eclipse build.
188
189
and
190
191
 Permanently mark goal generate in pom.xml as ignored as ignored in Eclipse build.
192
193
This will prevent the Maven plugin in Eclipse to generate the source code while Eclipse also does it internally.