Projet

Général

Profil

MAY Maven Standalone Setup » Historique » Version 4

Anonyme, 01/10/2014 16:08

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
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
11
	<modelVersion>4.0.0</modelVersion>
12
	<groupId>XXX</groupId>
13
	<artifactId>XXX</artifactId>
14
	<version>XXX</version>
15 2 Anonyme
16 1 Anonyme
	<properties>
17
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18 2 Anonyme
		<xtext-version>2.6.2</xtext-version>
19
		<may-version>3.3.1</may-version>
20 1 Anonyme
		<may-lib-version>3.3.0</may-lib-version>
21
	</properties>
22
23
	<dependencies>
24
		<dependency>
25
			<groupId>fr.irit.smac.lib.may</groupId>
26
			<artifactId>common-components</artifactId>
27
			<version>${may-lib-version}</version>
28
		</dependency>
29
	</dependencies>
30
31
	<build>
32
		<plugins>
33
			<plugin>
34
				<groupId>org.codehaus.mojo</groupId>
35
				<artifactId>build-helper-maven-plugin</artifactId>
36
				<version>1.8</version>
37
				<executions>
38
					<execution>
39
						<id>add-source</id>
40
						<goals>
41
							<goal>add-source</goal>
42
						</goals>
43
						<configuration>
44
							<sources>
45
								<source>speadl-gen</source>
46
							</sources>
47
						</configuration>
48
					</execution>
49
					<!-- The following is only needed so that speadl files are included in the generated maven artifact -->
50
					<execution>
51
						<id>add-resource</id>
52
						<goals>
53
							<goal>add-resource</goal>
54
						</goals>
55
						<configuration>
56
							<resources>
57
								<resource>
58 2 Anonyme
									<directory>src/main/java</directory>
59 1 Anonyme
									<includes>
60
										<include>**/*.speadl</include>
61
									</includes>
62
								</resource>
63
							</resources>
64
						</configuration>
65
					</execution>
66
				</executions>
67 2 Anonyme
			</plugin>
68
			<plugin>
69
				<groupId>org.apache.maven.plugins</groupId>
70
				<artifactId>maven-clean-plugin</artifactId>
71
				<version>2.5</version>
72
				<executions>
73
					<execution>
74
						<!-- hack in order for the file not to be removed on clean but only 
75
								prior to code generation from xtext-maven-plugin -->
76
						<phase>generate-sources</phase>
77
						<goals>
78
							<goal>clean</goal>
79
						</goals>
80
						<configuration>
81
							<excludeDefaultDirectories>true</excludeDefaultDirectories>
82
							<filesets>
83
								<fileset>
84
									<directory>speadl-gen</directory>
85
								</fileset>
86
							</filesets>
87
						</configuration>
88
					</execution>
89
				</executions>
90
			</plugin>
91
			<plugin>
92
				<groupId>org.eclipse.xtext</groupId>
93
				<artifactId>xtext-maven-plugin</artifactId>
94
				<version>${xtext-version}</version>
95
				<executions>
96
					<execution>
97
						<goals>
98
							<goal>generate</goal>
99
						</goals>
100
					</execution>
101
				</executions>
102
				<configuration>
103
					<languages>
104
						<language>
105
							<setup>fr.irit.smac.may.speadl.SpeADLStandaloneSetup</setup>
106
							<outputConfigurations>
107
								<outputConfiguration>
108
									<outputDirectory>speadl-gen</outputDirectory>
109
								</outputConfiguration>
110
							</outputConfigurations>
111
						</language>
112
					</languages>
113
				</configuration>
114
				<dependencies>
115
					<dependency>
116
						<groupId>fr.irit.smac.may</groupId>
117
						<artifactId>fr.irit.smac.may.speadl</artifactId>
118
						<version>${may-version}</version>
119
					</dependency>
120
				</dependencies>
121 1 Anonyme
			</plugin>
122
		</plugins>
123
	</build>
124
</project>
125
</pre>
126 3 Anonyme
127 4 Anonyme
h2. Possible issues and resolutions
128 3 Anonyme
129
If Maven in Eclipse gives the following error:
130
131
 Plugin execution not covered by lifecycle configuration: org.eclipse.xtext:xtext-maven-plugin:2.6.0:generate (execution: default, phase: generate-sources)
132
133
In the Overview view of the pom.xml file, click on the error and select the Quick Fix named:
134
135
 Permanently mark goal generate in pom.xml as ignored.
136
137
This will prevent the maven plugin in Eclipse to generate the source code while Eclipse also does it internally.