Projet

Général

Profil

MAY Maven Standalone Setup » Historique » Version 9

Anonyme, 02/10/2014 11:44

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