Skip to content

Commit

Permalink
Merge pull request #1494 from matthiasblaesing/pr-1492
Browse files Browse the repository at this point in the history
Add 'uses' information to OSGI metadata in MANIFEST.MF
  • Loading branch information
matthiasblaesing authored Jan 9, 2023
2 parents 780facd + 1af6eb1 commit a5f47cd
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Features
* [#1482](https://github.com/java-native-access/jna/pull/1482): Add multilingual support of `Kernel32Util.formatMessage` - [@overpathz](https://github.com/overpathz).
* [#1490](https://github.com/java-native-access/jna/pull/1490): Adds support for a custom `SymbolProvider` in `NativeLibrary` & `Library` - [@soywiz](https://github.com/soywiz).
* [#1491](https://github.com/java-native-access/jna/pull/1491): Update libffi to v3.4.4 - [@matthiasblaesing](https://github.com/matthiasblaesing).
* [#1487](https://github.com/java-native-access/jna/issues/1487): Add 'uses' information to OSGI metadata in MANIFEST.MF to improve stability of package resolution - [@sratz](https://github.com/sratz).

Bug Fixes
---------
Expand Down
15 changes: 13 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
</or>
</condition>
<property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}${version.suffix}"/>
<property name="osgi.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
<!-- jnidispatch library release version -->
<property name="jni.major" value="6"/>
<property name="jni.minor" value="1"/>
Expand Down Expand Up @@ -470,7 +471,17 @@
<attribute name="Bundle-RequiredExecutionEnvironment" value="JavaSE-1.6"/>
<attribute name="Bundle-Vendor" value="${vendor}"/>
<attribute name="Bundle-ActivationPolicy" value="lazy"/>
<attribute name="Export-Package" value="com.sun.jna;version=${jna.major}.${jna.minor}.${jna.revision}, com.sun.jna.ptr;version=${jna.major}.${jna.minor}.${jna.revision}, com.sun.jna.win32;version=${jna.major}.${jna.minor}.${jna.revision}"/>
<!--
The full "Export-Package" statement can be generated by invoking
create-export-package-metadata-pom.sh in the main folder. This is
necessary if the exported packages change. Then the list in the
shell script needs to be updated as well.
-->
<attribute name="Export-Package" value="
com.sun.jna;version=&quot;${osgi.version}&quot;,
com.sun.jna.ptr;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna&quot;,
com.sun.jna.win32;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna&quot;
"/>
<!-- Note that no terminal "*" is included in this list,
which will force failure on unsupported platforms.
-->
Expand Down Expand Up @@ -761,7 +772,7 @@ osname=macosx;processor=aarch64
<property name="spec.title" value="${spec.title}"/>
<property name="spec.vendor" value="${spec.vendor}"/>
<property name="spec.version" value="${spec.version}"/>
<property name="osgi.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
<property name="osgi.version" value="${osgi.version}"/>
<fileset dir="${contrib}" includes="platform/build.xml" />
</subant>
<!-- Sources package as required by maven -->
Expand Down
34 changes: 20 additions & 14 deletions contrib/platform/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,28 @@
<attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
<attribute name="Bundle-Vendor" value="${vendor}"/>
<attribute name="Require-Bundle" value="com.sun.jna;bundle-version=&quot;${osgi.version}&quot;"/>
<!--
The full "Export-Package" statement can be generated by invoking
create-export-package-metadata-pom.sh in the main folder. This is
necessary if the exported packages change. Then the list in the
shell script needs to be updated as well.
-->
<attribute name="Export-Package"
value="
com.sun.jna.platform;version=${osgi.version},
com.sun.jna.platform.dnd;version=${osgi.version},
com.sun.jna.platform.linux;version=${osgi.version},
com.sun.jna.platform.mac;version=${osgi.version},
com.sun.jna.platform.unix;version=${osgi.version},
com.sun.jna.platform.unix.aix;version=${osgi.version},
com.sun.jna.platform.unix.solaris;version=${osgi.version},
com.sun.jna.platform.win32;version=${osgi.version},
com.sun.jna.platform.win32.COM;version=${osgi.version},
com.sun.jna.platform.win32.COM.tlb;version=${osgi.version},
com.sun.jna.platform.win32.COM.tlb.imp;version=${osgi.version},
com.sun.jna.platform.win32.COM.util;version=${osgi.version},
com.sun.jna.platform.win32.COM.util.annotation;version=${osgi.version},
com.sun.jna.platform.wince;version=${osgi.version}
com.sun.jna.platform;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.platform.win32&quot;,
com.sun.jna.platform.dnd;version=&quot;${osgi.version}&quot;,
com.sun.jna.platform.linux;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.platform.unix&quot;,
com.sun.jna.platform.mac;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.platform,com.sun.jna.platform.unix,com.sun.jna.ptr&quot;,
com.sun.jna.platform.unix;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.ptr&quot;,
com.sun.jna.platform.unix.aix;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna&quot;,
com.sun.jna.platform.unix.solaris;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.ptr&quot;,
com.sun.jna.platform.win32;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.platform,com.sun.jna.platform.win32.COM,com.sun.jna.ptr,com.sun.jna.win32&quot;,
com.sun.jna.platform.win32.COM;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.platform.win32,com.sun.jna.platform.win32.COM.util,com.sun.jna.ptr,com.sun.jna.win32&quot;,
com.sun.jna.platform.win32.COM.tlb;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna.platform.win32.COM.tlb.imp&quot;,
com.sun.jna.platform.win32.COM.tlb.imp;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna.platform.win32,com.sun.jna.platform.win32.COM&quot;,
com.sun.jna.platform.win32.COM.util;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.platform.win32,com.sun.jna.platform.win32.COM,com.sun.jna.platform.win32.COM.util.annotation,com.sun.jna.ptr&quot;,
com.sun.jna.platform.win32.COM.util.annotation;version=&quot;${osgi.version}&quot;,
com.sun.jna.platform.wince;version=&quot;${osgi.version}&quot;;uses:=&quot;com.sun.jna,com.sun.jna.platform.win32&quot;
"/>
</manifest>
<manifest file="@{target}" mode="update" if:true="@{module-info}">
Expand Down
44 changes: 44 additions & 0 deletions create-export-package-metadata-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>net.java.dev.jna</groupId>
<artifactId>create-export-package-metadata</artifactId>
<version>1.0.0</version>
<packaging>bundle</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<sourceDirectory>${sourceDirectory}</sourceDirectory>
<outputDirectory>${outputDirectory}</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>5.1.8</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>${exportedPackages}</Export-Package>
<Import-Package>${importedPackages}</Import-Package>
</instructions>
</configuration>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
62 changes: 62 additions & 0 deletions create-export-package-metadata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env sh
set -e

extract_export_package_value_for_buildxml() {
sed -z -E 's:\r?\n ::g' "$1" \
| grep '^Export-Package' \
| sed 's/^Export-Package: //' \
| sed 's/",/",\n/g' \
| sed 's/1\.0\.0/${osgi.version}/g' \
| sed 's/"/\&quot;/g'
}

rm -rf tmp

mkdir tmp

cp -r src tmp

mvn \
-f create-export-package-metadata-pom.xml \
-DsourceDirectory=tmp/src \
-DoutputDirectory=tmp/target \
-DexportedPackages=com.sun.jna,com.sun.jna.ptr,com.sun.jna.win32 \
clean package

cp -r contrib/platform/src tmp

mvn \
-f create-export-package-metadata-pom.xml \
-DsourceDirectory=tmp/src \
-DoutputDirectory=tmp/target-platform \
-DexportedPackages=\
com.sun.jna.platform,\
com.sun.jna.platform.dnd,\
com.sun.jna.platform.linux,\
com.sun.jna.platform.mac,\
com.sun.jna.platform.unix,\
com.sun.jna.platform.unix.aix,\
com.sun.jna.platform.unix.solaris,\
com.sun.jna.platform.win32,\
com.sun.jna.platform.win32.COM,\
com.sun.jna.platform.win32.COM.tlb,\
com.sun.jna.platform.win32.COM.tlb.imp,\
com.sun.jna.platform.win32.COM.util,\
com.sun.jna.platform.win32.COM.util.annotation,\
com.sun.jna.platform.wince \
-DimportedPackages=com.sun.jna,com.sun.jna.ptr,com.sun.jna.win32 \
clean package

echo 'build.xml: Export-Package:'
echo
extract_export_package_value_for_buildxml tmp/target/META-INF/MANIFEST.MF
echo
echo

echo 'contrib/platform/build.xml: Export-Package:'
echo
extract_export_package_value_for_buildxml tmp/target-platform/META-INF/MANIFEST.MF
echo
echo

rm -r tmp

0 comments on commit a5f47cd

Please sign in to comment.