diff --git a/biz.aQute.bnd.gradle/README.md b/biz.aQute.bnd.gradle/README.md index 9bfcd1a91b..e70250c5d9 100644 --- a/biz.aQute.bnd.gradle/README.md +++ b/biz.aQute.bnd.gradle/README.md @@ -8,9 +8,8 @@ specified in the Bnd Workspace's `cnf/build.bnd` file and each project's `bnd.bnd` file to configure the Gradle projects and tasks. The [`biz.aQute.bnd.gradle`][2] jar contains the Bnd Gradle Plugins. -These plugins requires at least Gradle 4.0 for Java 8, at least -Gradle 4.2.1 for Java 9, at least Gradle 4.7 for Java 10, and at -least Gradle 5.0 for Java 11. +These plugins requires at least Gradle 5.1 for Java 8 to Java 12, and at +least Gradle 6.0 for Java 13. This README represents the capabilities and features of the Bnd Gradle Plugins in the branch containing this README. So for the `master` branch, this will be @@ -433,7 +432,7 @@ plus _${project.configurations.archives.artifacts.files}_. The list of fully qualified names of test classes to run. If not set, or empty, Then all the test classes listed in the `Test-Classes` manifest header are -run. In Gradle 4.6 and later, the `--tests` command line option can be used +run. The `--tests` command line option can be used to set the fully qualified name of a test class to run. This can be repeated multiple times to specify multiple test classes to run. diff --git a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/Baseline.groovy b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/Baseline.groovy index 17aea55e0f..e494965b2e 100644 --- a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/Baseline.groovy +++ b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/Baseline.groovy @@ -49,7 +49,6 @@ package aQute.bnd.gradle import static aQute.bnd.gradle.BndUtils.builtBy -import static aQute.bnd.gradle.BndUtils.toTask import aQute.bnd.differ.DiffPluginImpl import aQute.bnd.header.Parameters @@ -68,6 +67,7 @@ import org.gradle.api.tasks.InputFile 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 @@ -214,7 +214,9 @@ public class Baseline extends DefaultTask { Task getBundleTask() { return bundleCollection.getBuiltBy().flatten().findResult { t -> - t = toTask(t) + if (t instanceof TaskProvider) { + t = t.get() + } t instanceof Task && t.convention.findPlugin(BundleTaskConvention.class) ? t : null } } diff --git a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndBuilderPlugin.groovy b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndBuilderPlugin.groovy index ec14866161..c8635ee5f8 100644 --- a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndBuilderPlugin.groovy +++ b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndBuilderPlugin.groovy @@ -19,9 +19,6 @@ package aQute.bnd.gradle -import static aQute.bnd.gradle.BndUtils.configureTask -import static aQute.bnd.gradle.BndUtils.createTask - import org.gradle.api.GradleException import org.gradle.api.Plugin import org.gradle.api.Project @@ -48,7 +45,7 @@ public class BndBuilderPlugin implements Plugin { } plugins.apply 'java' - def jar = configureTask(project, 'jar') { t -> + def jar = tasks.named('jar') { t -> t.description 'Assembles a bundle containing the main classes.' t.convention.plugins.bundle = new BundleTaskConvention(t) def defaultBndfile = project.file('bnd.bnd') @@ -72,7 +69,7 @@ public class BndBuilderPlugin implements Plugin { } } - createTask(project, 'baseline', Baseline.class) { t -> + tasks.register('baseline', Baseline.class) { t -> t.description 'Baseline the project bundle.' t.group 'release' t.bundle jar diff --git a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndPlugin.groovy b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndPlugin.groovy index 0bdb7d0a75..efa256a611 100644 --- a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndPlugin.groovy +++ b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndPlugin.groovy @@ -17,10 +17,6 @@ package aQute.bnd.gradle import static aQute.bnd.exporter.executable.ExecutableJarExporter.EXECUTABLE_JAR import static aQute.bnd.exporter.runbundles.RunbundlesExporter.RUNBUNDLES import static aQute.bnd.gradle.BndUtils.logReport -import static aQute.bnd.gradle.BndUtils.configureEachTask -import static aQute.bnd.gradle.BndUtils.configureTask -import static aQute.bnd.gradle.BndUtils.createTask -import static aQute.bnd.gradle.BndUtils.namedTask import static aQute.bnd.osgi.Processor.isTrue import aQute.lib.strings.Strings @@ -84,13 +80,13 @@ public class BndPlugin implements Plugin { /* Set up configurations */ configurations { - runtime.artifacts.clear() + runtimeOnly.artifacts.clear() archives.artifacts.clear() } /* Set up deliverables */ bndProject.getDeliverables()*.getFile().each { File deliverable -> artifacts { - runtime(deliverable) { + runtimeOnly(deliverable) { builtBy 'jar' } archives(deliverable) { @@ -108,7 +104,7 @@ public class BndPlugin implements Plugin { resources.srcDirs = srcDirs java.outputDir = destinationDir output.resourcesDir = destinationDir - configureTask(project, compileJavaTaskName) { t -> + tasks.named(compileJavaTaskName) { t -> t.destinationDir = destinationDir } output.dir(destinationDir, builtBy: compileJavaTaskName) @@ -120,7 +116,7 @@ public class BndPlugin implements Plugin { resources.srcDirs = srcDirs java.outputDir = destinationDir output.resourcesDir = destinationDir - configureTask(project, compileJavaTaskName) { t -> + tasks.named(compileJavaTaskName) { t -> t.destinationDir = destinationDir } output.dir(destinationDir, builtBy: compileJavaTaskName) @@ -136,7 +132,7 @@ public class BndPlugin implements Plugin { File destinationDir = java.outputDir String compileTaskName = getCompileTaskName(lang) try { - configureTask(project, compileTaskName) { t -> + tasks.named(compileTaskName) { t -> t.destinationDir = destinationDir } sourceDirSet.srcDirs = java.srcDirs @@ -155,7 +151,7 @@ public class BndPlugin implements Plugin { File destinationDir = java.outputDir String compileTaskName = getCompileTaskName(lang) try { - configureTask(project, compileTaskName) { t -> + tasks.named(compileTaskName) { t -> t.destinationDir = destinationDir } sourceDirSet.srcDirs = java.srcDirs @@ -173,10 +169,10 @@ public class BndPlugin implements Plugin { bnd.ext.allSrcDirs = files(bndProject.getAllsourcepath()) /* Set up dependencies */ dependencies { - compile pathFiles(bndProject.getBuildpath()) - runtime files(bndProject.getSrcOutput()) - testCompile pathFiles(bndProject.getTestpath()) - testRuntime files(bndProject.getTestOutput()) + implementation pathFiles(bndProject.getBuildpath()) + runtimeOnly files(bndProject.getSrcOutput()) + testImplementation pathFiles(bndProject.getTestpath()) + testRuntimeOnly files(bndProject.getTestOutput()) } /* Set up compile tasks */ sourceCompatibility = bnd('javac.source', sourceCompatibility) @@ -192,7 +188,7 @@ public class BndPlugin implements Plugin { boolean javacDebug = bndis('javac.debug') boolean javacDeprecation = isTrue(bnd('javac.deprecation', 'true')) String javacEncoding = bnd('javac.encoding', 'UTF-8') - configureEachTask(project, JavaCompile.class) { t -> + tasks.withType(JavaCompile.class).configureEach { t -> configure(t.options) { if (javacDebug) { debugOptions.debugLevel = 'source,lines,vars' @@ -207,11 +203,7 @@ public class BndPlugin implements Plugin { } if (!javacBootclasspath.empty) { fork = true - if (delegate.hasProperty('bootstrapClasspath')) { // gradle 4.3 - bootstrapClasspath = javacBootclasspath - } else { - bootClasspath = javacBootclasspath.asPath - } + bootstrapClasspath = javacBootclasspath } if (!javacProfile.empty) { compilerArgs.addAll(['-profile', javacProfile]) @@ -232,25 +224,19 @@ public class BndPlugin implements Plugin { t.logger.info '-source {} -target {} {}', project.sourceCompatibility, project.targetCompatibility, options.compilerArgs.join(' ') } t.logger.info '-classpath {}', t.classpath.asPath - if (t.options.hasProperty('bootstrapClasspath')) { // gradle 4.3 - if (t.options.bootstrapClasspath != null) { - t.logger.info '-bootclasspath {}', t.options.bootstrapClasspath.asPath - } - } else { - if (t.options.bootClasspath != null) { - t.logger.info '-bootclasspath {}', t.options.bootClasspath - } + if (t.options.bootstrapClasspath != null) { + t.logger.info '-bootclasspath {}', t.options.bootstrapClasspath.asPath } } } } - def jar = configureTask(project, 'jar') { t -> + def jar = tasks.named('jar') { t -> t.description 'Jar this project\'s bundles.' t.actions.clear() /* Replace the standard task actions */ t.enabled !bndProject.isNoBundles() project.configurations.archives.artifacts.files.find { - t.archiveName = it.name /* use first artifact as archiveName */ + t.archiveFileName = it.name /* use first artifact as archiveFileName */ } /* Additional excludes for projectDir inputs */ t.ext.projectDirInputsExcludes = Strings.split(bndMerge(Constants.BUILDERIGNORE)).collect { it.concat('/') } @@ -298,27 +284,27 @@ public class BndPlugin implements Plugin { } } - def jarDependencies = createTask(project, 'jarDependencies') { t -> + def jarDependencies = tasks.register('jarDependencies') { t -> t.description 'Jar all projects this project depends on.' t.dependsOn getBuildDependencies('jar') t.group 'build' } - def buildDependencies = createTask(project, 'buildDependencies') { t -> + def buildDependencies = tasks.register('buildDependencies') { t -> t.description 'Assembles and tests all projects this project depends on.' t.dependsOn getTestDependencies('buildNeeded') t.group 'build' } - def buildNeeded = configureTask(project, 'buildNeeded') { t -> + def buildNeeded = tasks.named('buildNeeded') { t -> t.dependsOn buildDependencies } - def buildDependents = configureTask(project, 'buildDependents') { t -> + def buildDependents = tasks.named('buildDependents') { t -> t.dependsOn getDependents('buildDependents') } - def release = createTask(project, 'release') { t -> + def release = tasks.register('release') { t -> t.description 'Release this project to the release repository.' t.group 'release' t.enabled !bndProject.isNoBundles() && !bnd(Constants.RELEASEREPO, 'unset').empty @@ -333,26 +319,26 @@ public class BndPlugin implements Plugin { } } - def releaseDependencies = createTask(project, 'releaseDependencies') { t -> + def releaseDependencies = tasks.register('releaseDependencies') { t -> t.description 'Release all projects this project depends on.' t.dependsOn getBuildDependencies('releaseNeeded') t.group 'release' } - def releaseNeeded = createTask(project, 'releaseNeeded') { t -> + def releaseNeeded = tasks.register('releaseNeeded') { t -> t.description 'Release this project and all projects it depends on.' t.dependsOn releaseDependencies, release t.group 'release' } - def test = configureTask(project, 'test') { t -> + def test = tasks.named('test') { t -> t.enabled !bndis(Constants.NOJUNIT) && !bndis('no.junit') t.doFirst { checkErrors(t.logger, t.ignoreFailures) } } - def testOSGi = createTask(project, 'testOSGi', TestOSGi.class) { t -> + def testOSGi = tasks.register('testOSGi', TestOSGi.class) { t -> t.description 'Runs the OSGi JUnit tests by launching a framework and running the tests in the launched framework.' t.group 'verification' t.enabled !bndis(Constants.NOJUNITOSGI) && !bndUnprocessed(Constants.TESTCASES, '').empty @@ -360,34 +346,34 @@ public class BndPlugin implements Plugin { t.bndrun = bndProject.getPropertiesFile() } - def check = configureTask(project, 'check') { t -> + def check = tasks.named('check') { t -> t.dependsOn testOSGi } - def checkDependencies = createTask(project, 'checkDependencies') { t -> + def checkDependencies = tasks.register('checkDependencies') { t -> t.description 'Runs all checks on all projects this project depends on.' t.dependsOn getTestDependencies('checkNeeded') t.group 'verification' } - def checkNeeded = createTask(project, 'checkNeeded') { t -> + def checkNeeded = tasks.register('checkNeeded') { t -> t.description 'Runs all checks on this project and all projects it depends on.' t.dependsOn checkDependencies, check t.group 'verification' } - def clean = configureTask(project, 'clean') { t -> + def clean = tasks.named('clean') { t -> t.description 'Cleans the build and compiler output directories of this project.' t.delete project.buildDir, project.sourceSets.main.output, project.sourceSets.test.output } - def cleanDependencies = createTask(project, 'cleanDependencies') { t -> + def cleanDependencies = tasks.register('cleanDependencies') { t -> t.description 'Cleans all projects this project depends on.' t.dependsOn getTestDependencies('cleanNeeded') t.group 'build' } - def cleanNeeded = createTask(project, 'cleanNeeded') { t -> + def cleanNeeded = tasks.register('cleanNeeded') { t -> t.description 'Cleans this project and all projects it depends on.' t.dependsOn cleanDependencies, clean t.group 'build' @@ -397,61 +383,61 @@ public class BndPlugin implements Plugin { include '*.bndrun' } - def export = createTask(project, 'export') { t -> + def export = tasks.register('export') { t -> t.description 'Export all the bndrun files.' t.group 'export' } bndruns.forEach { runFile -> - def subtask = createTask(project, "export.${runFile.name - '.bndrun'}", Export.class) { t -> + def subtask = tasks.register("export.${runFile.name - '.bndrun'}", Export.class) { t -> t.description "Export the ${runFile.name} file." t.dependsOn 'assemble' t.group 'export' t.bndrun = runFile t.exporter = EXECUTABLE_JAR } - configureTask(project, 'export') { t -> + tasks.named('export') { t -> t.dependsOn subtask } } - def runbundles = createTask(project, 'runbundles') { t -> + def runbundles = tasks.register('runbundles') { t -> t.description 'Create a distribution of the runbundles in each of the bndrun files.' t.group 'export' } bndruns.forEach { runFile -> - def subtask = createTask(project, "runbundles.${runFile.name - '.bndrun'}", Export.class) { t -> + def subtask = tasks.register("runbundles.${runFile.name - '.bndrun'}", Export.class) { t -> t.description "Create a distribution of the runbundles in the ${runFile.name} file." t.dependsOn 'assemble' t.group 'export' t.bndrun = runFile t.exporter = RUNBUNDLES } - configureTask(project, 'runbundles') { t -> + tasks.named('runbundles') { t -> t.dependsOn subtask } } - def resolve = createTask(project, 'resolve') { t -> + def resolve = tasks.register('resolve') { t -> t.description 'Resolve the runbundles required for each of the bndrun files.' t.group 'export' } bndruns.forEach { runFile -> - def subtask = createTask(project, "resolve.${runFile.name - '.bndrun'}", Resolve.class) { t -> + def subtask = tasks.register("resolve.${runFile.name - '.bndrun'}", Resolve.class) { t -> t.description "Resolve the runbundles required for ${runFile.name} file." t.dependsOn 'assemble' t.group 'export' t.bndrun = runFile } - configureTask(project, 'resolve') { t -> + tasks.named('resolve') { t -> t.dependsOn subtask } } bndruns.forEach { runFile -> - createTask(project, "run.${runFile.name - '.bndrun'}", Bndrun.class) { t -> + tasks.register("run.${runFile.name - '.bndrun'}", Bndrun.class) { t -> t.description "Run the bndrun file ${runFile.name}." t.dependsOn 'assemble' t.group 'export' @@ -460,7 +446,7 @@ public class BndPlugin implements Plugin { } bndruns.forEach { runFile -> - createTask(project, "testrun.${runFile.name - '.bndrun'}", TestOSGi.class) { t -> + tasks.register("testrun.${runFile.name - '.bndrun'}", TestOSGi.class) { t -> t.description "Runs the OSGi JUnit tests in the bndrun file ${runFile.name}." t.dependsOn 'assemble' t.group 'verification' @@ -468,11 +454,11 @@ public class BndPlugin implements Plugin { } } - def echo = createTask(project, 'echo') { t -> + def echo = tasks.register('echo') { t -> t.description 'Displays the bnd project information.' t.group 'help' - def compileJava = project.tasks.getByName('compileJava') - def compileTestJava = project.tasks.getByName('compileTestJava') + def compileJava = tasks.getByName('compileJava') + def compileTestJava = tasks.getByName('compileTestJava') t.doLast { println """ ------------------------------------------------------------ @@ -491,7 +477,7 @@ project.allsourcepath: ${bnd.allSrcDirs.asPath} project.testsrc: ${project.sourceSets.test.java.sourceDirectories.asPath} project.testoutput: ${compileTestJava.destinationDir} project.testpath: ${compileTestJava.classpath.asPath} -project.bootclasspath: ${compileJava.options.hasProperty('bootstrapClasspath')?compileJava.options.bootstrapClasspath?.asPath?:'':compileJava.options.bootClasspath?:''} +project.bootclasspath: ${compileJava.options.bootstrapClasspath?.asPath?:''} project.deliverables: ${project.configurations.archives.artifacts.files*.path} javac: ${compileJava.options.forkOptions.executable?:'javac'} javac.source: ${project.sourceCompatibility} @@ -502,7 +488,7 @@ javac.profile: ${javacProfile} } } - def bndproperties = createTask(project, 'bndproperties') { t -> + def bndproperties = tasks.register('bndproperties') { t -> t.description 'Displays the bnd properties.' t.group 'help' t.doLast { @@ -534,7 +520,7 @@ Project ${project.name} private Closure getBuildDependencies(String taskName) { return { bndProject.getBuildDependencies().collect { dependency -> - namedTask(project.parent.project(dependency.getName()), taskName) + project.parent.project(dependency.getName()).tasks.named(taskName) } } } @@ -542,7 +528,7 @@ Project ${project.name} private Closure getTestDependencies(String taskName) { return { bndProject.getTestDependencies().collect { dependency -> - namedTask(project.parent.project(dependency.getName()), taskName) + project.parent.project(dependency.getName()).tasks.named(taskName) } } } @@ -550,7 +536,7 @@ Project ${project.name} private Closure getDependents(String taskName) { return { bndProject.getDependents().collect { dependent -> - namedTask(project.parent.project(dependent.getName()), taskName) + project.parent.project(dependent.getName()).tasks.named(taskName) } } } diff --git a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndUtils.groovy b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndUtils.groovy index 3da7448739..e0751dc86b 100644 --- a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndUtils.groovy +++ b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndUtils.groovy @@ -17,8 +17,6 @@ import org.gradle.api.logging.Logger import org.gradle.util.GradleVersion class BndUtils { - private static final boolean IS_GRADLE_MIN_50 = GradleVersion.current().compareTo(GradleVersion.version("5.0"))>=0 - private BndUtils() { } public static void logReport(def report, Logger logger) { @@ -44,72 +42,11 @@ class BndUtils { } } - @CompileStatic - public static Object namedTask(Project project, String name) { - if (IS_GRADLE_MIN_50) { - return project.getTasks().named(name) - } else { - return project.getTasks().getByName(name) - } - } - - @CompileStatic - public static Object configureTask(Project project, String name, Action configuration) { - if (IS_GRADLE_MIN_50) { - return project.getTasks().named(name, configuration) - } else { - return project.getTasks().getByName(name, configuration) - } - } - - @CompileStatic - public static Object createTask(Project project, String name, Action configuration) { - if (IS_GRADLE_MIN_50) { - return project.getTasks().register(name, configuration) - } else { - return project.getTasks().create(name, configuration) - } - } - - @CompileStatic - public static Object createTask(Project project, String name, Class type, Action configuration) { - if (IS_GRADLE_MIN_50) { - return project.getTasks().register(name, type, configuration) - } else { - return project.getTasks().create(name, type, configuration) - } - } - - @CompileStatic - public static void configureEachTask(Project project, Class type, Action configuration) { - if (IS_GRADLE_MIN_50) { - project.getTasks().withType(type).configureEach(configuration) - } else { - project.getTasks().withType(type).all(configuration) - } - } - @CompileStatic public static ConfigurableFileCollection builtBy(ConfigurableFileCollection collection, Object... paths) { - if (IS_GRADLE_MIN_50) { - return collection.builtBy(paths.findAll { path -> - path instanceof Task || path instanceof TaskProvider || path instanceof Buildable - }) - } else { - return collection.builtBy(paths.findAll { path -> - path instanceof Task || path instanceof Buildable - }) - } - } - - @CompileStatic - public static Object toTask(Object t) { - if (IS_GRADLE_MIN_50) { - if (t instanceof TaskProvider) { - return t.get() - } - } - return t + return collection.builtBy(paths.findAll { path -> + path instanceof Task || path instanceof TaskProvider || path instanceof Buildable + }) } @CompileStatic diff --git a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndWorkspacePlugin.groovy b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndWorkspacePlugin.groovy index 66bddd2f79..95e4062379 100644 --- a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndWorkspacePlugin.groovy +++ b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndWorkspacePlugin.groovy @@ -12,8 +12,6 @@ package aQute.bnd.gradle -import static aQute.bnd.gradle.BndUtils.createTask - import aQute.bnd.build.Workspace import aQute.bnd.osgi.Constants @@ -175,7 +173,7 @@ public class BndWorkspacePlugin implements Plugin { Project cnfProject = findProject(bnd_cnf) if (cnfProject != null) { ext.cnf = cnfProject - createTask(cnfProject, 'cleanCache', Delete.class) { t -> + cnfProject.tasks.register('cleanCache', Delete.class) { t -> t.description 'Clean the cache folder.' t.group 'build' t.delete 'cache' diff --git a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BundleTaskConvention.groovy b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BundleTaskConvention.groovy index f63d69957b..c41e6e9015 100644 --- a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BundleTaskConvention.groovy +++ b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BundleTaskConvention.groovy @@ -25,6 +25,7 @@ package aQute.bnd.gradle import static aQute.bnd.gradle.BndUtils.logReport import static aQute.bnd.gradle.BndUtils.builtBy +import static aQute.bnd.gradle.BndUtils.unwrap import java.util.Properties import java.util.jar.Manifest @@ -230,19 +231,18 @@ class BundleTaskConvention { throw new GradleException('Sub-bundles are not supported by this task') } - // 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 baseName = task.hasProperty('archiveBaseName') ? task.archiveBaseName.get() : task.baseName - String version = task.hasProperty('archiveVersion') ? task.archiveVersion.getOrNull() : task.version + File archiveFile = unwrap(task.archiveFile) + String archiveFileName = unwrap(task.archiveFileName) + String archiveBaseName = unwrap(task.archiveBaseName) + String archiveVersion = unwrap(task.archiveVersion) // Include entire contents of Jar task generated jar (except the manifest) project.copy { - from archivePath + from archiveFile into temporaryDir } - File archiveCopyFile = new File(temporaryDir, archiveName) - Jar bundleJar = new Jar(archiveName, archiveCopyFile) + File archiveCopyFile = new File(temporaryDir, archiveFileName) + Jar bundleJar = new Jar(archiveFileName, 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') @@ -277,16 +277,16 @@ class BundleTaskConvention { logger.debug 'builder sourcepath: {}', builder.getSourcePath() - // set bundle symbolic name from tasks's baseName property if necessary + // set bundle symbolic name from tasks's archiveBaseName property if necessary String bundleSymbolicName = builder.getProperty(Constants.BUNDLE_SYMBOLICNAME) if (isEmpty(bundleSymbolicName)) { - builder.setProperty(Constants.BUNDLE_SYMBOLICNAME, baseName) + builder.setProperty(Constants.BUNDLE_SYMBOLICNAME, archiveBaseName) } - // set bundle version from task's version if necessary + // set bundle version from task's archiveVersion if necessary String bundleVersion = builder.getProperty(Constants.BUNDLE_VERSION) if (isEmpty(bundleVersion)) { - builder.setProperty(Constants.BUNDLE_VERSION, MavenVersion.parseMavenString(version?.toString()).getOSGiVersion().toString()) + builder.setProperty(Constants.BUNDLE_VERSION, MavenVersion.parseMavenString(archiveVersion?.toString()).getOSGiVersion().toString()) } logger.debug 'builder properties: {}', builder.getProperties() @@ -296,24 +296,24 @@ class BundleTaskConvention { if (!builder.isOk()) { // if we already have an error; fail now logReport(builder, logger) - failBuild("Bundle ${archiveName} has errors", archivePath) + failBuild("Bundle ${archiveFileName} has errors", archiveFile) } // Write out the bundle - builtJar.write(archivePath) + builtJar.write(archiveFile) long now = System.currentTimeMillis() - archivePath.setLastModified(now) + archiveFile.setLastModified(now) logReport(builder, logger) if (!builder.isOk()) { - failBuild("Bundle ${archiveName} has errors", archivePath) + failBuild("Bundle ${archiveFileName} has errors", archiveFile) } } } } - private void failBuild(String msg, File archivePath) { - project.delete(archivePath) + private void failBuild(String msg, File archiveFile) { + project.delete(archiveFile) throw new GradleException(msg) } diff --git a/biz.aQute.bnd.gradle/test/aQute/bnd/gradle/TestHelper.groovy b/biz.aQute.bnd.gradle/test/aQute/bnd/gradle/TestHelper.groovy index 3775c9851f..8ac3fb5ef5 100644 --- a/biz.aQute.bnd.gradle/test/aQute/bnd/gradle/TestHelper.groovy +++ b/biz.aQute.bnd.gradle/test/aQute/bnd/gradle/TestHelper.groovy @@ -24,15 +24,9 @@ class TestHelper { } private static String gradleVersion() { - if (JavaVersion.current().isJava11Compatible()) { - return '5.0' + if (JavaVersion.current().compareTo(JavaVersion.VERSION_12) > 0) { + return '6.0' } - if (JavaVersion.current().isJava10Compatible()) { - return '4.7' - } - if (JavaVersion.current().isJava9Compatible()) { - return '4.2.1' - } - return '4.0' + return '5.1' } } diff --git a/biz.aQute.bnd.gradle/testresources/baselinetask1/build.gradle b/biz.aQute.bnd.gradle/testresources/baselinetask1/build.gradle index 6605b3aaa5..d39d98eda0 100644 --- a/biz.aQute.bnd.gradle/testresources/baselinetask1/build.gradle +++ b/biz.aQute.bnd.gradle/testresources/baselinetask1/build.gradle @@ -19,15 +19,15 @@ repositories { } dependencies { - compile 'commons-codec:commons-codec:1.5' - compile 'commons-lang:commons-lang:2.6' - testCompile 'junit:junit:4.9' + implementation 'commons-codec:commons-codec:1.5' + implementation 'commons-lang:commons-lang:2.6' + testImplementation 'junit:junit:4.9' } jar { manifest { - attributes('Implementation-Title': baseName, - 'Implementation-Version': version, + attributes('Implementation-Title': project.archivesBaseName, + 'Implementation-Version': project.version, '-includeresource': '{bar.txt}', '-include': 'other.bnd', 'Override': 'This should be overridden by the bnd file' @@ -54,7 +54,7 @@ task baselineSelf(type: Baseline) { description 'Baseline Self' group 'build' bundle jar - baseline jar.archivePath + baseline jar.archiveFile ignoreFailures = false baselineReportDirName = 'foo' } diff --git a/biz.aQute.bnd.gradle/testresources/baselinetask4/build.gradle b/biz.aQute.bnd.gradle/testresources/baselinetask4/build.gradle index dc03cbe06a..fb7973148e 100644 --- a/biz.aQute.bnd.gradle/testresources/baselinetask4/build.gradle +++ b/biz.aQute.bnd.gradle/testresources/baselinetask4/build.gradle @@ -18,16 +18,16 @@ repositories { } dependencies { - compile 'commons-codec:commons-codec:1.5' - compile 'commons-lang:commons-lang:2.6' - testCompile 'junit:junit:4.9' + implementation 'commons-codec:commons-codec:1.5' + implementation 'commons-lang:commons-lang:2.6' + testImplementation 'junit:junit:4.9' baseline ':baselinetask1:1.0.0' } jar { manifest { - attributes('Implementation-Title': baseName, - 'Implementation-Version': version, + attributes('Implementation-Title': project.archivesBaseName, + 'Implementation-Version': project.version, '-includeresource': '{bar.txt}', '-include': 'other.bnd', 'Override': 'This should be overridden by the bnd file' diff --git a/biz.aQute.bnd.gradle/testresources/builderplugin1/build.gradle b/biz.aQute.bnd.gradle/testresources/builderplugin1/build.gradle index 11b85fa1c4..c268e5864b 100644 --- a/biz.aQute.bnd.gradle/testresources/builderplugin1/build.gradle +++ b/biz.aQute.bnd.gradle/testresources/builderplugin1/build.gradle @@ -17,16 +17,16 @@ repositories { } dependencies { - compile 'commons-codec:commons-codec:1.5' - compile 'commons-lang:commons-lang:2.6' - testCompile 'junit:junit:4.9' + implementation 'commons-codec:commons-codec:1.5' + implementation 'commons-lang:commons-lang:2.6' + testImplementation 'junit:junit:4.9' } jar { ext.taskprop = 'prop.task' manifest { - attributes('Implementation-Title': baseName, - 'Implementation-Version': version, + attributes('Implementation-Title': project.archivesBaseName, + 'Implementation-Version': project.version, '-includeresource': '{${.}/bar.txt}', '-include': '${.}/other.bnd', 'Override': 'This should be overridden by the bnd file' @@ -39,13 +39,13 @@ task bundle(type: Bundle) { description 'Bundle' group 'build' from sourceSets.test.output - baseName = baseName+'_bundle' + archiveBaseName = "${project.archivesBaseName}_bundle" bnd = ''' -exportcontents: doubler.impl -sources: true My-Header: my-value text: TEXT -Bundle-Name: ${project.group}:${task.baseName} +Bundle-Name: ${project.group}:${task.archiveBaseName} Project-Name: ${project.name} Project-Dir: ${project.dir} Project-Output: ${project.output} @@ -61,6 +61,6 @@ Project-Buildpath: ${project.buildpath} } artifacts { - runtime bundle + runtimeOnly bundle archives bundle } diff --git a/biz.aQute.bnd.gradle/testresources/indexplugin1/build.gradle b/biz.aQute.bnd.gradle/testresources/indexplugin1/build.gradle index 79cf0f4069..9899c99126 100644 --- a/biz.aQute.bnd.gradle/testresources/indexplugin1/build.gradle +++ b/biz.aQute.bnd.gradle/testresources/indexplugin1/build.gradle @@ -18,16 +18,16 @@ repositories { } dependencies { - compile 'commons-codec:commons-codec:1.5' - compile 'commons-lang:commons-lang:2.6' - testCompile 'junit:junit:4.9' + implementation 'commons-codec:commons-codec:1.5' + implementation 'commons-lang:commons-lang:2.6' + testImplementation 'junit:junit:4.9' } jar { ext.taskprop = 'prop.task' manifest { - attributes('Implementation-Title': baseName, - 'Implementation-Version': version, + attributes('Implementation-Title': project.archivesBaseName, + 'Implementation-Version': project.version, '-includeresource': '{${.}/bar.txt}', '-include': '${.}/other.bnd', 'Override': 'This should be overridden by the bnd file' @@ -39,13 +39,13 @@ task bundle(type: Bundle) { description 'Bundle' group 'build' from sourceSets.test.output - baseName = baseName+'_bundle' + archiveBaseName = "${project.archivesBaseName}_bundle" bnd = ''' -exportcontents: doubler.impl -sources: true My-Header: my-value text: TEXT -Bundle-Name: ${project.group}:${task.baseName} +Bundle-Name: ${project.group}:${task.archiveBaseName} Project-Name: ${project.name} Project-Dir: ${project.dir} Project-Output: ${project.output} @@ -61,7 +61,7 @@ Project-Buildpath: ${project.buildpath} } artifacts { - runtime bundle + runtimeOnly bundle archives bundle } diff --git a/biz.aQute.bnd.gradle/testresources/runtask1/build.gradle b/biz.aQute.bnd.gradle/testresources/runtask1/build.gradle index 027efa09f9..66b34c0cac 100644 --- a/biz.aQute.bnd.gradle/testresources/runtask1/build.gradle +++ b/biz.aQute.bnd.gradle/testresources/runtask1/build.gradle @@ -16,7 +16,7 @@ repositories { dependencies { compileOnly 'org.osgi:osgi.core:5.0.0' - runtime 'org.eclipse.platform:org.eclipse.osgi:3.13.0' + runtimeOnly 'org.eclipse.platform:org.eclipse.osgi:3.13.0' } task run(type: Bndrun) { diff --git a/biz.aQute.bnd.gradle/testresources/testosgitask1/build.gradle b/biz.aQute.bnd.gradle/testresources/testosgitask1/build.gradle index 79bd560bd9..6faa67b8e7 100644 --- a/biz.aQute.bnd.gradle/testresources/testosgitask1/build.gradle +++ b/biz.aQute.bnd.gradle/testresources/testosgitask1/build.gradle @@ -16,8 +16,8 @@ repositories { } dependencies { - compile "biz.aQute.bnd:biz.aQute.junit:${bnd_version}" - runtime 'org.eclipse.platform:org.eclipse.osgi:3.13.0' + implementation "biz.aQute.bnd:biz.aQute.junit:${bnd_version}" + runtimeOnly 'org.eclipse.platform:org.eclipse.osgi:3.13.0' } ext { diff --git a/biz.aQute.bnd.gradle/testresources/testosgitask2/build.gradle b/biz.aQute.bnd.gradle/testresources/testosgitask2/build.gradle index d8fd3e9edf..052a34f1fc 100644 --- a/biz.aQute.bnd.gradle/testresources/testosgitask2/build.gradle +++ b/biz.aQute.bnd.gradle/testresources/testosgitask2/build.gradle @@ -20,7 +20,7 @@ configurations { } dependencies { - compile "biz.aQute.bnd:biz.aQute.junit:${bnd_version}" + implementation "biz.aQute.bnd:biz.aQute.junit:${bnd_version}" framework 'org.eclipse.platform:org.eclipse.osgi:3.13.0' } diff --git a/biz.aQute.bnd.gradle/testresources/testosgitask3/build.gradle b/biz.aQute.bnd.gradle/testresources/testosgitask3/build.gradle index f2fe8eb234..a230427392 100644 --- a/biz.aQute.bnd.gradle/testresources/testosgitask3/build.gradle +++ b/biz.aQute.bnd.gradle/testresources/testosgitask3/build.gradle @@ -20,7 +20,7 @@ configurations { } dependencies { - compile "biz.aQute.bnd:biz.aQute.junit:${bnd_version}" + implementation "biz.aQute.bnd:biz.aQute.junit:${bnd_version}" bundles "biz.aQute.bnd:biz.aQute.junit:${bnd_version}" bundles 'org.eclipse.platform:org.eclipse.osgi:3.13.0' } @@ -30,7 +30,7 @@ task testosgi(type: TestOSGi) { group 'test' inputs.files jar bndrun "${name}.bndrun" - bundles = [configurations.bundles, jar.archivePath] + bundles = [configurations.bundles, jar.archiveFile] } check { diff --git a/biz.aQute.bnd.gradle/testresources/testosgitask4/build.gradle b/biz.aQute.bnd.gradle/testresources/testosgitask4/build.gradle index fd3f1b0dfb..41e13009bd 100644 --- a/biz.aQute.bnd.gradle/testresources/testosgitask4/build.gradle +++ b/biz.aQute.bnd.gradle/testresources/testosgitask4/build.gradle @@ -16,8 +16,8 @@ repositories { } dependencies { - compile "biz.aQute.bnd:biz.aQute.junit:${bnd_version}" - runtime 'org.eclipse.platform:org.eclipse.osgi:3.13.0' + implementation "biz.aQute.bnd:biz.aQute.junit:${bnd_version}" + runtimeOnly 'org.eclipse.platform:org.eclipse.osgi:3.13.0' } task testosgiIgnoreFail(type: TestOSGi) {