From f93b599b0ef1ffa67cacf6c18bd6fabe4fb88de6 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Sat, 15 Mar 2025 10:53:25 +0100 Subject: [PATCH 1/4] Adds BND Maven Plugins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds [BND Maven Plugins](https://github.com/bndtools/bnd/blob/master/maven-plugins/README.md) to: - Generate an OSGi bundle descriptor (`MANIFEST.MF`). - Generate a JPMS bundle descriptor. - Check for binary compatibility between releases. The binary compatibility check is implemented by: - Annotating each package with `@Version`. See [Versioning in OSGi](https://bnd.bndtools.org/chapters/170-versioning.html#versions-in-osgi) for details. - Adding the `bnd-baseline-maven-plugin` that checks if the version increment is compatible with the change type (`MICRO`—only annotations added, `MINOR`—only binary compatible changes, `MAJOR`—binary incompatible changes). --- bnd.bnd | 55 ++++++++++++ pom.xml | 87 ++++++++++++++++++- .../com/github/packageurl/package-info.java | 4 +- .../packageurl/validator/package-info.java | 7 +- 4 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 bnd.bnd diff --git a/bnd.bnd b/bnd.bnd new file mode 100644 index 0000000..887e9d6 --- /dev/null +++ b/bnd.bnd @@ -0,0 +1,55 @@ +# +# MIT License +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +## + +# Create OSGi and JPMS module names based on the `groupId` and `artifactId`. +# This almost agrees with `maven-bundle-plugin`, but replaces non-alphanumeric characters +# with full stops `.`. +Bundle-SymbolicName: com.github.packageurl.java +-jpms-module-info: $[Bundle-SymbolicName];access=0 + +# Convert API leakage warnings to errors +-fixupmessages.priv_refs: "private references";restrict:=warning;is:=error + + + +# Options specific to dependency packages: +# +# Jakarta Validation is an optional dependency. +Import-Package: \ + jakarta.validation;resolution:=optional,\ + * + +# Options specific to dependency modules: +# +# Jakarta Validation is optional, so it can not be `transitive`, otherwise consumers will need it at compile time. +-jpms-module-info-options: \ + jakarta.validation;transitive=false + +# Adds certain `Implementation-*` and `Specification-*` entries to the generated `MANIFEST.MF`. +# We set these values to their Maven Archiver defaults: https://maven.apache.org/shared/maven-archiver/#class_manifest +Implementation-Title: ${project.name} +# Implementation-Vendor: ${project.organization.name} +Implementation-Version: ${project.version} +Specification-Title: ${project.name} +# Specification-Vendor: ${project.organization.name} +Specification-Version: ${parsedVersion.majorVersion}.${parsedVersion.minorVersion} diff --git a/pom.xml b/pom.xml index 06a7b36..e7100c8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.package-url packageurl-java - 1.5.1-SNAPSHOT + 1.6.0-SNAPSHOT jar Package URL @@ -56,6 +56,8 @@ 18 + 7.1.0 + 3.6.0 2.5 3.14.0 2.7 @@ -128,6 +130,12 @@ true provided + + org.osgi + org.osgi.annotation.bundle + 2.0.0 + provided + org.jspecify jspecify @@ -149,6 +157,16 @@ + + biz.aQute.bnd + bnd-baseline-maven-plugin + ${bnd.maven.plugin.version} + + + biz.aQute.bnd + bnd-maven-plugin + ${bnd.maven.plugin.version} + org.apache.maven.plugins maven-clean-plugin @@ -202,6 +220,25 @@ + + + org.codehaus.mojo + build-helper-maven-plugin + ${builder.helper.maven.plugin.version} + + + parse-version + + parse-version + + validate + + + org.apache.maven.plugins maven-enforcer-plugin @@ -324,6 +361,54 @@ + + + biz.aQute.bnd + bnd-maven-plugin + + true + + + generate-jar-and-module-descriptors + + jar + + + + + + + biz.aQute.bnd + bnd-baseline-maven-plugin + + + check-api-compatibility + + baseline + + + + org.cyclonedx cyclonedx-maven-plugin diff --git a/src/main/java/com/github/packageurl/package-info.java b/src/main/java/com/github/packageurl/package-info.java index 55397be..5312caa 100644 --- a/src/main/java/com/github/packageurl/package-info.java +++ b/src/main/java/com/github/packageurl/package-info.java @@ -24,6 +24,8 @@ *

https://github.com/package-url/purl-spec

*/ @NullMarked +@Export package com.github.packageurl; -import org.jspecify.annotations.NullMarked; \ No newline at end of file +import org.jspecify.annotations.NullMarked; +import org.osgi.annotation.bundle.Export; diff --git a/src/main/java/com/github/packageurl/validator/package-info.java b/src/main/java/com/github/packageurl/validator/package-info.java index 03dc629..5cd633e 100644 --- a/src/main/java/com/github/packageurl/validator/package-info.java +++ b/src/main/java/com/github/packageurl/validator/package-info.java @@ -19,7 +19,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +/** + * This package contains a validator for Jakarta Validation. + */ @NullMarked +@Export package com.github.packageurl.validator; -import org.jspecify.annotations.NullMarked; \ No newline at end of file +import org.jspecify.annotations.NullMarked; +import org.osgi.annotation.bundle.Export; From 3dfa3cfa6116b1df0fe4b1540572b84dd56fd01e Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Sat, 15 Mar 2025 11:15:53 +0100 Subject: [PATCH 2/4] Enable reproducible builds --- pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pom.xml b/pom.xml index e7100c8..067a18b 100644 --- a/pom.xml +++ b/pom.xml @@ -42,6 +42,13 @@ UTF-8 false + + 2025-03-15T10:12:28Z +