[Git][java-team/bnd][master] Fixed the Gradle plugin
Emmanuel Bourg
gitlab at salsa.debian.org
Mon Aug 3 22:33:00 BST 2020
Emmanuel Bourg pushed to branch master at Debian Java Maintainers / bnd
Commits:
500d1d5f by Emmanuel Bourg at 2020-08-03T23:08:04+02:00
Fixed the Gradle plugin
- - - - -
3 changed files:
- debian/changelog
- debian/patches/embedded-repo.patch
- debian/patches/gradle-compatibility.patch
Changes:
=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+bnd (5.0.1-2) unstable; urgency=medium
+
+ * Fixed the Gradle plugin
+
+ -- Emmanuel Bourg <ebourg at apache.org> Mon, 03 Aug 2020 23:07:50 +0200
+
bnd (5.0.1-1) unstable; urgency=medium
* New upstream release
=====================================
debian/patches/embedded-repo.patch
=====================================
@@ -11,3 +11,15 @@ Forwarded: not-needed
}
return false;
} finally {
+--- a/biz.aQute.bnd.gradle/bnd.bnd
++++ b/biz.aQute.bnd.gradle/bnd.bnd
+@@ -9,8 +9,7 @@
+ aQute.libg;version=project, \
+ biz.aQute.bndlib;version=latest, \
+ biz.aQute.resolve;version=latest, \
+- biz.aQute.repository;version=latest, \
+- biz.aQute.bnd.embedded-repo;version=latest
++ biz.aQute.repository;version=latest
+
+ -testpath: \
+ ${junit}
=====================================
debian/patches/gradle-compatibility.patch
=====================================
@@ -282,24 +282,209 @@ Forwarded: not-needed
}
--- a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/Baseline.groovy
+++ b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/Baseline.groovy
-@@ -66,7 +66,6 @@
+@@ -8,19 +8,17 @@
+ * Here is an example of using the Baseline task type:
+ * <pre>
+ * import aQute.bnd.gradle.Baseline
++ * apply plugin: 'java'
+ * configurations {
+ * baseline
+ * }
+ * dependencies {
+- * baseline('group': group, 'name': jar.archiveBaseName) {
+- * version {
+- * strictly "(0,${jar.archiveVersion.get()}["
+- * }
++ * baseline('group': group, 'name': jar.baseName, 'version': "(,${jar.version})") {
+ * transitive false
+ * }
+ * }
+ * }
+- * tasks.register('baseline', Baseline) {
++ * task baseline(type: Baseline) {
+ * bundle jar
+ * baseline configurations.baseline
+ * }
+@@ -64,26 +62,17 @@
+ import org.gradle.api.Task
+ import org.gradle.api.artifacts.Configuration
import org.gradle.api.file.ConfigurableFileCollection
- import org.gradle.api.file.DirectoryProperty
- import org.gradle.api.file.RegularFile
+-import org.gradle.api.file.DirectoryProperty
+-import org.gradle.api.file.RegularFile
-import org.gradle.api.model.ReplacedBy
- import org.gradle.api.provider.ListProperty
- import org.gradle.api.provider.Provider
+-import org.gradle.api.provider.ListProperty
+-import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Input
-@@ -74,7 +73,6 @@
- import org.gradle.api.tasks.Internal
+ import org.gradle.api.tasks.InputFile
+-import org.gradle.api.tasks.Internal
++import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
-import org.gradle.api.tasks.TaskProvider
public class Baseline extends DefaultTask {
private ConfigurableFileCollection bundleCollection
-@@ -216,9 +214,6 @@
- @Internal('Used by baseline configuration')
+ private ConfigurableFileCollection baselineCollection
+- private final ListProperty<String> diffignore
+- private final ListProperty<String> diffpackages
+- private final DirectoryProperty baselineReportDirectory
+- private final Provider<RegularFile> reportFile
+- private String baselineReportDirName
++ private List<String> diffignore = []
++ private List<String> diffpackages = []
+
+ /**
+ * Whether baseline failures should be ignored.
+@@ -94,7 +83,17 @@
+ * <code>false</code>.
+ */
+ @Input
+- boolean ignoreFailures = false
++ boolean ignoreFailures
++
++ /**
++ * The name of the baseline reports directory.
++ *
++ * <p>
++ * Can be a name or a path relative to <code>ReportingExtension.getBaseDir()</code>.
++ * The default name is 'baseline'.
++ */
++ @Input
++ String baselineReportDirName
+
+ /**
+ * Create a Baseline task.
+@@ -102,15 +101,8 @@
+ */
+ public Baseline() {
+ super()
++ ignoreFailures = false
+ baselineReportDirName = 'baseline'
+- baselineReportDirectory = project.objects.directoryProperty().convention(project.reporting.baseDirectory.dir(baselineReportDirName))
+- reportFile = baselineReportDirectory.file(project.provider({ ->
+- String bundlename = project.file(getBundle()).name
+- bundlename = bundlename[0..Math.max(-1, bundlename.lastIndexOf('.') - 1)]
+- return "${name}/${bundlename}.txt"
+- }))
+- diffignore = project.objects.listProperty(String.class).empty()
+- diffpackages = project.objects.listProperty(String.class).empty()
+ bundleCollection = project.files()
+ baselineCollection = project.files()
+ dependsOn {
+@@ -119,20 +111,6 @@
+ }
+
+ /**
+- * Return the bundle File to be baselined.
+- *
+- * <p>
+- * An exception will be thrown if the set bundle does
+- * not result in exactly one file.
+- */
+- @InputFile
+- public Provider<RegularFile> getBundle() {
+- return project.layout.file(project.provider({ ->
+- return bundleCollection.singleFile
+- }))
+- }
+-
+- /**
+ * Set the bundle to be baselined.
+ *
+ * <p>
+@@ -145,17 +123,15 @@
+ }
+
+ /**
+- * Get the baseline bundle File.
++ * Return the bundle File to be baselined.
+ *
+ * <p>
+- * An exception will be thrown if the baseline argument does
++ * An exception will be thrown if the set bundle does
+ * not result in exactly one file.
+ */
+ @InputFile
+- public Provider<RegularFile> getBaseline() {
+- return project.layout.file(project.provider({ ->
+- return baselineCollection.singleFile
+- }))
++ public File getBundle() {
++ return bundleCollection.singleFile
+ }
+
+ /**
+@@ -170,11 +146,23 @@
+ }
+
+ /**
+- * Return the diffignore values.
++ * Get the baseline bundle File.
++ *
++ * <p>
++ * An exception will be thrown if the baseline argument does
++ * not result in exactly one file.
+ */
+- @Input
+- public ListProperty<String> getDiffignore() {
+- return this.diffignore
++ @InputFile
++ public File getBaseline() {
++ return baselineCollection.singleFile
++ }
++
++ /**
++ * Returns a file pointing to the baseline reporting directory.
++ */
++ public File getBaselineReportDir() {
++ File dir = new File(baselineReportDirName)
++ return dir.absolute ? dir : project.reporting.file(dir.path)
+ }
+
+ /**
+@@ -187,16 +175,17 @@
+ /**
+ * Set the diffignore values.
+ */
+- public void setDiffignore(Iterable<String> diffignore) {
+- this.diffignore.set(diffignore)
++ public void setDiffignore(List<String> diffignore) {
++ this.diffignore = diffignore
+ }
+
+ /**
+- * Return the diffpackages values.
++ * Return the diffignore values.
+ */
+ @Input
+- public ListProperty<String> getDiffpackages() {
+- return this.diffpackages
++ @Optional
++ public List<String> getDiffignore() {
++ return diffignore
+ }
+
+ /**
+@@ -209,64 +198,36 @@
+ /**
+ * Set the diffpackages values.
+ */
+- public void setDiffpackages(Iterable<String> diffpackages) {
+- this.diffpackages.set(diffpackages)
++ public void setDiffpackages(List<String> diffpackages) {
++ this.diffpackages = diffpackages
++ }
++
++ /**
++ * Return the diffpackages values.
++ */
++ @Input
++ @Optional
++ public List<String> getDiffpackages() {
++ return diffpackages
+ }
+
+- @Internal('Used by baseline configuration')
Task getBundleTask() {
return bundleCollection.getBuiltBy().flatten().findResult { t ->
- if (t instanceof TaskProvider) {
@@ -308,14 +493,80 @@ Forwarded: not-needed
t instanceof Task && t.convention.findPlugin(BundleTaskConvention.class) ? t : null
}
}
-@@ -264,7 +259,6 @@
+-
+- @Internal('Used internally')
+ ConfigurableFileCollection getBundleCollection() {
+ return bundleCollection
+ }
+-
+- @Internal('Used internally')
+ ConfigurableFileCollection getBaselineCollection() {
+ return baselineCollection
}
- @Deprecated
+- /**
+- * The baseline reports directory.
+- */
+- @Internal('Represented by reportFile')
+- public DirectoryProperty getBaselineReportDirectory() {
+- return baselineReportDirectory
+- }
+-
+- /**
+- * The name of the baseline reports directory.
+- *
+- * <p>
+- * Can be a name or a path relative to <code>ReportingExtension.getBaseDirectory()</code>.
+- * The default name is 'baseline'.
+- */
+- @Internal('Represented by reportFile')
+- public String getBaselineReportDirName() {
+- return baselineReportDirName
+- }
+-
+- public void setBaselineReportDirName(String baselineReportDirName) {
+- this.baselineReportDirName = baselineReportDirName
+- baselineReportDirectory.set(project.reporting.baseDirectory.dir(baselineReportDirName))
+- }
+-
+ @OutputFile
+- public Provider<RegularFile> getReportFile() {
+- return reportFile
+- }
+-
+- @Deprecated
- @ReplacedBy('reportFile')
public File getDestination() {
- return project.file(getReportFile())
+- return project.file(getReportFile())
++ String bundlename = bundle.name
++ bundlename = bundlename[0..Math.max(-1, bundlename.lastIndexOf('.') - 1)]
++ return new File(baselineReportDir, "${name}/${bundlename}.txt")
}
+
+ /**
+@@ -275,9 +236,7 @@
+ */
+ @TaskAction
+ void baselineBundle() {
+- File bundle = project.file(getBundle())
+- File baseline = project.file(getBaseline())
+- File report = project.file(getReportFile())
++ File report = destination
+ project.mkdir(report.parent)
+ boolean failure = false
+ new Processor().withCloseable { Processor processor ->
+@@ -288,9 +247,9 @@
+ logger.debug 'Baseline bundle {} against baseline {}', bundle, baseline
+
+ def differ = new DiffPluginImpl()
+- differ.setIgnore(new Parameters(getDiffignore().get().join(','), processor))
++ differ.setIgnore(new Parameters(diffignore.join(','), processor))
+ def baseliner = new aQute.bnd.differ.Baseline(processor, differ)
+- def infos = baseliner.baseline(newer, older, new Instructions(new Parameters(getDiffpackages().get().join(','), processor))).sort {it.packageName}
++ def infos = baseliner.baseline(newer, older, new Instructions(new Parameters(diffpackages.join(','), processor))).sort {it.packageName}
+ def bundleInfo = baseliner.getBundleInfo()
+ new Formatter(report, 'UTF-8', Locale.US).withCloseable { Formatter f ->
+ f.format '===============================================================%n'
--- a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndUtils.groovy
+++ b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndUtils.groovy
@@ -9,11 +9,9 @@
@@ -998,3 +1249,292 @@ Forwarded: not-needed
// Depend upon output dir to avoid parallel test execution
// This effectively claims the resource and prevents
// other test tasks claiming the same resource from
+--- a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndBuilderPlugin.groovy
++++ b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndBuilderPlugin.groovy
+@@ -48,7 +48,7 @@
+ }
+ plugins.apply 'java'
+
+- def jar = tasks.named('jar') { t ->
++ def jar = tasks.getByName('jar') { t ->
+ t.description 'Assembles a bundle containing the main classes.'
+ t.convention.plugins.bundle = new BundleTaskConvention(t)
+ RegularFile defaultBndfile = project.layout.projectDirectory.file('bnd.bnd')
+@@ -74,7 +74,7 @@
+ }
+ }
+
+- tasks.register('baseline', Baseline.class) { t ->
++ tasks.create('baseline', Baseline.class) { t ->
+ t.description 'Baseline the project bundle.'
+ t.group 'release'
+ t.bundle jar
+@@ -85,8 +85,8 @@
+ Task baselineTask = tasks.getByName('baseline')
+ Task bundleTask = baselineTask.getBundleTask()
+ if (bundleTask) {
+- String archiveBaseName = unwrap(bundleTask.archiveBaseName)
+- String archiveVersion = unwrap(bundleTask.archiveVersion)
++ String archiveBaseName = unwrap(bundleTask.baseName)
++ String archiveVersion = unwrap(bundleTask.version)
+ logger.debug 'Searching for default baseline {}:{}:(0,{}[', group, archiveBaseName, archiveVersion
+ Dependency baselineDep = dependencies.create('group': group, 'name': archiveBaseName) {
+ version {
+--- a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BundleTaskConvention.groovy
++++ b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BundleTaskConvention.groovy
+@@ -23,10 +23,8 @@
+
+ package aQute.bnd.gradle
+
+-import static aQute.bnd.gradle.BndUtils.builtBy
+-import static aQute.bnd.gradle.BndUtils.jarLibraryElements
+ import static aQute.bnd.gradle.BndUtils.logReport
+-import static aQute.bnd.gradle.BndUtils.unwrap
++import static aQute.bnd.gradle.BndUtils.builtBy
+
+ import java.util.Properties
+ import java.util.jar.Manifest
+@@ -41,13 +39,10 @@
+ import aQute.bnd.version.MavenVersion
+ import aQute.lib.utf8properties.UTF8Properties
+ import org.gradle.api.GradleException
+-import org.gradle.api.Project
+-import org.gradle.api.Task
+ import org.gradle.api.file.ConfigurableFileCollection
+-import org.gradle.api.file.RegularFileProperty
+ import org.gradle.api.logging.Logger
+-import org.gradle.api.provider.ListProperty
+-import org.gradle.api.provider.Provider
++import org.gradle.api.Project
++import org.gradle.api.Task
+ import org.gradle.api.tasks.Input
+ import org.gradle.api.tasks.InputFile
+ import org.gradle.api.tasks.InputFiles
+@@ -57,9 +52,8 @@
+ class BundleTaskConvention {
+ private final Task task
+ private final Project project
+- private final RegularFileProperty bndfile
+- private final ListProperty<CharSequence> instructions
+- private final Provider<String> bndbnd
++ private File bndfile
++ private final StringBuilder instructions
+ private final ConfigurableFileCollection classpathCollection
+ private boolean classpathModified
+ private SourceSet sourceSet
+@@ -74,18 +68,14 @@
+ BundleTaskConvention(org.gradle.api.tasks.bundling.Jar task) {
+ this.task = task
+ this.project = task.project
+- bndfile = project.objects.fileProperty()
+- instructions = project.objects.listProperty(CharSequence.class).empty()
+- bndbnd = instructions.map({ list ->
+- return list.join('\n')
+- })
++ instructions = new StringBuilder()
+ classpathCollection = project.files()
+ setSourceSet(project.sourceSets.main)
+ classpathModified = false
+ // need to programmatically add to inputs since @InputFiles in a convention is not processed
+ task.inputs.files(classpathCollection).withPropertyName('classpath')
+- task.inputs.file(getBndfile()).optional().withPropertyName('bndfile')
+- task.inputs.property('bnd', getBnd())
++ task.inputs.file({ getBndfile() }).optional().withPropertyName('bndfile')
++ task.inputs.property('bnd', { getBnd() })
+ }
+
+ /**
+@@ -95,7 +85,7 @@
+ */
+ @InputFile
+ @Optional
+- public RegularFileProperty getBndfile() {
++ public File getBndfile() {
+ return bndfile
+ }
+ /**
+@@ -106,9 +96,7 @@
+ * Project.file().
+ */
+ public void setBndfile(Object file) {
+- bndfile.set(project.layout.file(project.provider({ ->
+- return project.file(file)
+- })))
++ bndfile = project.file(file)
+ }
+
+ /**
+@@ -119,15 +107,15 @@
+ */
+ @Input
+ @Optional
+- public Provider<String> getBnd() {
+- return bndbnd
++ public String getBnd() {
++ return instructions.toString()
+ }
+
+ /**
+ * Set the bnd property from a multi-line string.
+ */
+ public void setBnd(CharSequence line) {
+- instructions.empty()
++ instructions.length = 0
+ bnd(line)
+ }
+
+@@ -135,14 +123,16 @@
+ * Add instuctions to the bnd property from a list of multi-line strings.
+ */
+ public void bnd(CharSequence... lines) {
+- instructions.addAll(lines)
++ lines.each { line ->
++ instructions.append(line).append('\n')
++ }
+ }
+
+ /**
+ * Set the bnd property from a map.
+ */
+ public void setBnd(Map<String, ?> map) {
+- instructions.empty()
++ instructions.length = 0
+ bnd(map)
+ }
+
+@@ -150,9 +140,9 @@
+ * Add instuctions to the bnd property from a map.
+ */
+ public void bnd(Map<String, ?> map) {
+- map.each({ key, value ->
+- instructions.add("${key}=${value}")
+- })
++ map.each { key, value ->
++ instructions.append(key).append('=').append(value).append('\n')
++ }
+ }
+
+ /**
+@@ -194,7 +184,6 @@
+ */
+ public void setSourceSet(SourceSet sourceSet) {
+ this.sourceSet = sourceSet
+- jarLibraryElements(project, sourceSet.compileClasspathConfigurationName)
+ if (!classpathModified) {
+ setClasspath(sourceSet.compileClasspath)
+ classpathModified = false
+@@ -220,16 +209,12 @@
+ }.replaceHere(project.projectDir).store(writer, null)
+
+ // if the bnd file exists, add its contents to the tmp bnd file
+- File bndfile = getBndfile().getOrNull()?.getAsFile()
+ if (bndfile?.isFile()) {
+ builder.loadProperties(bndfile).store(writer, null)
+- } else {
+- String bnd = getBnd().get()
+- if (!bnd.empty) {
+- UTF8Properties props = new UTF8Properties()
+- props.load(bnd, project.buildFile, builder)
+- props.replaceHere(project.projectDir).store(writer, null)
+- }
++ } else if (!bnd.empty) {
++ UTF8Properties props = new UTF8Properties()
++ props.load(bnd, project.buildFile, builder)
++ props.replaceHere(project.projectDir).store(writer, null)
+ }
+ }
+ builder.setProperties(temporaryBndFile, project.projectDir) // this will cause project.dir property to be set
+@@ -245,18 +230,18 @@
+ throw new GradleException('Sub-bundles are not supported by this task')
+ }
+
+- File archiveFile = unwrap(task.archiveFile)
+- String archiveFileName = unwrap(task.archiveFileName)
+- String archiveBaseName = unwrap(task.archiveBaseName)
+- String archiveVersion = unwrap(task.archiveVersion)
++ // Gradle 5.1 deprecates Jar task properties
++ File archivePath = task.hasProperty('archiveFile') ? task.archiveFile.get().asFile : task.archivePath
++ String archiveName = task.hasProperty('archiveFileName') ? task.archiveFileName.get() : task.archiveName
++ String version = task.hasProperty('archiveVersion') ? task.archiveVersion.get() : task.version
+
+ // Include entire contents of Jar task generated jar (except the manifest)
+ project.copy {
+- from archiveFile
++ from archivePath
+ into temporaryDir
+ }
+- File archiveCopyFile = new File(temporaryDir, archiveFileName)
+- Jar bundleJar = new Jar(archiveFileName, archiveCopyFile)
++ File archiveCopyFile = new File(temporaryDir, archiveName)
++ Jar bundleJar = new Jar(archiveName, archiveCopyFile)
+ String reproducible = builder.getProperty(Constants.REPRODUCIBLE)
+ bundleJar.setReproducible((reproducible != null) ? Processor.isTrue(reproducible) : !task.preserveFileTimestamps)
+ bundleJar.updateModified(archiveCopyFile.lastModified(), 'time of Jar task generated jar')
+@@ -264,7 +249,7 @@
+ builder.setJar(bundleJar)
+
+ // set builder classpath
+- ConfigurableFileCollection buildpath = project.files(getClasspath().files.findAll { File file ->
++ ConfigurableFileCollection buildpath = project.files(classpath.files.findAll { File file ->
+ if (!file.exists()) {
+ return false
+ }
+@@ -285,22 +270,22 @@
+ logger.debug 'builder classpath: {}', builder.getClasspath()*.getSource()
+
+ // set builder sourcepath
+- ConfigurableFileCollection sourcepath = project.files(getSourceSet().allSource.srcDirs.findAll{it.exists()})
++ ConfigurableFileCollection sourcepath = project.files(sourceSet.allSource.srcDirs.findAll{it.exists()})
+ builder.setProperty('project.sourcepath', sourcepath.asPath)
+ builder.setSourcepath(sourcepath.files as File[])
+ logger.debug 'builder sourcepath: {}', builder.getSourcePath()
+
+
+- // set bundle symbolic name from tasks's archiveBaseName property if necessary
++ // set bundle symbolic name from tasks's baseName property if necessary
+ String bundleSymbolicName = builder.getProperty(Constants.BUNDLE_SYMBOLICNAME)
+ if (isEmpty(bundleSymbolicName)) {
+- builder.setProperty(Constants.BUNDLE_SYMBOLICNAME, archiveBaseName)
++ builder.setProperty(Constants.BUNDLE_SYMBOLICNAME, baseName)
+ }
+
+- // set bundle version from task's archiveVersion if necessary
++ // set bundle version from task's version if necessary
+ String bundleVersion = builder.getProperty(Constants.BUNDLE_VERSION)
+ if (isEmpty(bundleVersion)) {
+- builder.setProperty(Constants.BUNDLE_VERSION, MavenVersion.parseMavenString(archiveVersion).getOSGiVersion().toString())
++ builder.setProperty(Constants.BUNDLE_VERSION, MavenVersion.parseMavenString(version?.toString()).getOSGiVersion().toString())
+ }
+
+ logger.debug 'builder properties: {}', builder.getProperties()
+@@ -310,24 +295,24 @@
+ if (!builder.isOk()) {
+ // if we already have an error; fail now
+ logReport(builder, logger)
+- failTask("Bundle ${archiveFileName} has errors", archiveFile)
++ failBuild("Bundle ${archiveName} has errors", archivePath)
+ }
+
+ // Write out the bundle
+- builtJar.write(archiveFile)
++ builtJar.write(archivePath)
+ long now = System.currentTimeMillis()
+- archiveFile.setLastModified(now)
++ archivePath.setLastModified(now)
+
+ logReport(builder, logger)
+ if (!builder.isOk()) {
+- failTask("Bundle ${archiveFileName} has errors", archiveFile)
++ failBuild("Bundle ${archiveName} has errors", archivePath)
+ }
+ }
+ }
+ }
+
+- private void failTask(String msg, File archiveFile) {
+- project.delete(archiveFile)
++ private void failBuild(String msg, File archivePath) {
++ project.delete(archivePath)
+ throw new GradleException(msg)
+ }
+
View it on GitLab: https://salsa.debian.org/java-team/bnd/-/commit/500d1d5f9d10d738754d85a3c9f40617064aeb14
--
View it on GitLab: https://salsa.debian.org/java-team/bnd/-/commit/500d1d5f9d10d738754d85a3c9f40617064aeb14
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20200803/6a9f134a/attachment.html>
More information about the pkg-java-commits
mailing list