osgiManifest throws NPE

When adding the fooJar from Chapter 37. The OSGi Plugin task to my build.gradle and running it, a NullPointerException is thrown.

task fooJar(type: Jar) {

manifest = osgiManifest {

instruction ‘Bundle-Vendor’, ‘MyCompany’

} }

11:39:08.965 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 0.054 secs, idle: 0.002 secs 11:39:08.969 [ERROR] [org.gradle.BuildExceptionReporter]

11:39:08.970 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception. 11:39:08.970 [ERROR] [org.gradle.BuildExceptionReporter]

11:39:08.971 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong: 11:39:08.971 [ERROR] [org.gradle.BuildExceptionReporter] Could not copy MANIFEST.MF to ‘*********/build/tmp/fooJar/MANIFEST.MF’. 11:39:08.972 [ERROR] [org.gradle.BuildExceptionReporter] > java.lang.NullPointerException (no error message) 11:39:08.973 [ERROR] [org.gradle.BuildExceptionReporter]

11:39:08.974 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is: 11:39:08.974 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.GradleException: Could not copy MANIFEST.MF to ‘******************/build/tmp/fooJar/MANIFEST.MF’. 11:39:08.975 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:70) 11:39:08.975 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.collections.MapFileTree$FileVisitDetailsImpl.getFile(MapFileTree.java:133) 11:39:08.976 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.AbstractFileTree$1.visitFile(AbstractFileTree.java:39) 11:39:08.976 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTree$1.visitFile(AbstractFileTree.java:145) 11:39:08.977 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.collections.MapFileTree$Visit.visit(MapFileTree.java:103) 11:39:08.977 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.collections.MapFileTree.visit(MapFileTree.java:70) 11:39:08.978 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.collections.FileTreeAdapter.visit(FileTreeAdapter.java:96) 11:39:08.978 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTree.visit(AbstractFileTree.java:136) 11:39:08.978 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.AbstractFileTree.getFiles(AbstractFileTree.java:37) 11:39:08.979 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.CompositeFileCollection.getFiles(CompositeFileCollection.java:39) 11:39:08.979 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.changedetection.state.DefaultFileSnapshotter.snapshot(DefaultFileSnapshotter.java:44) 11:39:08.980 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.changedetection.rules.InputFilesStateChangeRule.create(InputFilesStateChangeRule.java:33) 11:39:08.980 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.changedetection.rules.TaskUpToDateState.(TaskUpToDateState.java:46) 11:39:08.981 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.getStates(DefaultTaskArtifactStateRepository.java:126) 11:39:08.981 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.isUpToDate(DefaultTaskArtifactStateRepository.java:69) 11:39:08.982 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:52) 11:39:08.982 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) 11:39:08.982 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42) 11:39:08.983 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) 11:39:08.983 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) 11:39:08.984 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) 11:39:08.984 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:289) 11:39:08.985 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79) 11:39:08.985 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63) 11:39:08.986 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51) 11:39:08.986 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$1.run(DefaultTaskPlanExecutor.java:33) 11:39:08.986 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.Factories$1.create(Factories.java:22) 11:39:08.987 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:198) 11:39:08.987 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:266) 11:39:08.988 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:135) 11:39:08.988 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.java:95) 11:39:08.988 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:31) 11:39:08.989 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:86) 11:39:08.989 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29) 11:39:08.989 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61) 11:39:08.990 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23) 11:39:08.990 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67) 11:39:09.009 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32) 11:39:09.010 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61) 11:39:09.010 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54) 11:39:09.011 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166) 11:39:09.012 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113) 11:39:09.013 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81) 11:39:09.014 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64) 11:39:09.014 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33) 11:39:09.015 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24) 11:39:09.015 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35) 11:39:09.016 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26) 11:39:09.016 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50) 11:39:09.016 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171) 11:39:09.017 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201) 11:39:09.017 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174) 11:39:09.017 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170) 11:39:09.018 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139) 11:39:09.018 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33) 11:39:09.019 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22) 11:39:09.019 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.Main.doAction(Main.java:46) 11:39:09.019 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45) 11:39:09.020 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.Main.main(Main.java:37) 11:39:09.020 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50) 11:39:09.020 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32) 11:39:09.021 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.GradleMain.main(GradleMain.java:23) 11:39:09.038 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.NullPointerException 11:39:09.038 [ERROR] [org.gradle.BuildExceptionReporter] at aQute.bnd.osgi.Jar.getName(Jar.java:79) 11:39:09.039 [ERROR] [org.gradle.BuildExceptionReporter] at aQute.bnd.osgi.Jar.(Jar.java:69) 11:39:09.039 [ERROR] [org.gradle.BuildExceptionReporter] at aQute.bnd.osgi.Analyzer.setJar(Analyzer.java:833) 11:39:09.039 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.osgi.DefaultOsgiManifest.setAnalyzerProperties(DefaultOsgiManifest.java:125) 11:39:09.040 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.osgi.DefaultOsgiManifest.getEffectiveManifest(DefaultOsgiManifest.java:69) 11:39:09.040 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.osgi.DefaultOsgiManifest_Decorated.getEffectiveManifest(Unknown Source) 11:39:09.040 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.java.archives.internal.DefaultManifest.writeTo(DefaultManifest.java:151) 11:39:09.041 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.java.archives.internal.DefaultManifest.writeTo(DefaultManifest.java:35) 11:39:09.041 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.java.archives.Manifest$writeTo.call(Unknown Source) 11:39:09.042 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.tasks.bundling.Jar$_closure1_closure3.doCall(Jar.groovy:47) 11:39:09.042 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.collections.MapFileTree$FileVisitDetailsImpl.copyTo(MapFileTree.java:151) 11:39:09.042 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.AbstractFileTreeElement.copyFile(AbstractFileTreeElement.java:88) 11:39:09.043 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:65) 11:39:09.043 [ERROR] [org.gradle.BuildExceptionReporter] … 61 more 11:39:09.043 [ERROR] [org.gradle.BuildExceptionReporter]

11:39:09.044 [LIFECYCLE] [org.gradle.BuildResultLogger]

11:39:09.044 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED 11:39:09.045 [LIFECYCLE] [org.gradle.BuildResultLogger]

11:39:09.045 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 4.358 secs

Hi Jan,

Could you provide a complete build script sample that I could use to debug this?