Projet

Général

Profil

MAY Project Setup » Historique » Révision 50

Révision 49 (Anonyme, 28/02/2014 18:07) → Révision 50/74 (Anonyme, 28/02/2014 18:07)

*Draft version...* 

 h1. SpeADL MAY Project SetUp 

 _Estimated time: 3 minutes_ 

 h2. A classic JAVA project to start with... 

 First, create a java project, choose a name, and click finish. 

 Then, create a new file with the speadl extension within the src folder:  

 !https://wwwsecu.irit.fr/redmine/attachments/download/434/new_file_speadl1.png! 
 !https://wwwsecu.irit.fr/redmine/attachments/download/435/new_file_speadl2.png! 

 h2. Using Maven 

 The next step is to convert your project into a Maven project. To do this, right click on your project / Configure / Convert to Maven Project. 
 You will be asked to create a new POM file. Just click finish and edit it manually like this: 

 <pre> 
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
	 <modelVersion>4.0.0</modelVersion> 
	 <groupId>XXX</groupId> 
	 <artifactId>XXX</artifactId> 
	 <version>0.0.1-SNAPSHOT</version> 
	
	 <properties> 
		 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
	 </properties> 


	 <build> 
		 <sourceDirectory>src</sourceDirectory> 
		 <plugins> 
			 <plugin> 
				 <artifactId>maven-compiler-plugin</artifactId> 
				 <version>3.1</version> 
				 <configuration> 
					 <source>1.7</source> 
					 <target>1.7</target> 
				 </configuration> 
			 </plugin> 
			 <plugin> 
				 <groupId>org.codehaus.mojo</groupId> 
				 <artifactId>build-helper-maven-plugin</artifactId> 
				 <version>1.8</version> 
				 <executions> 
					 <execution> 
						 <id>add-source</id> 
						 <phase>generate-sources</phase> 
						 <goals> 
							 <goal>add-source</goal> 
						 </goals> 
						 <configuration> 
							 <sources> 
								 <source>speadl-gen</source> 
							 </sources> 
						 </configuration> 
					 </execution> 
					 <!-- The following is only needed so that speadl files are included in the generated maven artifact --> 
					 <execution> 
						 <id>add-resource</id> 
						 <goals> 
							 <goal>add-resource</goal> 
						 </goals> 
						 <configuration> 
							 <resources> 
								 <resource> 
									 <directory>${project.build.sourceDirectory}</directory> 
									 <includes> 
										 <include>**/*.speadl</include> 
									 </includes> 
								 </resource> 
							 </resources> 
						 </configuration> 
					 </execution> 
				 </executions> 
			 </plugin> 
		 </plugins> 
	 </build> 

	 <dependencies> 
		 <dependency> 
			 <groupId>fr.irit.smac.lib.may</groupId> 
			 <artifactId>common-components</artifactId> 
			 <version>3.2.4</version> 
		 </dependency> 
	 </dependencies> 

	 <repositories> 
		 <repository> 
			 <id>fr.irit.smac</id> 
			 <url>http://www.irit.fr/~Victor.Noel/maven-repos/</url> 
		 </repository> 
	 </repositories> 
 </project> 
 </pre> 

 h1. Using Maven for Code Generation 

 It is possible to use maven to generate code so that Eclipse is not needed anymore. 
 One possible workflow for doing that is to use another IDE and executing <pre>mvn generate-sources</pre> after modifying the speadl file. 

 In order to do that, use the following POM file (which add some things to the previous one): 

 <pre> 
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
	 <modelVersion>4.0.0</modelVersion> 
	 <groupId>XXX</groupId> 
	 <artifactId>XXX</artifactId> 
	 <version>0.0.1-SNAPSHOT</version> 

	 <properties> 
		 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
	 </properties> 

	 <build> 
		 <plugins> 
			 <plugin> 
				 <groupId>org.codehaus.mojo</groupId> 
				 <artifactId>build-helper-maven-plugin</artifactId> 
				 <version>1.8</version> 
				 <executions> 
					 <execution> 
						 <id>add-source</id> 
						 <goals> 
							 <goal>add-source</goal> 
						 </goals> 
						 <configuration> 
							 <sources> 
								 <source>speadl-gen</source> 
							 </sources> 
						 </configuration> 
					 </execution> 
					 <!-- The following is only needed so that speadl files are included in the generated maven artifact --> 
					 <execution> 
						 <id>add-resource</id> 
						 <goals> 
							 <goal>add-resource</goal> 
						 </goals> 
						 <configuration> 
							 <resources> 
								 <resource> 
									 <directory>src/main/java</directory> 
									 <includes> 
										 <include>**/*.speadl</include> 
									 </includes> 
								 </resource> 
							 </resources> 
						 </configuration> 
					 </execution> 
				 </executions> 
			 </plugin> 
			 <plugin> 
				 <groupId>org.apache.maven.plugins</groupId> 
				 <artifactId>maven-clean-plugin</artifactId> 
				 <version>2.5</version> 
				 <executions> 
					 <execution> 
						 <phase>clean</phase> 
						 <goals> 
							 <goal>clean</goal> 
						 </goals> 
						 <configuration> 
							 <filesets> 
								 <fileset> 
									 <directory>speadl-gen</directory> 
								 </fileset> 
							 </filesets> 
						 </configuration> 
					 </execution> 
				 </executions> 
			 </plugin> 
			 <plugin> 
				 <groupId>org.eclipse.xtext</groupId> 
				 <artifactId>xtext-maven-plugin</artifactId> 
				 <version>2.5.3</version> <version>2.5.0</version> 
				 <executions> 
					 <execution> 
						 <goals> 
							 <goal>generate</goal> 
						 </goals> 
					 </execution> 
				 </executions> 
				 <configuration> 
					 <languages> 
						 <language> 
							 <setup>fr.irit.smac.may.speadl.SpeADLStandaloneSetup</setup> 
							 <outputConfigurations> 
								 <outputConfiguration> 
									 <outputDirectory>speadl-gen</outputDirectory> 
								 </outputConfiguration> 
							 </outputConfigurations> 
						 </language> 
					 </languages> 
				 </configuration> 
				 <dependencies> 
					 <dependency> 
						 <groupId>fr.irit.smac.may</groupId> 
						 <artifactId>fr.irit.smac.may.speadl</artifactId> 
						 <version>3.2.4</version> <version>3.2.1</version> 
					 </dependency> 
				 </dependencies> 
			 </plugin> 
		 </plugins> 
	 </build> 
 </project> 
 </pre> 

 

 h1. Possible issues and resolutions 

 h2. Maven Eclipse Error 

 If Maven in Eclipse gives the following error: 

  Plugin execution not covered by lifecycle configuration: org.eclipse.xtext:xtext-maven-plugin:2.5.0:generate (execution: default, phase: generate-sources) 

 In the Overview view of the pom.xml file, click on the error and select the Quick Fix named: 

  Permanently mark goal generate in pom.xml as ignored. 

 This will prevent the maven plugin in Eclipse to generate the source code while Eclipse also does it internally. 

 h2. Project configuration is not up-to-date 

 You may get an error message saying your project configuration is out of date with your new pom.xml 
 Update it : right click on your project / Maven / Update Project Configuration... and click Ok. 

 !https://wwwsecu.irit.fr/redmine/attachments/download/337/update_project_conf.jpg!