Page tree
Skip to end of metadata
Go to start of metadata

This page covers miscellaneous topics about configuring the Eclipse IDE for work with Daffodil (or generally).

General

To develop on Daffodil using Eclipse, you will need Eclipse with the Scala IDE add-ins. The ScalaIDE add-ins are not being maintained however (as of 2021-02-01), and latest version of them is from 2018. However, the ScalaIDE does still work quite well with Daffodil.

  • Downloading the entire ScalaIDE 4.7 (pre-built) works reliably.
  • Loading the ScalaIDE from the update site has been unreliable at creating a real working environment.
    • Specifically: Eclipse 20-12 does not  work with the ScalaIDE update site for ScalaIDE 4.7.

You will need the Java SDK (not just the JRE), and Daffodil requires Java 8 (aka 1.8) at least.

The ScalaIDE 4.7 also requires Java 8 (not newer), so Java 8 JDK is a hard requirement.

  • If you are also using other JVM versions or want the default Java to be a newer one, then you can setup the eclipse.ini for ScalaIDE to specifically always use the Java 8 installation.

Setup Eclipse Projects

For Daffodil 3.0.0 and older:

  1. Enable the sbt ecilpse plugin by create the file ~/.sbt/1.0/plugins/plugins.sbt  with the following content

    plugins.sbt
    addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")
  2. Set the DAFFODIL_HOME environment variable to the directory where you have Daffodil checked out. You can run the following, or put it in configureation file like ~/.bashrc

    export DAFFODIL_HOME="/path/to/daffodil.git"
  3. Run the following sbt command to generate eclipse project files:

    sbt updateClassifiers compile eclipse updateEclipseClasspaths

For Daffodil 3.1.0 and newer:

  1. Run the following sbt command to generate eclipse project files:

    sbt updateClassifiers compile eclipse

For all Daffodil versions:

The above will create an Eclipse .project, .classpath and .settings within each sub-project.

Then in Eclipse...

  1. First turn off automatic build
    1. Project menu at top, ensure "Build Automatically" is unchecked.
  2. Import all the daffodil projects
    1. File -> Import, Projects from Git, Existing local repository,
    2. select the daffodil directory -> next -> Import existing Eclipse projects -> Next.
    3. All projects should be pre-selected for you. -> Next.
    4. You should now have a collection of project folders displayed in the package explorer.
  3. Fix daffodil-lib (This may be unnecessary. Check it, but 'sbt eclipse' seems to set this up properly.)
    1. resource_managed/main folder: right-click Build-Path → add as source folder.
    2. src_managed/main folder also add as source folder
  4. Fix daffodil-japi: Edit daffodil-japi/.settings/org.scala-ide.sdt.core.prefs
    1. Delete the line that begins with "XPlugin="
    2. Delete the line that begins with "P="
  5. Select and refresh all projects.

You can now build all projects, and run tests in the ordinary Eclipse way.

See the note below about "pre-build with sbt".

Line Endings

Setup Eclipse for "Unix" style line endings - single LF characters, not MS-DOS style CRLF endings.

Pre-build with sbt to Retrieve Libraries

Before starting Eclipse, you must issue the 'sbt updateClassifiers compile' command. This pulls down all libraries needed, and puts them into lib_managed where the eclipse projects are setup to find them. This also pulls down all the source and javadoc jars for convenient access. The compile command forces some code-generator steps to run which create source code in the daffodil-lib module.

This 'sbt updateClassifiers compile' must be repeated any time the daffodil-propgen module is changed.


Eclipse Settings for DFDL Schema Authoring/Editing

The Eclipse IDE can be used to assist a user in the authoring of DFDL schemas.

DFDL extends a subset of XML Schema. Note however: an XML Schema is an XML document.

There are XML-Schema-Aware editors. So, if you have an editor that is aware of the XML Schema of an XML document, then that editor can provide intelligent assistance in authoring the XML document. It can show you the XML source code, or can show you diagrammatic ways of examining the document.

Now, turns out there is an XML Schema for DFDL Schemas. It was created by taking the XML Schema for XML Schemas, and subsetting it to just what DFDL uses, and then adding into it the XML Schema for DFDL's annotation objects.

Since there is an XML Schema for the XML Documents that just happen to be DFDL Schemas, an XML aware editor can provide assistance in authoring DFDL Schemas.

This section contains instructions for setting up the Eclipse Integrated-Development-Environment (IDE), and to configure it's XML editing features so that they provide some level of support for authoring DFDL schemas. In theory, based on this, if you have some other favorite XML-Schema-Aware editing environment, you could figure out how to enable it to provide you similar DFDL schema authoring assistance.

The XML settings all assume you have installed Eclipse's XML support. Given an Eclipse update site for your version of Eclipse, the  "Eclipse XML Editors and Tools" software is what you need, and what this page is referring to for XML settings.

(Caveat: The menu locations often vary from one Eclipse release to the next.)

Following are steps to modify the eclipse XML settings to aid in the creation of DFDL schemas:

  1. Window > Preferences > Validation
    1. turn off XML Schema Validator
    2. turn off DTD Validator and HTML Validator
    3. click the ... settings box to the right of XML Validator
      1. Select Include Group
      2. Click Add Rule
      3. Select File Extension
      4. Click Next
      5. Add extensions tdml
      6. Click Finish
      7. Repeat steps i-vi, replacing tdml with dfdl.xsd
  2. Window > Preferences > General > Content Types
    1. Select Text > XML
    2. Click Add...
    3. Set Content type to *.dfdl.xsd
    4. Repeat steps b-c with content type set to *.tdml
  3. Window > Preferences > XML > XML Files > Editor
    1. Uncheck Format comments
  4. File > Import > XML > XML Catalog
    1. Choose daffodil-lib/src/main/resources/eclipse-xml-catalog.xml

Graphics Problems on Linux/Fedora

 See content...

The problems I was having:

Windows/buttons/bars missing.

Frequent errors to where it would state something about SWT and recommend restarting Eclipse.

Window would go black and render Eclipse unusable until you quit and restart it.

Odd additional "DragPlaceholder" tabs added each and every time Eclipse would crash.

Below is the fix.

Whatever you use to execute eclipse, you have to add the following statement: export SWT_GTK3=0

https://bugs.eclipse.org/bugs/show_bug.cgi?id=497705

I added that export line to the script I use to launch my Eclipse and it fixed all of my issues.

You have the choice of either adding it to your /usr/share/applications eclipse.desktop file:

Exec=env SWT_GTK3=0 /bin/eclipse

Or adding it to whatever script you use to launch eclipse, which in my case is:

#!/bin/bash

export ECLIPSE_HOME="/home/username/Programs/eclipse"

export SWT_GTK3=0

$ECLIPSE_HOME/eclipse $*

I'd tried adding the '-Dswt.enable.autoScale=false' line to my eclipse.ini file and that didn't do anything, thus I resorted to altering the script above.

  • No labels

2 Comments

  1. Why does sbt call the library-updating command "updateClassifiers"? In what way is a library a "classifier" ??

    1. The sbt library updating command is actually just "update". Running that will download library dependency jars and store them in lib_managed. This is all that is actually needed to get the necessary dependencies for compiling with eclipse.

      "Classifiers" are maven's way of distinguishing between different content built from the same source. The classifier jars are just a keyword at the end of a jar, e.g. foo-1.0.0-classifier.jar. The most common examples of these are "javadocs" and "sources" classifiers. In addition to downloading the standard jars, running the "updateClassifiers" command will also download the "javadocs" and "sources" jars to lib_managed, which eclipse can use when debugging and stepping through code. If you do not plan to debug and step through code, you only need to run "sbt update".