Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » prevent compiling in xtext-maven-plugin
prevent compiling in xtext-maven-plugin [message #1753007] Wed, 01 February 2017 05:35 Go to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
I created a pom.xml. The contents are basically the same in this link:
https://github.com/ghillairet/xcore-maven-example/blob/master/pom.xml. It can compile without problem.

But, I need my .xcore to refer to some methods in a Test.xtend file. And I am getting an error saying "org.generator.Test cannot be resolved". I don't need it to compile the java classes. I just want xcore to generate the java classes, as these will then be compiled together with the xtend classes. Is it possible to configure the xtext-maven-plugin to just tell xcore to generate the classes?

[Updated on: Wed, 01 February 2017 05:40]

Report message to a moderator

Re: prevent compiling in xtext-maven-plugin [message #1753008 is a reply to message #1753007] Wed, 01 February 2017 06:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11501
Registered: July 2009
Senior Member
Hi,

i dont get that.
there are actual references inside the xcore file. thus it needs to see the xtend files (well you could call the xtend maven plugin first.

and cant reproduce it.

did you adapt the pom to handle xtend files ?!?

                        </language>
                        <language>
                            <setup>org.eclipse.xtend.core.XtendStandaloneSetup</setup>
                            <outputConfigurations>
                                <outputConfiguration>
                                    <outputDirectory>${project.basedir}/src/main/java-gen</outputDirectory>
                                </outputConfiguration>
                            </outputConfigurations>
                        </language>



//deps of xtext-maven-plugin
                    <dependency>
                        <groupId>org.eclipse.xtend</groupId>
                        <artifactId>org.eclipse.xtend.core</artifactId>
                        <version>${xtext-version}</version>
                    </dependency>


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: prevent compiling in xtext-maven-plugin [message #1753010 is a reply to message #1753008] Wed, 01 February 2017 06:34 Go to previous messageGo to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
Hi Christian,
No, i did not adapt the pom. My problem is from a clean build the java classes from xtend will not be generated yet. So, the classes technically does not exist yet when xcore is compiling. Can the xtext-maven-plugin accept xtend classes?

Currently, in my .xcore file, I import an xtend class. And it is called in an operation.
import org.generator.Test

class Greetings {
 String name
 int age
 op String checkValid() {
   if (Test::getState(age))
      return "You are still a minor."
  return "Adult"
 }
}


If I remove the call to the Test method and the import, it can compile successfully.
My xtend file is in src folder, and the generated java classes is in xtend-gen. I did not include either of these directories in my pom.xml.
Re: prevent compiling in xtext-maven-plugin [message #1753012 is a reply to message #1753010] Wed, 01 February 2017 06:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11501
Registered: July 2009
Senior Member
as i said what you try to do makes no sense

(a) you have to call xtend maven before xtext maven since xcore needs to find the xtend file or the generated java file for it
(b) you need to enable the xtext maven plugin to see xtend as well (my snippets)


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: prevent compiling in xtext-maven-plugin [message #1753013 is a reply to message #1753010] Wed, 01 February 2017 06:45 Go to previous messageGo to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
Hi Christian,
I tried your suggestion above but I get this error.


[INFO] --- xtext-maven-plugin:2.10.0:generate (default) @ xtext ---
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/eclipse/xtend/org.eclipse.xtend.core/2.10.0/org.eclipse.xtend.core-2.10.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.529 s
[INFO] Finished at: 2017-02-01T14:40:24+08:00
[INFO] Final Memory: 10M/244M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.xtext:xtext-maven-plugin:2.10.0:generate (default) on project xtext: Execution default of goal org.eclipse.xtext:xtext-maven-plugin:2.10.0:generate failed: Plugin org.eclipse.xtext:xtext-maven-plugin:2.10.0 or one of its dependencies could not be resolved: Failed to collect dependencies at org.eclipse.xtext:xtext-maven-plugin:jar:2.10.0 -> org.eclipse.xtend:org.eclipse.xtend.core:jar:2.10.0: Failed to read artifact descriptor for org.eclipse.xtend:org.eclipse.xtend.core:jar:2.10.0: Could not transfer artifact org.eclipse.xtend:org.eclipse.xtend.core:pom:2.10.0 from/to central (https://repo.maven.apache.org/maven2): connect timed out -> [Help 1]
[ERROR] 


This is the content of my pom.xml.
<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>xtext</groupId>
    <version>1.0.0-SNAPSHOT</version>
    <artifactId>xtext</artifactId>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <emf-version>2.12.0</emf-version>
        <emf-common-version>2.12.0</emf-common-version>
        <emf-codegen-version>2.11.0</emf-codegen-version>
        <xtext-version>2.10.0</xtext-version>
        <ecore-xtext-version>1.2.0</ecore-xtext-version>
        <ecore-xcore-version>1.3.1</ecore-xcore-version>
        <ecore-xcore-lib-version>1.1.100</ecore-xcore-lib-version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.eclipse.emf</groupId>
            <artifactId>org.eclipse.emf.common</artifactId>
            <version>${emf-common-version}</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.emf</groupId>
            <artifactId>org.eclipse.emf.ecore</artifactId>
            <version>${emf-version}</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.emf</groupId>
            <artifactId>org.eclipse.emf.ecore.xcore.lib</artifactId>
            <version>${ecore-xcore-lib-version}</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.xtext</groupId>
            <artifactId>org.eclipse.xtext.xbase.lib</artifactId>
            <version>${xtext-version}</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.6.1</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>emf-gen</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.9.1</version>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${basedir}/emf-gen</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.eclipse.xtext</groupId>
                <artifactId>xtext-maven-plugin</artifactId>
                <version>${xtext-version}</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <languages>
                        <language>
                            <setup>org.eclipse.xtext.ecore.EcoreSupport</setup>
                        </language>
                        <language>
                            <setup>org.eclipse.emf.codegen.ecore.xtext.GenModelSupport</setup>
                        </language>
                        <language>
                            <setup>org.eclipse.xtend.core.XtendStandaloneSetup</setup>
                            <outputConfigurations>
                                <outputConfiguration>
                                    <outputDirectory>${project.basedir}/xtend-gen</outputDirectory>
                                </outputConfiguration>
                            </outputConfigurations>
                        </language>
                        <language>
                            <setup>org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup</setup>
                            <outputConfigurations>
                                <outputConfiguration>
                                    <outputDirectory>${project.basedir}/emf-gen</outputDirectory>
                                </outputConfiguration>
                            </outputConfigurations>
                        </language>
                    </languages>
                    <sourceRoots>
                        <root>${basedir}/src/org</root>
                    </sourceRoots>
                    <compilerSourceLevel>1.7</compilerSourceLevel>
                    <compilerTargetLevel>1.7</compilerTargetLevel>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.eclipse.text</groupId>
                        <artifactId>org.eclipse.text</artifactId>
                        <version>3.5.101</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.core</groupId>
                        <artifactId>org.eclipse.core.resources</artifactId>
                        <version>3.7.100</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.xtend</groupId>
                        <artifactId>org.eclipse.xtend.core</artifactId>
                        <version>${xtext-version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.xtext</groupId>
                        <artifactId>org.eclipse.xtext.ecore</artifactId>
                        <version>${xtext-version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.xtext</groupId>
                        <artifactId>org.eclipse.xtext.xbase</artifactId>
                        <version>${xtext-version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.emf</groupId>
                        <artifactId>org.eclipse.emf.codegen.ecore.xtext</artifactId>
                        <version>${ecore-xtext-version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.emf</groupId>
                        <artifactId>org.eclipse.emf.common</artifactId>
                        <version>${emf-common-version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.emf</groupId>
                        <artifactId>org.eclipse.emf.ecore</artifactId>
                        <version>${emf-version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.emf</groupId>
                        <artifactId>org.eclipse.emf.ecore.xmi</artifactId>
                        <version>${emf-version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.emf</groupId>
                        <artifactId>org.eclipse.emf.codegen</artifactId>
                        <version>${emf-codegen-version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.emf</groupId>
                        <artifactId>org.eclipse.emf.codegen.ecore</artifactId>
                        <version>${emf-codegen-version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.emf</groupId>
                        <artifactId>org.eclipse.emf.ecore.xcore</artifactId>
                        <version>${ecore-xcore-version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.emf</groupId>
                        <artifactId>org.eclipse.emf.ecore.xcore.lib</artifactId>
                        <version>${ecore-xcore-lib-version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>


Do I need to create a separate plugin for xtend?

[Updated on: Wed, 01 February 2017 06:52]

Report message to a moderator

Re: prevent compiling in xtext-maven-plugin [message #1753014 is a reply to message #1753013] Wed, 01 February 2017 06:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11501
Registered: July 2009
Senior Member
no i dont think so do you?!?
https://search.maven.org/#artifactdetails%7Corg.eclipse.xtend%7Corg.eclipse.xtend.core%7C2.10.0%7Ceclipse-plugin
are you sure the xtend core plugin is available in your maven repo config? did you run maven with -U


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: prevent compiling in xtext-maven-plugin [message #1753016 is a reply to message #1753014] Wed, 01 February 2017 07:33 Go to previous messageGo to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
i managed to make it work. but I encountered another problem.

My project's flow is this:
xcore
-> used by the xtext grammar
-> also does some operations and refers to the methods defined in xtend.

xtend
-> transforms and generate the classes
-> calls the op methods in xcore
-> refers to the xtext variables

Thus, xcore depends on the java classes of xtend, and xtend depends on the xtext variables which also depends on the xcore stuffs.
All these are in one project. This is not a problem if build is being handled by Eclipse IDE. But when being run by the maven script in a "clean" environment (no generated sources from xtend yet), this becomes a problem.

So, I was thinking that for XcoreStandaloneSetup, it just simple generates the .java files without checking for the validity. The validity will be checked anyway, when xtend is compiled. I noticed that with Eclipse IDE, only the java files are generated. There are no .class files. But when running maven, .class files are there. Thus, is it possible to skip this part (the .class files) of the xcore compiler?
Re: prevent compiling in xtext-maven-plugin [message #1753021 is a reply to message #1753016] Wed, 01 February 2017 08:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11501
Registered: July 2009
Senior Member
as i said: thats no possible.
thus another question

is it a real circle xtend -> xcore -> xtend or is it a loose circle some xtend -> xcore -> some other xtend?
if so you could solve this by having two projects or separate source folders i think


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: prevent compiling in xtext-maven-plugin [message #1753033 is a reply to message #1753021] Wed, 01 February 2017 09:51 Go to previous messageGo to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
it is a real circle, unfortunately.
Re: prevent compiling in xtext-maven-plugin [message #1753034 is a reply to message #1753033] Wed, 01 February 2017 09:57 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11501
Registered: July 2009
Senior Member
yes but whats not working with my approach?

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Previous Topic:Xtext and EMF4CPP
Next Topic:Loading Xtext model without direct dependency to xtext plugin
Goto Forum:
  


Current Time: Wed Dec 13 21:00:29 GMT 2017

Powered by FUDForum. Page generated in 0.02581 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software