Skip to content

Commit

Permalink
infra: convert nested libs to wrapped OSGi bundles
Browse files Browse the repository at this point in the history
EclipseCS uses several external libraries, which are copied manually
into the libs folder. Since everything else comes from the Eclipse
target platform, those 3 libraries are easier to maintain by fetching
them directly from maven and letting Eclipse PDE automatically wrap them
into OSGi bundles.

With that change in place, updating the external libraries is as easy as
changing the version number in the .target file.

Also improve the documentation how to maintain the target platform,
required plugins etc.
  • Loading branch information
Bananeweizen committed Nov 16, 2022
1 parent 538e4a7 commit 99874c2
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 48 deletions.
9 changes: 5 additions & 4 deletions net.sf.eclipsecs.core/.classpath
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
<accessrules>
<accessrule kind="accessible" pattern="com/puppycrawl/tools/checkstyle/meta/**"/>
</accessrules>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="lib/dom4j-2.1.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/snakeyaml-1.33.jar"/>
<classpathentry exported="true" kind="lib" path="lib/javassist-3.28.0-GA.jar"/>
<classpathentry kind="lib" path="lib/checkstyle-10.4-all.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
10 changes: 5 additions & 5 deletions net.sf.eclipsecs.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ Bundle-SymbolicName: net.sf.eclipsecs.core;singleton:=true
Bundle-Version: 10.4.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-ClassPath: .,
lib/dom4j-2.1.3.jar,
lib/snakeyaml-1.33.jar,
lib/javassist-3.28.0-GA.jar,
lib/checkstyle-10.4-all.jar
Bundle-Activator: net.sf.eclipsecs.core.CheckstylePlugin
Bundle-ActivationPolicy: lazy
Expand All @@ -25,7 +22,9 @@ Export-Package: net.sf.eclipsecs.core,
net.sf.eclipsecs.core.projectconfig,
net.sf.eclipsecs.core.projectconfig.filters,
net.sf.eclipsecs.core.util
Import-Package: org.eclipse.core.filebuffers,
Import-Package: org.dom4j;version="2.1.3",
org.dom4j.io;version="2.1.3",
org.eclipse.core.filebuffers,
org.eclipse.core.resources,
org.eclipse.core.runtime,
org.eclipse.core.runtime.jobs,
Expand All @@ -42,6 +41,7 @@ Import-Package: org.eclipse.core.filebuffers,
org.eclipse.team.core.subscribers;resolution:=optional,
org.eclipse.team.core.synchronize;resolution:=optional,
org.osgi.framework,
org.osgi.service.prefs
org.osgi.service.prefs,
org.yaml.snakeyaml;version="1.33.0"
Automatic-Module-Name: net.sf.eclipsecs.core

3 changes: 0 additions & 3 deletions net.sf.eclipsecs.core/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ bin.includes = .,\
plugin.xml,\
schema/,\
core.properties,\
lib/dom4j-2.1.3.jar,\
lib/snakeyaml-1.33.jar,\
lib/checkstyle-10.4-all.jar

source.. = src/
javacDefaultEncoding.. = UTF-8

Binary file removed net.sf.eclipsecs.core/lib/dom4j-2.1.3.jar
Binary file not shown.
Binary file removed net.sf.eclipsecs.core/lib/javassist-3.28.0-GA.jar
Binary file not shown.
Binary file removed net.sf.eclipsecs.core/lib/snakeyaml-1.33.jar
Binary file not shown.
25 changes: 25 additions & 0 deletions net.sf.eclipsecs.target/net.sf.eclipsecs.partial.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
<target name="Eclipse Checkstyle (Eclipse Plugins)" sequenceNumber="1668583180">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jdt.feature.group" version="3.18.500.v20200902-1800"/>
<unit id="org.eclipse.sdk.ide" version="4.17.0.I20200902-1800"/>
<unit id="org.eclipse.emf.feature.group" version="2.23.0.v20200822-0801"/>
<repository location="https://download.eclipse.org/releases/2020-09/202009161000/"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.junit.jupiter.api" version="5.6.0.v20200203-2009"/>
<unit id="org.junit.jupiter.engine" version="5.6.0.v20200203-2009"/>
<unit id="org.junit.jupiter.params" version="5.6.0.v20200203-2009"/>
<unit id="org.junit.platform.commons" version="1.6.0.v20200203-2009"/>
<unit id="org.junit.platform.engine" version="1.6.0.v20200203-2009"/>
<unit id="org.junit.platform.launcher" version="1.6.0.v20200203-2009"/>
<unit id="org.junit.platform.runner" version="1.6.0.v20200203-2009"/>
<unit id="org.junit.platform.suite.api" version="1.6.0.v20200203-2009"/>
<repository location="https://download.eclipse.org/tools/orbit/downloads/drops/R20200831200620/repository"/>
</location>
</locations>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
</target>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Install https://download.eclipse.org/cbi/tpd/3.0.0-SNAPSHOT/ to use this target definition.
// Read https://github.com/eclipse-cbi/targetplatform-dsl for more details.
target "Eclipse Checkstyle"
target "Eclipse Checkstyle (Eclipse Plugins)"
with source configurePhase
environment JavaSE-11

Expand Down
49 changes: 27 additions & 22 deletions net.sf.eclipsecs.target/net.sf.eclipsecs.target.target
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
<target name="Eclipse Checkstyle" sequenceNumber="1653761205">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jdt.feature.group" version="3.18.500.v20200902-1800"/>
<unit id="org.eclipse.sdk.ide" version="4.17.0.I20200902-1800"/>
<unit id="org.eclipse.emf.feature.group" version="2.23.0.v20200822-0801"/>
<repository location="https://download.eclipse.org/releases/2020-09/202009161000/"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.junit.jupiter.api" version="5.6.0.v20200203-2009"/>
<unit id="org.junit.jupiter.engine" version="5.6.0.v20200203-2009"/>
<unit id="org.junit.jupiter.params" version="5.6.0.v20200203-2009"/>
<unit id="org.junit.platform.commons" version="1.6.0.v20200203-2009"/>
<unit id="org.junit.platform.engine" version="1.6.0.v20200203-2009"/>
<unit id="org.junit.platform.launcher" version="1.6.0.v20200203-2009"/>
<unit id="org.junit.platform.runner" version="1.6.0.v20200203-2009"/>
<unit id="org.junit.platform.suite.api" version="1.6.0.v20200203-2009"/>
<repository location="https://download.eclipse.org/tools/orbit/downloads/drops/R20200831200620/repository"/>
</location>
</locations>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
</target>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<locations>
<location type="Target" uri="file:${project_loc:/net.sf.eclipsecs.core}/../net.sf.eclipsecs.target/net.sf.eclipsecs.partial.target"/>
<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="generate" type="Maven">
<dependencies>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.3</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.29.2-GA</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.33</version>
<type>jar</type>
</dependency>
</dependencies>
</location>
</locations>
</target>
53 changes: 40 additions & 13 deletions net.sf.eclipsecs.target/readme.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,54 @@
## What's this?

The .target file describes the minimum eclipse environment that eclipse-cs runs in.
The `.target` file describes the minimum Eclipse environment that eclipse-cs runs in.
Right now that is 2020-09 (since that is the first version officially running on Java 11).


## Preconditions for development

To use the target platform, these plugins must be installed in your Eclipse IDE:
* [Eclipse M2E](https://marketplace.eclipse.org/content/eclipse-m2e-maven-support-eclipse-ide)
* [Target Platform DSL](https://github.com/eclipse-cbi/targetplatform-dsl)


## How to use the target platform

In the Maven build it is used automatically for compilation
(see target-platform-configuration section in the parent POM).

For development in Eclipse you have to load it manually, but only one time:
Open the .target file and use the "Set As Active Target" hyperlink. This may take
a while the first time, since plugins are loaded from the Internet.
For development in Eclipse you have to load it manually, but only after it has been modified.
Open the `net.sf.eclipsecs.target.target` file and use the "Set As Active Target" hyperlink.
This may take a while the first time, since plugins are loaded from the Internet.

If you don't do that, the compilation happens against the Eclipse plugins of your IDE
and you may call methods that don't exist in earlier versions,
which will lead to runtime errors for end users that are still on an old Eclipse version.

If you don't do that, the compilation happens against the eclipse plugins of
your IDE and you may call methods that don't exist in earlier versions, which
will lead to runtime errors for end users.

## How to update the target platform

Target files are hard to maintain manually. Therefore we use a custom DSL to
maintain the target platform, and to derive the .target file.
Target files are hard to maintain manually.
Therefore we use a custom DSL to maintain most of the target platform, and to derive the `.target` file.
However, that DSL based generation is not possible for the part of the target platform that shall include Maven coordinates.
That's why the target platform is split over 2 files.
The root target platform contains only the Maven coordinates and can be edited manually.
It also includes a nested target file, which is generated from the target platform DSL.
While that structure may look confusing at first glance, it simplifies the actual editing a lot,
because you either only edit Maven coordinates or entries in the `.tpd`file.

### Eclipse plugins

Edit the `net.sf.eclipsecs.partial.tpd` file (note the _partial_ in the name).
After saving use the context menu of the .tpd file to create a new version of the `net.sf.eclipsecs.partial.target` file.

### Maven libraries

Meanwhile Eclipse PDE and Tycho can also use Maven libraries directly in the target platform
(by automatically wrapping them into a generated OSGi bundle).
Those libraries are contained in `net.sf.eclipsecs.target.target`.
You can open that with a text editor and edit the Maven coordinates like in a `pom.xml`.


Install https://github.com/eclipse-cbi/targetplatform-dsl to edit the .tpd
file. After saving use the context menu of the .tpd file to create a new
version of the .target file.
## Committing changes

Both the .target and .tpd files must be checked in after changes.
Both the `.target` and `.tpd` files must be checked in after changes.

0 comments on commit 99874c2

Please sign in to comment.