Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Headless ANT build
Headless ANT build [message #930388] Tue, 02 October 2012 09:14 Go to next message
Boris Brodski is currently offline Boris BrodskiFriend
Messages: 112
Registered: July 2009
Senior Member
Hello,


is it possible to headless build a simple Xtext project with Ant (without eclipse and without Maven)?

Following:

<java classpathref="xtend-compiler" classname="org.eclipse.xtend.core.compiler.batch.Main" fork="true" failonerror="yes">
<arg value="-encoding"/>
<arg value="UTF-8"/>
<arg value="-d"/>
<arg value="ant/xtend-src"/>
<arg value="-cp"/>
<arg value="${libs}/org.eclipse.xtext_2.3.1.v201208210947.jar; ..."/>
<arg value="src-gen"/>
<arg value="src"/>
</java>


but it ends with an endless flow of exceptions starting with

[java] 0 ERROR AbstractClassMirror - resource is empty: java:/Objects/org.eclipse.xtext.generator.IGenerator
[java] 0 [main] ERROR org.eclipse.xtext.common.types.access.impl.AbstractClassMirror - resource is empty: java:/Objects/org.eclipse.xtext.generator.IGenerator
[java] 16 ERROR LazyLinkingResource - resolution of uriFragment 'xtextLink_::0.0.1::3::/2' failed.
[java] java.lang.IllegalStateException: Resource has not been loaded
[java] at org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider.findTypeByClass(ClasspathTypeProvider.java:128)
[java] at org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider.findTypeByName(ClasspathTypeProvider.java:82)
[java] at org.eclipse.xtext.common.types.xtext.AbstractTypeScope.getSingleElement(AbstractTypeScope.java:54)
[java] at org.eclipse.xtext.scoping.impl.AbstractScope.getSingleElement(AbstractScope.java:105)
[java] at org.eclipse.xtext.scoping.impl.AbstractScope.getSingleElement(AbstractScope.java:105)
[java] at org.eclipse.xtext.linking.impl.DefaultLinkingService.getLinkedObjects(DefaultLinkingService.java:121)
[java] at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:179)
[java] at org.eclipse.xtext.xbase.resource.XbaseResource.access$0(XbaseResource.java:1)
[java] at org.eclipse.xtext.xbase.resource.XbaseResource$2.exec(XbaseResource.java:239)
[java] at org.eclipse.xtext.xbase.resource.XbaseResource$2.exec(XbaseResource.java:1)
[java] at org.eclipse.xtext.util.OnChangeEvictingCache.execWithoutCacheClear(OnChangeEvictingCache.java:124)
[java] at org.eclipse.xtext.xbase.resource.XbaseResource.getEObject(XbaseResource.java:237)
[java] at org.eclipse.xtend.core.resource.XtendResource.getEObject(XtendResource.java:82)
[java] at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:219)
[java] at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:203)
[java] at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:263)
[java] at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eResolveProxy(BasicEObjectImpl.java:1483)
[java] at org.eclipse.xtend.core.xtend.impl.XtendImportImpl.getImportedType(XtendImportImpl.java:212)

....


Thank you!!

PS
It also look's like only the last source directory get considered by the Xtend compiler. The reverse sequence ('src' than 'src-gen') ends with


[java] 0 INFO XtendBatchCompiler - No sources to compile in 'src-gen'
[java] 0 [main] INFO org.eclipse.xtend.core.compiler.batch.XtendBatchCompiler - No sources to compile in 'src-gen'
Re: Headless ANT build [message #930503 is a reply to message #930388] Tue, 02 October 2012 11:32 Go to previous messageGo to next message
Dennis Huebner is currently offline Dennis HuebnerFriend
Messages: 257
Registered: July 2009
Senior Member

Hi Boris,
could you please attach your project as zip?

Thanks,
Dennis.



+Dennis Huebner

Get professional support from the Xtext committers at www.typefox.io
Re: Headless ANT build [message #930608 is a reply to message #930503] Tue, 02 October 2012 13:33 Go to previous messageGo to next message
Boris Brodski is currently offline Boris BrodskiFriend
Messages: 112
Registered: July 2009
Senior Member
The test project is in the headless-build-problem.zip.

Since only max. 2 MB files are allowed, I removed the eclipse plugins from the

org.xtext.example.mydsl/lib

directory. The jar files upon antlr generator were copied from the eclipse/plugins directory:

antlr-generator-3.2.0.jar
com.google.guava_10.0.1.v201203051515.jar
com.google.inject_3.0.0.v201203062045.jar
com.ibm.icu_4.4.2.v20110208.jar
javax.inject_1.0.0.v20091030.jar
org.antlr.runtime_3.2.0.v201101311130.jar
org.apache.commons.cli_1.2.0.v201105210650.jar
org.apache.commons.logging_1.0.4.v201101211617.jar
org.apache.log4j_1.2.15.v201012070815.jar
org.eclipse.emf.codegen.ecore_2.7.0.v20120130-0943.jar
org.eclipse.emf.codegen_2.6.0.v20120130-0943.jar
org.eclipse.emf.common_2.7.0.v20120127-1122.jar
org.eclipse.emf.ecore.xmi_2.7.0.v20120127-1122.jar
org.eclipse.emf.ecore_2.7.0.v20120127-1122.jar
org.eclipse.emf.mwe.core_1.2.1.v201206110920.jar
org.eclipse.emf.mwe.utils_1.2.1.v201206110920.jar
org.eclipse.emf.mwe2.language_2.3.0.v201206120758.jar
org.eclipse.emf.mwe2.launch_2.3.0.v201206120758.jar
org.eclipse.emf.mwe2.lib_2.3.0.v201206110920.jar
org.eclipse.emf.mwe2.runtime_2.3.0.v201206110920.jar
org.eclipse.jdt.core_3.7.0.v_B61.jar
org.eclipse.xpand_1.2.0.v201206110941.jar
org.eclipse.xtend.core_2.3.1.v201208210947.jar
org.eclipse.xtend.lib_2.3.1.v201208210947.jar
org.eclipse.xtend.typesystem.emf_1.2.0.v201206110941.jar
org.eclipse.xtend_1.2.0.v201206110941.jar
org.eclipse.xtext.common.types_2.3.1.v201208210947.jar
org.eclipse.xtext.generator_2.3.1.v201208210947.jar
org.eclipse.xtext.util_2.3.1.v201208210947.jar
org.eclipse.xtext.xbase.lib_2.3.1.v201208210947.jar
org.eclipse.xtext.xbase_2.3.1.v201208210947.jar
org.eclipse.xtext_2.3.1.v201208210947.jar

Versions:
- Eclipse
- Eclipse Java EE IDE for Web Developers.
- Version: Indigo Release
- Build id: 20110615-0604
- Xtext 2.3.1


My build.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="all">
<property name="workflow" value="src/org/xtext/example/mydsl/GenerateMyDsl.mwe2" />

<path id="wme2-classpath">
<fileset dir="lib" includes="*.jar" />
<pathelement location="src"/>
</path>

<path id="xtend-compiler-classpath">
<fileset dir="lib" includes="*.jar" />
</path>

<target name="compile">
<mkdir dir="ant" />
<mkdir dir="ant/xtend-src" />
<java classpathref="xtend-compiler-classpath" classname="org.eclipse.xtend.core.compiler.batch.Main" fork="true" failonerror="yes">
<arg value="-encoding" />
<arg value="UTF-8" />
<arg value="-d" />
<arg value="ant/xtend-src" />
<arg value="-cp" />
<arg value="lib/org.eclipse.xtext_2.3.1.v201208210947.jar" /> <!-- Here come more libraries -->
<arg value="src-gen" />
<arg value="src" />
</java>
</target>

<target name="run-workflow">
<java classpathref="wme2-classpath" classname="org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher" fork="true" failonerror="yes">
<jvmarg value="-Dfile.encoding=UTF-8" />
<arg value="${workflow}" />
</java>
</target>


<target name="all" depends="run-workflow,compile" description="Build all">

</target>


</project>

The single lib/org.eclipse.xtext_2.3.1.v201208210947.jar file on the Xtend compiler class path produces the exceptions.

Thank you for the help!
Re: Headless ANT build [message #930641 is a reply to message #930608] Tue, 02 October 2012 14:02 Go to previous messageGo to next message
Dennis Huebner is currently offline Dennis HuebnerFriend
Messages: 257
Registered: July 2009
Senior Member

Hi Boris,
first of all, you can use our standalone uber jar, it contains most of the needed eclipse stuff it's about 10 mb big.
Here is the latest SNAPSHOT: http://build.eclipse.org/common/xtend/maven/org/eclipse/xtend/org.eclipse.xtend.standalone/2.4.0-SNAPSHOT/

Second, class path entries have to be separated by the java.io.File.pathSeparatorChar char, the same is true for the last argument, which is the source folder/-s argument. In unix filesystems following works for me (I call the compile target directly without mwe2 stuff):

<arg value="lib/org.eclipse.xtext.xbase.lib_2.4.0.v201210011132.jar:lib/org.eclipse.xtend.standalone-2.4.0-20120828.110609-1.jar" />
<arg value="src-gen:src" />

Best regards,
Dennis.



+Dennis Huebner

Get professional support from the Xtext committers at www.typefox.io

[Updated on: Tue, 02 October 2012 14:03]

Report message to a moderator

Re: Headless ANT build [message #935228 is a reply to message #930388] Sat, 06 October 2012 20:52 Go to previous messageGo to next message
Boris Brodski is currently offline Boris BrodskiFriend
Messages: 112
Registered: July 2009
Senior Member
Hello Dennis,


thank you very much for the help. It works!
My problem was to understand, that the exception

- java.lang.IllegalStateException: Resource has not been loaded

just means, that the class can't be loaded, while some other required class isn't on the class path.

The tip with the "src:src-gen" was also very helpful.


Best Regards,
Boris Brodski

PS
I just recorded a screen cast (XtextCast) about building Xtext projects with Ant:
xtextcasts.org(SLASH)episodes/12-building-with-ant
Re: Headless ANT build [message #935243 is a reply to message #935228] Sat, 06 October 2012 21:11 Go to previous messageGo to next message
Boris Brodski is currently offline Boris BrodskiFriend
Messages: 112
Registered: July 2009
Senior Member
Hello Dennis,

Here is the URL again: http://xtextcasts.org/episodes/12-building-with-ant

Regards,
Boris

[Updated on: Sat, 06 October 2012 21:12]

Report message to a moderator

Re: Headless ANT build [message #1265182 is a reply to message #935243] Wed, 05 March 2014 19:56 Go to previous message
raju ak is currently offline raju akFriend
Messages: 15
Registered: October 2013
Junior Member
Hi Brodski,

I Need small help, the headless build we can run easily if it is in the current working directory, lets assume if i want to run my build file out of that particular directory can you just point me where exactly i need to change the paths( I was bit confused while doing that) your help is appreciated. Here is the folder structure of my project

sample(folder)--
|- org.xtext.sample
|- org.xtext.sample.ui
|- org.xtext.sample.sdk and test project
|- build.xml
I have written the build.xml file out side the Xtext project that means in the sample folder. so i am not very sure where to change this things.

Thanks.
Previous Topic:How to complete code using ctrl-space
Next Topic:[Xtend2] for non xtext model
Goto Forum:
  


Current Time: Fri Mar 29 01:27:18 GMT 2024

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

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

Back to the top