Skip to content

Commit

Permalink
Update BND plugin to 6.0.0 (#2440)
Browse files Browse the repository at this point in the history
We use the new bundle extension for bnd configuration. We also update
the verifyOSGi task to use the new output property to enable
up-to-date builds.

Signed-off-by: Raymond Augé <raymond.auge@liferay.com>
  • Loading branch information
rotty3000 committed Oct 5, 2021
1 parent 7032574 commit d4180a2
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -23,7 +23,7 @@ plugins {
id 'com.diffplug.gradle.spotless' version '4.5.1'
id 'eclipse'
id 'com.github.ben-manes.versions' version '0.39.0'
id 'biz.aQute.bnd.builder' version '5.3.0'
id 'biz.aQute.bnd.builder' version '6.0.0'
id 'ru.vyarus.animalsniffer' version '1.5.2'
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Expand Up @@ -30,7 +30,7 @@ libraries.objenesis = 'org.objenesis:objenesis:3.2'

libraries.osgi = 'org.osgi:osgi.core:8.0.0'
libraries.equinox = 'org.eclipse.platform:org.eclipse.osgi:3.17.0'
libraries.bndGradle = 'biz.aQute.bnd:biz.aQute.bnd.gradle:5.3.0'
libraries.bndGradle = 'biz.aQute.bnd:biz.aQute.bnd.gradle:6.0.0'

libraries.groovy = 'org.codehaus.groovy:groovy:3.0.9'

Expand Down
40 changes: 21 additions & 19 deletions gradle/mockito-core/osgi.gradle
Expand Up @@ -2,23 +2,25 @@ apply plugin: 'biz.aQute.bnd.builder'

jar {
classpath = project.configurations.compileClasspath
bnd(
'Bundle-Name': 'Mockito Mock Library for Java. Core bundle requires Byte Buddy and Objenesis.',
'Bundle-SymbolicName': 'org.mockito.mockito-core',
'Bundle-Version': "\${version_cleanup;${project.version}}",
'-versionpolicy': '[${version;==;${@}},${version;+;${@}})',
'Export-Package': "org.mockito.internal.*;status=INTERNAL;mandatory:=status;version=${version},org.mockito.*;version=${version}",
'Import-Package': [
'net.bytebuddy.*;version="[1.6.0,2.0)"',
'junit.*;resolution:=optional',
'org.junit.*;resolution:=optional',
'org.hamcrest;resolution:=optional',
'org.objenesis;version="[3.1,4.0)"',
'org.opentest4j.*;resolution:=optional',
'org.mockito.*'
].join(','),
'-removeheaders': 'Private-Package',
'Automatic-Module-Name': 'org.mockito',
'-noextraheaders': 'true'
)
bundle {
bnd(
'Bundle-Name': 'Mockito Mock Library for Java. Core bundle requires Byte Buddy and Objenesis.',
'Bundle-SymbolicName': 'org.mockito.mockito-core',
'Bundle-Version': "\${version_cleanup;${project.version}}",
'-versionpolicy': '[${version;==;${@}},${version;+;${@}})',
'Export-Package': "org.mockito.internal.*;status=INTERNAL;mandatory:=status;version=${version},org.mockito.*;version=${version}",
'Import-Package': [
'net.bytebuddy.*;version="[1.6.0,2.0)"',
'junit.*;resolution:=optional',
'org.junit.*;resolution:=optional',
'org.hamcrest;resolution:=optional',
'org.objenesis;version="[3.1,4.0)"',
'org.opentest4j.*;resolution:=optional',
'org.mockito.*'
].join(','),
'-removeheaders': 'Private-Package',
'Automatic-Module-Name': 'org.mockito',
'-noextraheaders': 'true'
)
}
}
40 changes: 19 additions & 21 deletions subprojects/junit-jupiter/junit-jupiter.gradle
@@ -1,5 +1,3 @@
import aQute.bnd.gradle.BundleTaskConvention
import aQute.bnd.gradle.FileSetRepositoryConvention
import aQute.bnd.gradle.Resolve

description = "Mockito JUnit 5 support"
Expand All @@ -21,26 +19,26 @@ tasks.withType(Test) {

jar {
classpath = project.configurations.runtimeClasspath
bnd(
'Bundle-Name': 'Mockito Extension Library for JUnit 5.',
'Bundle-SymbolicName': 'org.mockito.junit-jupiter',
'Bundle-Version': "\${version_cleanup;${project.version}}",
'-versionpolicy': '[${version;==;${@}},${version;+;${@}})',
'Export-Package': "org.mockito.junit.jupiter.*;version=${version}",
'-removeheaders': 'Private-Package',
'Automatic-Module-Name': 'org.mockito.junit.jupiter',
'-noextraheaders': 'true',
'-export-apiguardian': 'org.mockito.internal.*'
)
bundle {
bnd(
'Bundle-Name': 'Mockito Extension Library for JUnit 5.',
'Bundle-SymbolicName': 'org.mockito.junit-jupiter',
'Bundle-Version': "\${version_cleanup;${project.version}}",
'-versionpolicy': '[${version;==;${@}},${version;+;${@}})',
'Export-Package': "org.mockito.junit.jupiter.*;version=${version}",
'-removeheaders': 'Private-Package',
'Automatic-Module-Name': 'org.mockito.junit.jupiter',
'-noextraheaders': 'true',
'-export-apiguardian': 'org.mockito.internal.*'
)
}
}

def osgiPropertiesFile = file("$buildDir/verifyOSGiProperties.bndrun")

// Bnd's Resolve task uses a properties file for its configuration. This
// task writes out the properties necessary for it to verify the OSGi
// metadata.
tasks.register('osgiProperties', WriteProperties) {
outputFile = osgiPropertiesFile
def osgiProperties = tasks.register('osgiProperties', WriteProperties) {
outputFile = layout.getBuildDirectory().file("verifyOSGiProperties.bndrun")
property('-standalone', true)
property('-runee', "JavaSE-${targetCompatibility}")
property('-runrequires', 'osgi.identity;filter:="(osgi.identity=org.mockito.junit-jupiter)"')
Expand All @@ -49,12 +47,12 @@ tasks.register('osgiProperties', WriteProperties) {
// Bnd's Resolve task is what verifies that a jar can be used in OSGi and
// that its metadata is valid. If the metadata is invalid this task will
// fail.
tasks.register('verifyOSGi', Resolve) {
dependsOn(osgiProperties)
setBndrun(osgiPropertiesFile)
def verifyOSGi = tasks.register('verifyOSGi', Resolve) {
getBndrun().fileProvider(osgiProperties.map { it.outputFile })
getOutputBndrun().set(layout.getBuildDirectory().file("resolvedOSGiProperties.bndrun"))
reportOptional = false
}

tasks.check {
tasks.named('check') {
dependsOn(verifyOSGi)
}

0 comments on commit d4180a2

Please sign in to comment.