Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Using Gradle to Generate XCore and IncQuery code
Using Gradle to Generate XCore and IncQuery code [message #1711186] Tue, 13 October 2015 19:53 Go to next message
Eclipse UserFriend
I'm trying to generate EMF models outside of Eclipse using Gradle. I've tried the Gradle build script included at the end. I pieced this together from the one resource I could find. A working example showing both incQuery and XCore would be extremely helpful.

The error I am getting:

Caused by: java.lang.ClassNotFoundException: org.eclipse.xtext.ecore.EcoreSupportStandaloneSetup


The Build Script

plugins {
    id "org.xtext.xtext" version "0.3.25"
}

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    // I've tried a whole slew of dependencies here to no avail
    xtextTooling 'org.eclipse.emf:org.eclipse.emf.ecore.xcore:1.3.1'
}

xtext {
    version = '2.8.4'
    sources {
        srcDir 'src/main/xcore'
    }
    languages {
        xcore {
            setup = 'org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup'
            output.dir = 'build.xcore'
        }
    }
}

[Updated on: Tue, 13 October 2015 19:53] by Moderator

Re: Using Gradle to Generate XCore and IncQuery code [message #1711212 is a reply to message #1711186] Wed, 14 October 2015 03:31 Go to previous messageGo to next message
Eclipse UserFriend
Hi Hassan,

I guess you are missing some dependencies. According to the pom file in maven central (https://repo1.maven.org/maven2/org/eclipse/xtext/xtext-maven-plugin/2.9.0.beta5/xtext-maven-plugin-2.9.0.beta5.pom), the plug-in you are missing should be 'org.eclipse.xtext:org.eclipse.xtext.ecore'. Maybe other dependencies are also missing, look for the definition of the plug-in.

About IncQuery support, we don't have a Gradle compiler, and we had to customize the Maven compiler to load some EPackages into the EPackage registry. If I recall orrectly, Gradle can execute Java code in the build script, so it is possible that you can do it without dedicated support, however, I have no real experience with Gradle, so I cannot be sure. Furthermore, I don't know about anybody who has tried to execute the IncQuery generator from Gradle.

I hope this was helpful,
Zoltán
Re: Using Gradle to Generate XCore and IncQuery code [message #1711215 is a reply to message #1711186] Wed, 14 October 2015 03:41 Go to previous messageGo to next message
Eclipse UserFriend
You will need org.eclipse.xtext.ecore and probably also org.eclipse.emf.codegen.ecore.xtext as xtextTooling dependencies. Unfortunately, Xcore does not properly declare its transitive dependencies.
Re: Using Gradle to Generate XCore and IncQuery code [message #1711217 is a reply to message #1711215] Wed, 14 October 2015 03:43 Go to previous messageGo to next message
Eclipse UserFriend
@Zoltan why don't you register those EPackages in your StandaloneSetup? Then the Maven and Gradle plugins will work out of the box.
Re: Using Gradle to Generate XCore and IncQuery code [message #1711223 is a reply to message #1711217] Wed, 14 October 2015 04:08 Go to previous messageGo to next message
Eclipse UserFriend
@Stefan: For EMF-IncQuery the used EPackages are user input, not a statically determined set of EPackages, so we could not add everything a user may want.

Maybe it would be possible to ask the user the extend our standalone setup, but we thought this approach is cleaner. Furthermore, we are delegating to the Xtext generator, just after setting up our requirements.

Cheers,
Zoltán
Re: Using Gradle to Generate XCore and IncQuery code [message #1711227 is a reply to message #1711223] Wed, 14 October 2015 04:31 Go to previous messageGo to next message
Eclipse UserFriend
@Zoltan I see, for such a use case the Gradle plugin would need a hook for running additional setup. It runs in an isolated classloader, so doing the setups inside the Gradle build will not help. It would be great if you could elaborate on the use case a little in the issue tracker of the Gradle plugin https://github.com/xtext/xtext-gradle-plugin
Re: Using Gradle to Generate XCore and IncQuery code [message #1711274 is a reply to message #1711227] Wed, 14 October 2015 09:54 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for all the replies guys. This is what the build definitions looks like now:

plugins {
    id "org.xtext.xtext" version "0.3.25"
}

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    xtextTooling 'org.eclipse.emf:org.eclipse.emf.ecore.xcore:1.3.1'
    xtextTooling 'org.eclipse.emf:org.eclipse.emf.codegen.ecore.xtext:1.2.0'
    xtextTooling 'org.eclipse.xtext:org.eclipse.xtext.ecore:2.9.0.beta5'
}

xtext {
    version = '2.8.4'
    sources {
        srcDir 'src/main/xcore'
    }
    languages {
        xcore {
            setup = 'org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup'
            output.dir = 'build.xcore'
        }
    }
}


I am now getting the following error (which I have seen before with different combinations of dependencies).

Caused by: java.lang.NoClassDefFoundError: org/eclipse/emf/mwe2/runtime/workflow/IWorkflowComponent
        at org.eclipse.xtext.ecore.EcoreSupportStandaloneSetup.<init>(EcoreSupportStandaloneSetup.java:23)
        at org.eclipse.xtext.ecore.EcoreSupportStandaloneSetup.setup(EcoreSupportStandaloneSetup.java:19)
        at org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup.createInjectorAndDoEMFRegistration(XcoreStandaloneSetup.java:64)
        at org.eclipse.xtext.builder.standalone.LanguageAccessFactory.createLanguageAccess(LanguageAccessFactory.java:37)
        at org.xtext.builder.standalone.Main.generate(Main.java:48)
        ... 67 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.emf.mwe2.runtime.workflow.IWorkflowComponent
        ... 72 more


Re: Using Gradle to Generate XCore and IncQuery code [message #1711416 is a reply to message #1711274] Thu, 15 October 2015 14:54 Go to previous messageGo to next message
Eclipse UserFriend
Could you please file a bug against Xcore and Xtext respectively? We are lacking transitive dependency declarations. You shouldn't need to hunt for dependencies.

As a workaround, look at the packages and you will find the corresponding jars you are missing on search.maven.org. Also, don't mix Xtext 2.8.4 and 2.9.0.beta5
Re: Using Gradle to Generate XCore and IncQuery code [message #1711420 is a reply to message #1711416] Thu, 15 October 2015 16:28 Go to previous messageGo to next message
Eclipse UserFriend
I will log the requests.

I could not find versions of 2.8.4 by googling unfortunately. I think I have all the dependencies now but the mismatched versions don't generate anything.

I wonder if it will be feasible to provide curated standalone releases separate of the Eclipse release cycle for the runtimes of EMF + XMI + EMF util + XCore and IncQuery (perhaps even as single jars) ? Including simple build tool support ?

I can see this being quite fundamental for Xtext uptake in Intelij.
Re: Using Gradle to Generate XCore and IncQuery code [message #1711575 is a reply to message #1711420] Sat, 17 October 2015 12:17 Go to previous messageGo to next message
Eclipse UserFriend
Hi Hassan,

we already release everything necessary on Maven Central.

The problem is just the missing transitive dependencies, as noted in my earlier post. This needs to be fixed on our side/Xcore's side to avoid user inconvenience.

Cheers,
Stefan

[Updated on: Sat, 17 October 2015 12:19] by Moderator

Re: Using Gradle to Generate XCore and IncQuery code [message #1713247 is a reply to message #1711575] Mon, 02 November 2015 13:43 Go to previous messageGo to next message
Eclipse UserFriend
bug filed against xtext:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=481268

bug files against xcore:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=481270

Intelij plugin suggestion add a ui element that brings up popup listing runtime dependencies.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=481269

I hope we will have xcore support intelij soon Very Happy but headless mode would rock as well.

Re: Using Gradle to Generate XCore and IncQuery code [message #1713509 is a reply to message #1711227] Wed, 04 November 2015 12:10 Go to previous message
Eclipse UserFriend
> @Zoltan I see, for such a use case the Gradle plugin would need a hook for running additional setup. It runs in an isolated classloader, so doing the setups inside the Gradle build will not help. It would be great if you could elaborate on the use case a little in the issue tracker of the Gradle plugin https://github.com/xtext/xtext-gradle-plugin

Hi,

sorry for being slow, but I have opened https://github.com/xtext/xtext-gradle-plugin/issues/26

Cheers,
Zoltán
Previous Topic:java.lang.SecurityException during maven build
Next Topic:expandall icon
Goto Forum:
  


Current Time: Sat Aug 09 05:26:56 EDT 2025

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

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

Back to the top