-
Notifications
You must be signed in to change notification settings - Fork 1
Dependency Management
Epoch wraps the Lingua Franca code base in a plugin (org.lflang) to provide it in the Epoch IDE. That means dependencies used in the code and usually provided via the Gradle configuration must additionally be provided in the plugin environment.
Eclipse only uses inter-plugin dependencies that means each plugin declares its dependencies to other plugins (in MANIFEST.MF) proving certain code packages. Epoch further uses a managed target platform (two manually synchronized definition in the Oomph setup for the development IDE and the target platform bundle) that specifies which dependencies should be available.
Given the presence of the target platform, adding dependencies can have variable complexity.
- Open the MANIFEST.MF file.
- Click Add... and find and select the new dependency.
In most cases plugins have the same name as their provided packages (e.g.com.google.gson
forcom.google.gson.JsonObject
). - Only if your plugin is not available, you need to adjust the target platform before you can add your dependency.
- Open the oomph setup file and navigate to the Targetlet definition in the Main stream.
- Go to the DefaultRepositories element and select the URL of the P2 update site that provides the plugin you want to add to the list of available dependencies.
The most common plugins are available at the Eclipse update side or the Orbit drops. - If your update site is not yet listed you can add it. If your dependency is not available as a plugin (e.g. it is only published as library via Maven Central), you need to create a wrapper plugin to make your library available via our epoch-external-dependencies update site before you can proceed.
- Right-click on the update side entry and select Explore in the context menu. This will open the Repository Explorer view and list all the plugins/features that are provided.
- When you located your plugin, you can drag and drop the entry from the Repository Explorer into the oomph setup file.
- After saving the oomph setup file you need to update the target platform in your development IDE via Help -> Perform Setup Tasks.
- Finally, you need to add the new plugin to the target definition in the target platform module). E.g.:
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<unit id="com.google.inject" version="0.0.0"/>
<unit id="jakarta.activation" version="0.0.0"/>
<unit id="javax.activation" version="0.0.0"/>
<unit id="javaewah" version="0.0.0"/>
<unit id="com.google.gson" version="0.0.0"/>
<repository location="https://download.eclipse.org/tools/orbit/downloads/drops/R20230531010532/repository/"/>
</location>
- Now you can proceed with adding the dependency to the plugin manifest.
- Clone the epoch-external-dependencies repository.
- If you do not want to add a new dependency but update the version of an existing dependency, jump to step 6.
- Copy an existing dependency folder (e.g. org.lflang.epoch.mirror.kotlin)
- Replace the license file (e.g. kotlin.license.txt) with the one of the new dependency.
- Delete all jars in lib folder.
- Update the pom.xml
- Set the correct
artifactId
in the pom.xml. - Set the dependencies in the pom.xml to the dependency according to maven central.
- Set
version
based on maven central version. - Set
includeGroupIds
based on the group id from maven central.
- Update the reposiroty top-level pom.xml
- Add the
artifactId
for the new dependency as a module to the already existing ones.
- Update META-INF/MANIFEST.MF
- Adjust
Bundle-Name
,Symbolic-Name
,Bundle-Version
, andAutomatic-Module-Name
. - Delete
Bundle-Classpath
andExport-Package
.
- Run
maven package
in root.
- This will fail but enables further steps.
- The maven command will download the maven jar into the lib folder.
- In build.properties
- Add the jar from the lib folder to the
bin/includes
.
- Import the repository into your developer Eclipse.
- Open and update the MANIFEST.MF in Eclipse.
- Go to Runtime tab
- Click on Add in Classpath
- Add dependency jars from lib folder.
- Click on Add in Exported Packages.
- Select all packages and add them.
- Open and update
category.xml
inorg.lflang.epoch.external.dependencies.reporitory
- Add a new bundle for the dependencies
artifactId
.
- Run
maven package
again.
- This should not fail.
- Adjust top-level README
- Create a PR and push and commit changes.
- After merge to master, the automatic build will update the update site.
- An example of such an commit can be inspected here: https://github.com/lf-lang/epoch-external-dependencies/commit/9ff98bf686143e13e73c8c53bf5aea537bcda69e
- Now you can continue with Case 2 above and find your new dependency by exploring
https://lf-lang.github.io/epoch-external-dependencies
.
Adding dependencies to the pom file (e.g. like this one) will have no effect on the compilation of the LF code. These dependencies are only used in the code generation stage for the Xtext grammar. During compilation of the LF code in the plugin, only dependencies listed in the manifest file will be available.