Projet

Général

Profil

MAY Maven Standalone Setup » Historique » Version 10

Anonyme, 02/10/2014 11:46

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