Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Building Standalone Compiler with Maven - My Method No Longer Works
Building Standalone Compiler with Maven - My Method No Longer Works [message #1850515] Mon, 07 March 2022 13:58 Go to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
This seems like a topic that everyone must deal with, but there's not many examples (I guess it's a Maven thing.. but since most of us must deal with it at some point....)

For years now I've been building my standalone compiler jars using a method based on Lorenzo Bettini's method documented here:

https://github.com/LorenzoBettini/packtpub-xtext-book-2nd-examples/blob/master/org.example.smalljava.parent/org.example.smalljava/pom.xml

For whatever reason, and I can't figure it out after days of cursing at it, it no longer works and builds a jar with a blank org.eclipse.emf.common jar and nothing works anymore (the emf.common jar has no classes and just a manifest file - I suspect the maven shade plugin is causing me grief, but I have no idea how it works (it's used in building the LSP in the ide plugin).

Every single plugin, eclipse version, tycho version, etc, has changed and all xtext example poms are all slightly different and I can't detect what in the world is going wrong. But it's dead for me and I'm too dumb to figure it out.

So I'm stuck manually exporting my jar from Eclipse - which works.


So I've started looking for another way. I stumbled upon this:

https://github.com/basilfx/xtext-standalone-maven-build

it seems very straightforward and simple, but unfortunately it is not working. (it appears to be 5 years old and based on xtext 2.12, so who knows...)

When I launch the resulting jar with java - jar <the jar>, it can find my Main class - which is the _entire point_.

I've seen some other xtext projects in github using the later method, so it works for some people.

Yes, my Main.class is in the resulting jar, but the JarRsrcLoader can't seem to find it.

Anyone using this later method with success?
Re: Building Standalone Compiler with Maven - My Method No Longer Works [message #1850527 is a reply to message #1850515] Mon, 07 March 2022 15:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14738
Registered: July 2009
Senior Member
hi,
can you describe "what" is not working? did you remote debug into it?
did you check what the new project wizard creates when you select lsp fat jar?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Building Standalone Compiler with Maven - My Method No Longer Works [message #1850867 is a reply to message #1850527] Sun, 20 March 2022 00:27 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Christian Dietrich wrote on Mon, 07 March 2022 10:28
hi,
can you describe "what" is not working? did you remote debug into it?


My method that had been working for years:

https://github.com/LorenzoBettini/packtpub-xtext-book-2nd-examples/blob/master/org.example.smalljava.parent/org.example.smalljava/pom.xml

For some unexplained reason, the maven-dependency-plugin copies the org.emf.common.2.19 plugin into the resulting jar - but it doesn't copy ANY of it's classes. Instead of a 367KB emf.common jar in my fatjar, I get a 19KB jar that has a manifest, but it has ZERO classes.

The command line compiler immediately exceptions because it can't find "common emf" stuff. I've spent hours/days cursing at Maven but I can't get it to copy this particular JAR (there may be more it's messing up, but I can't even start).

maven-dependency-plugin just seems to not be doing what it's supposed to do? I can't explain it because it's a "magic maven thing". I have debugged it to show that the copy of the emf.common jar the maven-dependency-plugin copies into the lib jar is messed up and incomplete.

Quote:

did you check what the new project wizard creates when you select lsp fat jar?


I've looked at it, but I don't understand it. I understand it's building the jar for the LSP, but I don't see anything familiar with specific my Main class and specifying what the compile jar's name looks like. I'm pretty lost on it.


This other method, new to me but fairly old:

https://github.com/basilfx/xtext-standalone-maven-build

Appears to run smoothy. Appears to copy everything it needs, Appears to build a proper manifest file in the fat jar... then when I run it, Java says it can't find the Main class - even though I clearly see it in the manifest's listed classpath and the class lives at that location in the jar.

It's weird, it's such a fundamental failure, but it all looks setup correctly to me.

I don't know how to remote debug unfortunately, I've always used Eclipse's debugger.

[Updated on: Sun, 20 March 2022 00:39]

Report message to a moderator

Re: Building Standalone Compiler with Maven - My Method No Longer Works [message #1850873 is a reply to message #1850867] Sun, 20 March 2022 08:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14738
Registered: July 2009
Senior Member
Did you triple check that you don't have bad stuff in local maven repo eg by using a dedicated one with -Dmaven.repo.local=somedir

Also: are these p2 deps or maven deps
Also: do you use the Xtext-dev-bom


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Sun, 20 March 2022 08:56]

Report message to a moderator

Re: Building Standalone Compiler with Maven - My Method No Longer Works [message #1853627 is a reply to message #1850515] Mon, 11 July 2022 19:05 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
For posterity, recording my solution.

This took me a very long time to debug. I still don't understand why it was happening, but it's now fixed.

When I upgrade my Eclipse to 2021-06 and moved to Java11, I also had a side effect that my surefire regressions would not launch. I tracked that down a fight between my 2021-06 eclipse targets needing at least tycho 2.1.0 (or I had to pick some other Eclipse version - any Eclipse version except 2021-06 worked).

While fixing the surefire issue, I noticed that my jar dependencies in my standalone app would change content depending on what my Eclipse version was in my target. For emf.common and emf.ecore, depending on the Eclipse version in the target, I would full content in the resulting standalone jar-in-jar or no content (a nearly blank jar directory with a MANIFEST and no classes)

Comparing my pom.xml from my dsl project alongside the dsl.ide pom.xml (that is building an uber jar for the LSP), I detected some differences in the configuration of the maven-dependency-plugin.

Basically the configuration from the Xtext Second Edition book - which has worked for years (5 maybe):

      <plugin>
        <!-- copy dependencies to build the standalone fatjar -->
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <outputDirectory>${dir.lib}</outputDirectory>
              <excludeTransitive>true</excludeTransitive>
              <addParentPoms>false</addParentPoms>
              <excludeScope>provided</excludeScope>
            </configuration>
          </execution>
        </executions>
      </plugin>   


was replaced with the configuration options I gathered from my dsl.ide pom.xml:

      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>target-platform-configuration</artifactId>
        <configuration>
          <pomDependencies>consider</pomDependencies>
        </configuration>
      </plugin>     
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.1.1</version>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <excludeGroupIds>p2.eclipse-feature</excludeGroupIds>
              <outputDirectory>${dir.lib}</outputDirectory>
              <overWriteReleases>false</overWriteReleases>
              <overWriteSnapshots>false</overWriteSnapshots>
              <overWriteIfNewer>true</overWriteIfNewer>
              <excludeTransitive>true</excludeTransitive>
            </configuration>
          </execution>
        </executions>
      </plugin>  


I did keep the tycho-platform-configuration to be "safer" although I'm not sure if it is critical.
Re: Building Standalone Compiler with Maven - My Method No Longer Works [message #1853631 is a reply to message #1853627] Mon, 11 July 2022 19:22 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14738
Registered: July 2009
Senior Member
Have no idea on what. No exceptions warnings etc in debug log ?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Previous Topic:Can I use multiple xtext files
Next Topic:Registering files needed by a dsl for Unit tests
Goto Forum:
  


Current Time: Sun Dec 22 06:19:52 GMT 2024

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

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

Back to the top