The second edition of the Xtext book has been published

The second edition of the Xtext book, Implementing Domain-Specific Languages with Xtext and Xtend, was published at the end of August: https://www.packtpub.com/web-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition. So… get it while it’s hot 🙂

4965OS_5541_Implementing Domain Specific Languages with Xtext and Xtend - Second Edition

Please, see my previous post for details about the novelties in this edition.

Sources of the examples are on github: https://github.com/LorenzoBettini/packtpub-xtext-book-2nd-examples.

Hope you’ll enjoy the book!

4 thoughts on “The second edition of the Xtext book has been published

  1. Uli

    Hello Mr. Bettini, I bought your book and read it and now I have a question, hoping you can help me. I’m not getting something in chapter “Providing a library”. As you may guess, I want to provide a standard library to my users, and I want it to ship with my Plugin. I understand what the book says until this point: “Now, if we run Eclipse, create a project and add as dependency our org.example.smalljava project, the classes of mainlib.smalljava will be automatically available.” …

    By “if we run eclipse” I think you mean an Eclipse instance that has my plugin loaded.
    By “add as dependency our org.example.smalljava” I think you mean right click the new project and select “Project References” and check the box at the plugin project. For this to work, the user would need to have a copy of the plugin project in his workspace, right? I think this is a major drawback of the approach, since typically this would not be the case? Since you’re not mentioning it, I’m wondering whether I misunderstood something.

    Thank you.

    Reply
    1. Lorenzo Bettini Post author

      Uli, the dependencies are meant to be added as any other dependencies described in the book: using the MANIFEST.MF and adding the corresponding bundle (plug-in).
      All the projects are Eclipse plug-ins after all.
      If you create an update site for your DSL, the library plug-in must be made available in the update site as well (the easiest way to do that is by adding it to the feature of your DSL – features and update sites are explained in a later chapter), so that it will be installed by your users. Moreover, in the example of the book there’s no separate plug-in for the library, the library code is included in the DSL main plug-in, so that you don’t have to configure your features explicitly.

      In the end, these concepts are related to Eclipse plug-ins and are not really related to Xtext.

      “Now, if we run Eclipse, create a project and add as dependency our org.example.smalljava project” means create an plug-in project and add to the MANIFEST.MF the bundle (plug-in) org.example.smalljava as a dependency.

      Does that clarify your doubts?
      cheers
      Lorenzo

      Reply
      1. Uli

        Hi Lorenzo,

        I really appreciate your support. I am no expert in Eclipse, that is true, but looking into it ;-). But my problem persists. This is my situation:
        Everything works perfectly with the standalone compiler. I have the library loaded and all is fine.
        In Eclipse though, it does not work. I figured maybe it was a problem that my language was not using packages or imports. I added that to the language, and the imports work as expected, I can import from other files in the same project, from other projects in the same workspace (if I make them depending on each other), all is wonderful. Also, I did the following: In the runtime eclipse, I created a Java project that has the bin folder of my xtext development eclipse as an “external class folder”. In the Java program, I use the classloader to resolve my dsl file and it can find it easily. I did the same with an exported plugin jar I created from my DSLand also that works. I checked the manifest and
        ->The file IS present.
        ->I can find it if I search with the classloader “manually” from within the runtime eclipse
        ->I fail to make xtext find it (or I fail to make xtext search it, not sure)
        In your book it says “the classes of our library are indexed and available in SmallJava Programs”. I think this is what is NOT happening, although the file exists and is visible.
        I wonder how exactly that magic should be happening. Which code is responsible for “finding my library file and “index it” and “make it available”. I guess it would only be “lazily” during resolving that the plugin will be searched for my dsl file?

        I keep digging. If anything comes to your mind in addition, I’ll be happy to hear it.

        Thank you,

        Uli

        Reply
        1. Lorenzo Bettini Post author

          Uli, don’t play with plain Java projects, project dependencies, external class folders and classloading… please, stick to Eclipse plug-in projects and its dependencies and everything works out of the box.

          Reply

Leave a Reply to UliCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.