Projet

Général

Profil

MAY Maven Standalone Setup » Historique » Version 16

Anonyme, 24/10/2014 13:05

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