[Git][java-team/eclipse-debian-helper][master] Generate the Declarative Services descriptors from the annotations

Emmanuel Bourg (@ebourg) gitlab at salsa.debian.org
Wed Nov 25 14:32:48 GMT 2026



Emmanuel Bourg pushed to branch master at Debian Java Maintainers / eclipse-debian-helper


Commits:
0e9d2975 by Emmanuel Bourg at 2026-11-25T15:32:06+01:00
Generate the Declarative Services descriptors from the annotations

- - - - -


3 changed files:

- debian/changelog
- debian/control
- src/ant/build-eclipse-bundle.xml


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+eclipse-debian-helper (1.14) unstable; urgency=medium
+
+  * Generate the Declarative Services descriptors from the annotations
+
+ -- Emmanuel Bourg <ebourg at apache.org>  Wed, 25 Nov 2026 15:31:56 +0100
+
 eclipse-debian-helper (1.13) unstable; urgency=medium
 
   * Default to the Java release required by the bundle manifest


=====================================
debian/control
=====================================
@@ -14,6 +14,7 @@ Architecture: all
 Depends:
  ant,
  ant-contrib,
+ bnd,
  maven-repo-helper,
  default-jdk-headless | default-jdk,
  ${misc:Depends}


=====================================
src/ant/build-eclipse-bundle.xml
=====================================
@@ -65,14 +65,14 @@
           </copy>
 
           <!-- Compile the source files to target/classes -->
-          <javac srcdir="${bundle.dir.@{name}}/target/sources" destdir="${bundle.dir.@{name}}/target/classes" debug="yes" release="${bundle.release.@{name}}" includeantruntime="false" encoding="@{encoding}">
-            <classpath>
-              <fileset dir="." includesfile="${bundle.dir.@{name}}/target/dependencies"/>
-              <bundle-classpath/>
-              <pathelement path="/usr/share/java/eclipse-osgi.jar"/>
-              <pathelement path="/usr/share/java/org.eclipse.osgi.jar"/>
-              <pathelement path="/usr/share/java/osgi.compendium.jar"/>
-            </classpath>
+          <path id="classpath.@{name}">
+            <fileset dir="." includesfile="${bundle.dir.@{name}}/target/dependencies"/>
+            <bundle-classpath/>
+            <pathelement path="/usr/share/java/eclipse-osgi.jar"/>
+            <pathelement path="/usr/share/java/org.eclipse.osgi.jar"/>
+            <pathelement path="/usr/share/java/osgi.compendium.jar"/>
+          </path>
+          <javac srcdir="${bundle.dir.@{name}}/target/sources" destdir="${bundle.dir.@{name}}/target/classes" debug="yes" release="${bundle.release.@{name}}" includeantruntime="false" encoding="@{encoding}" classpathref="classpath.@{name}">
             <compilerarg line="@{compilerargs}"/>
           </javac>
 
@@ -82,6 +82,9 @@
             <fileset dir="${bundle.dir.@{name}}" includes="${@{name}.bin.includes}"/>
           </copy>
 
+          <!-- Generate the Declarative Services descriptors missing from the resources -->
+          <bundle-ds name="@{name}" basedir="@{basedir}" classpathref="classpath.@{name}"/>
+
           <!-- Create the jar -->
           <replace file="${bundle.dir.@{name}}/target/classes/META-INF/MANIFEST.MF" token="%pluginName"   value="${@{name}.pluginName}"/>
           <replace file="${bundle.dir.@{name}}/target/classes/META-INF/MANIFEST.MF" token="%bundleName"   value="${@{name}.bundleName}"/>
@@ -182,4 +185,39 @@
     </sequential>
   </macrodef>
 
+  <!-- Macro generating the Declarative Services descriptors (OSGI-INF/*.xml) from the annotations of the compiled classes, if the manifest declares a Service-Component. The descriptors already present are kept -->
+  <macrodef name="bundle-ds">
+    <attribute name="name" description="The name of the bundle (for example org.eclipse.foo.bar)"/>
+    <attribute name="basedir" default="bundles"/>
+    <attribute name="classpathref" description="The reference of the classpath used to compile the bundle"/>
+    <sequential>
+      <property file="@{basedir}/@{name}/META-INF/MANIFEST.MF" prefix="manifest.@{name}"/>
+      <if>
+        <isset property="manifest.@{name}.Service-Component"/>
+        <then>
+          <property name="ds.target.@{name}" location="@{basedir}/@{name}/target"/>
+          <pathconvert property="ds.classpath.@{name}" pathsep=",">
+            <restrict>
+              <path refid="@{classpathref}"/>
+              <exists/>
+            </restrict>
+          </pathconvert>
+          <echo file="${ds.target.@{name}}/ds.bnd">-includeresource: ${ds.target.@{name}}/classes${line.separator}-classpath: ${ds.classpath.@{name}}${line.separator}-dsannotations: *${line.separator}</echo>
+          <java jar="/usr/share/java/bnd.jar" fork="true" failonerror="true" dir="${ds.target.@{name}}">
+            <arg line="buildx -o ds.jar ds.bnd"/>
+          </java>
+          <mkdir dir="${ds.target.@{name}}/ds"/>
+          <unzip src="${ds.target.@{name}}/ds.jar" dest="${ds.target.@{name}}/ds">
+            <patternset includes="OSGI-INF/*.xml"/>
+          </unzip>
+          <copy todir="${ds.target.@{name}}/classes">
+            <fileset dir="${ds.target.@{name}}/ds">
+              <present present="srconly" targetdir="${ds.target.@{name}}/classes"/>
+            </fileset>
+          </copy>
+        </then>
+      </if>
+    </sequential>
+  </macrodef>
+
 </project>



View it on GitLab: https://salsa.debian.org/java-team/eclipse-debian-helper/-/commit/0e9d29754d9ad8e18c90143802e4c4ff0e5920e5

-- 
View it on GitLab: https://salsa.debian.org/java-team/eclipse-debian-helper/-/commit/0e9d29754d9ad8e18c90143802e4c4ff0e5920e5
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20261125/e90504c7/attachment.htm>


More information about the pkg-java-commits mailing list