Projet

Général

Profil

Actions

MAY Maven Standalone Setup » Historique » Révision 10

« Précédent | Révision 10/18 (diff) | Suivant »
Anonyme, 02/10/2014 11:46


SpeADL MAY Maven SetUp

It is possible to use maven to generate code so that Eclipse is not needed anymore.
For example, one possible workflow is to use another IDE and executing

mvn generate-sources

after modifying the speadl file.

It is also included in all other maven calls such as:

mvn package

In order to do that, use the following POM file:

<project ...>
    <modelVersion>4.0.0</modelVersion>
    <groupId>XXX</groupId>
    <artifactId>XXX</artifactId>
    <version>XXX</version>

    <properties>
        <may-lib-version>3.3.0</may-lib-version>
        <xtext-version>2.6.2</xtext-version>
        <may-version>3.3.1</may-version>
    </properties>

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

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

    <pluginRepositories>
        <pluginRepository>
            <id>fr.irit.smac</id>
            <url>http://www.irit.fr/~Victor.Noel/maven-repos/</url>
        </pluginRepository>
    </pluginRepositories>

    <build>
        <!-- This is already present in the default POM -->
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>src</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <!-- This is already present in the default POM -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <!-- This configure the maven to take into account the SpeADL code -->
            <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>${project.build.sourceDirectory}</directory>
                                    <includes>
                                        <include>**/*.speadl</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- This is needed cleaning the generated file before regenerating them
                  But not when doing a clean -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.5</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                        <configuration>
                            <excludeDefaultDirectories>true</excludeDefaultDirectories>
                            <filesets>
                                <fileset>
                                    <directory>speadl-gen</directory>
                                </fileset>
                            </filesets>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- This is needed for generating the file directly from maven -->
            <plugin>
                <groupId>org.eclipse.xtext</groupId>
                <artifactId>xtext-maven-plugin</artifactId>
                <version>${xtext-version}</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>${may-version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>

Possible Issues and Resolutions

Errors in the POM file

If the POM file contains the following errors in Eclipse:

Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-clean-plugin:2.5:clean (execution: default, phase: generate-sources)

and

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

When hovering on the error, choose the following quickfix:

Permanently mark goal clean in pom.xml as ignored as ignored in Eclipse build.

and

Permanently mark goal generate in pom.xml as ignored as ignored in Eclipse build.

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

Mis à jour par Anonyme il y a plus de 11 ans · 18 révisions