Skip to content

Commit

Permalink
Generate OSGi Metadata via BND (#14)
Browse files Browse the repository at this point in the history
Aligns with Liquibase 4.9.1
  • Loading branch information
mattbertolini authored Mar 30, 2022
1 parent f863575 commit 2440abd
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 19 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ os: linux
jdk:
- openjdk8
- openjdk11
- openjdk17

before_script:
- export ANT_VERSION=1.10.12
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012-2020 Matt Bertolini
Copyright (c) 2012-2022 Matt Bertolini

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
Expand Down
15 changes: 11 additions & 4 deletions buildsrc/assemble.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2020 Matt Bertolini
Copyright (c) 2012-2022 Matt Bertolini
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
Expand All @@ -15,14 +15,17 @@
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.
-->
<project name="-assemble" basedir="../" xmlns="antlib:org.apache.tools.ant" xmlns:ivy="antlib:org.apache.ivy.ant">
<project name="-assemble" basedir="../" xmlns="antlib:org.apache.tools.ant" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:bnd="antlib:aqute.bnd.ant">
<include file="${basedir}/buildsrc/properties.xml"/>
<include file="${basedir}/buildsrc/compile.xml"/>
<include file="${basedir}/buildsrc/dependencies.xml"/>
<include file="${basedir}/buildsrc/javadoc.xml"/>
<include file="${basedir}/buildsrc/bnd.xml"/>

<target name="-main-jar" depends="-compile.-main-classes">
<jar destfile="${dist.dir}/${project.name}-${project.version}.jar" manifest="${build.main.dir}/META-INF/MANIFEST.MF">
<target name="-main-jar" depends="-compile.-main-classes, -bnd.-load-bnd">
<local name="main.jar.name"/>
<property name="main.jar.name" value="${project.name}-${project.version}.jar"/>
<jar destfile="${dist.dir}/${main.jar.name}" manifest="${build.main.dir}/META-INF/MANIFEST.MF">
<fileset dir="${build.main.dir}"/>
<manifest>
<attribute name="Implementation-Title" value="${project.name}"/>
Expand All @@ -31,6 +34,10 @@
<attribute name="Implementation-Version" value="${project.version}"/>
</manifest>
</jar>
<bnd:bndwrap failok="false" force="true" definitions="${basedir}/buildsrc/bnd/liquibase-slf4j.bnd" classpath="${toString:compile-main-classpath}" output="${dist.dir}/${main.jar.name}">
<fileset file="${dist.dir}/${main.jar.name}"/>
</bnd:bndwrap>
<delete file="${dist.dir}/${main.jar.name}.bak" failonerror="false"/>
</target>

<target name="-main-javadoc-jar" depends="-javadoc.-javadoc">
Expand Down
32 changes: 32 additions & 0 deletions buildsrc/bnd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2022 Matt Bertolini
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.
-->
<project name="-bnd" basedir="../" xmlns="antlib:org.apache.tools.ant" xmlns:macro="antmacro:com.mattbertolini.liquibase.slf4j">
<include file="${basedir}/buildsrc/dependencies.xml"/>

<property name="lib.bnd.dir" value="${lib.dir}/bnd"/>

<target name="-load-bnd" depends="-dependencies.-init-ivy" unless="load-bnd.run">
<macro:retrieve-deps conf="bnd"/>
<path id="bnd.classpath">
<fileset dir="${lib.bnd.dir}"/>
</path>
<taskdef resource="aQute/bnd/ant/taskdef.properties" classpathref="bnd.classpath" uri="antlib:aqute.bnd.ant"/>
<property name="load-bnd.run" value="true"/>
</target>

</project>
23 changes: 23 additions & 0 deletions buildsrc/bnd/liquibase-slf4j.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2012-2022 Matt Bertolini
#
# 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.

# Removing headers that make the jar non-reproducible
-removeheaders: Ant-Version,Created-By,Originally-Created-By,Bnd-LastModified,Tool
Bundle-Name: ${project.name}
Bundle-SymbolicName: com.mattbertolini.liquibase.logging.slf4j
Bundle-Version: ${version_cleanup;${project.version}}
Fragment-Host: org.liquibase.core;bundle-version="[${dependency.compile.liquibase-core.version},${versionmask;+;${dependency.compile.liquibase-core.version}})"
Provide-Capability: osgi.serviceloader; osgi.serviceloader=liquibase.logging.LogService
Require-Capability: osgi.serviceloader; filter:="(osgi.serviceloader=liquibase.logging.LogService)"; cardinality:=multiple
5 changes: 4 additions & 1 deletion buildsrc/compile.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2020 Matt Bertolini
Copyright (c) 2012-2022 Matt Bertolini
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
Expand All @@ -21,12 +21,15 @@
<include file="${basedir}/buildsrc/dependencies.xml"/>

<property name="lib.compile.dir" value="${lib.dir}/compile"/>
<property name="lib.compileonly.dir" value="${lib.dir}/compile-only"/>
<property name="lib.test.dir" value="${lib.dir}/test"/>

<target name="-build-main-classpath" depends="-dependencies.-init-ivy" unless="build-main-classpath.run">
<macro:retrieve-deps conf="compile"/>
<macro:retrieve-deps conf="compile-only"/>
<path id="compile-main-classpath">
<fileset dir="${lib.compile.dir}"/>
<fileset dir="${lib.compileonly.dir}"/>
</path>
<property name="build-main-classpath.run" value="true"/>
</target>
Expand Down
3 changes: 2 additions & 1 deletion buildsrc/dependencies.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2020 Matt Bertolini
Copyright (c) 2012-2022 Matt Bertolini
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
Expand Down Expand Up @@ -55,6 +55,7 @@
<ivy:resolve file="${basedir}/ivy.xml" conf="@{conf}" haltonfailure="false" log="download-only"/>
<ivy:retrieve pattern="${lib.dir}/@{conf}/${ivy.retrieve.pattern}" sync="true" haltonfailure="true"/>
<ivy:artifactproperty name="dependency.[conf].[artifact]" value="${lib.dir}/@{conf}/${ivy.retrieve.pattern}"/>
<ivy:artifactproperty name="dependency.[conf].[artifact].version" value="[revision]"/>
<ivy:artifactproperty name="ivy.retrieve.[conf].run" value="true"/>
</sequential>
</macrodef>
Expand Down
2 changes: 1 addition & 1 deletion buildsrc/ivy/pom-template.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2020 Matt Bertolini
Copyright (c) 2012-2022 Matt Bertolini
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
Expand Down
4 changes: 2 additions & 2 deletions buildsrc/javadoc.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2020 Matt Bertolini
Copyright (c) 2012-2022 Matt Bertolini
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
Expand Down Expand Up @@ -33,7 +33,7 @@
<packageset dir="${src.main.java.dir}" defaultexcludes="true"/>
<link href="https://docs.oracle.com/javase/8/docs/api/"/>
<link href="https://www.liquibase.org/javadoc/"/>
<link href="http://slf4j.org/apidocs/"/>
<link href="https://www.slf4j.org/apidocs/"/>
<doctitle>Liquibase SLF4J Logger Documentation</doctitle>
</javadoc>
</ac:sequential>
Expand Down
2 changes: 1 addition & 1 deletion buildsrc/properties.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2020 Matt Bertolini
Copyright (c) 2012-2022 Matt Bertolini
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
Expand Down
9 changes: 8 additions & 1 deletion buildsrc/publish.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2020 Matt Bertolini
Copyright (c) 2012-2022 Matt Bertolini
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
Expand All @@ -22,6 +22,13 @@

<property file="${basedir}/build-publish.properties" />

<!--
There is a problem with the Ivy publish tasks when using the Ant package found in Homebrew. The Homebrew package
installs a version of Ivy in Ant's main classpath. This version may be older than the version of Ivy used by
this build. This results in NoClassDefFound errors when trying to use BouncyCastle to sign jars. Try to use an
installation of Ant not from Homebrew.
-->

<target name="-init-ivy-publish-settings" depends="-dependencies.-init-ivy">
<ivy:settings id="publish-settings" file="${basedir}/buildsrc/ivy/ivysettings-publish.xml"/>
</target>
Expand Down
5 changes: 2 additions & 3 deletions buildsrc/test.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2020 Matt Bertolini
Copyright (c) 2012-2022 Matt Bertolini
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
Expand Down Expand Up @@ -35,15 +35,14 @@

<target name="-test" depends="-load-junit-platform, -jacoco.-load-jacoco, -compile.-main-classes, -compile.-test-classes" unless="test.run">
<path id="test-classpath">
<fileset dir="${lib.compile.dir}"/>
<fileset dir="${lib.test.dir}"/>
</path>
<path id="run-unit-tests-classpath">
<path location="${build.main.dir}"/>
<path location="${build.test.dir}"/>
<path refid="compile-main-classpath"/>
<path refid="test-classpath"/>
<path refid="junit-platform.classpath"/>
<path refid="jacoco.classpath"/>
</path>
<mkdir dir="${build.reports.unittest.dir}"/>
<jacoco:agent property="jacoco.agent.property" destfile="${build.reports.coverage.dir}/${project.name}-coverage.exec"/>
Expand Down
12 changes: 8 additions & 4 deletions ivy.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2021 Matt Bertolini
Copyright (c) 2012-2022 Matt Bertolini
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
Expand All @@ -25,13 +25,15 @@
</info>
<configurations>
<conf name="compile"/>
<conf name="compile-only"/>
<conf name="test"/>
<conf name="spotbugs"/>
<conf name="ivy"/>
<conf name="antcontrib"/>
<conf name="jacoco"/>
<conf name="jxr"/>
<conf name="junit-platform"/>
<conf name="bnd"/>
<conf name="default" visibility="private"/>
<conf name="sources" visibility="private"/>
<conf name="javadoc" visibility="private"/>
Expand All @@ -43,8 +45,8 @@
<artifact type="pom" ext="pom"/>
</publications>
<dependencies defaultconfmapping="compile->default">
<dependency org="org.slf4j" name="slf4j-api" rev="1.7.32"/>
<dependency org="org.liquibase" name="liquibase-core" rev="4.1.0"/>
<dependency org="org.slf4j" name="slf4j-api" rev="1.7.36"/>
<dependency org="org.liquibase" name="liquibase-core" rev="4.9.1"/>
<dependency org="org.junit.jupiter" name="junit-jupiter-api" rev="5.8.2" conf="test->default"/>
<dependency org="org.mockito" name="mockito-core" rev="4.2.0" conf="test->default"/>
<dependency org="org.junit.jupiter" name="junit-jupiter-engine" rev="5.8.2" conf="junit-platform->default"/>
Expand All @@ -55,7 +57,9 @@
<dependency org="org.jacoco" name="org.jacoco.ant" rev="0.8.7" conf="jacoco->default"/>
<dependency org="com.github.spotbugs" name="spotbugs" rev="4.5.2" conf="spotbugs->default"/>
<dependency org="com.github.spotbugs" name="spotbugs-ant" rev="4.5.2" conf="spotbugs->default"/>
<dependency org="com.mattbertolini" name="jxr-ant" rev="2.0.0" conf="jxr->default">
<dependency org="com.mattbertolini" name="jxr-ant" rev="2.0.0" conf="jxr->default"/>
<dependency org="org.osgi" name="osgi.annotation" rev="8.0.1" conf="compile-only->default"/>
<dependency org="biz.aQute.bnd" name="biz.aQute.bnd.ant" rev="6.2.0" conf="bnd->default">
<exclude module="ant"/>
</dependency>
<dependency org="org.apache.ivy" name="ivy" rev="${lib.ivy.version}" conf="ivy->default"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2012-2022 Matt Bertolini
*
* 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.
*/

/**
* The main package of the Liquibase SLF4J library.
*/
@Export
@Version("${version_cleanup;${project.version}}") // Project version property defined in Ant build
package com.mattbertolini.liquibase.logging.slf4j;

import org.osgi.annotation.bundle.Export;
import org.osgi.annotation.versioning.Version;

0 comments on commit 2440abd

Please sign in to comment.