[GRADLE-1282] OsgiManifest.writeTo fails on clean build Created: 03/Jan/11  Updated: 10/Feb/17  Resolved: 10/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: 0.9.1
Fix Version/s: None

Type: Bug
Reporter: Emil Sit Assignee: Unassigned
Resolution: Won't Fix Votes: 0


 Description   

If you apply the following patch to samples/osgi/build.gradle, a clean build fails with the appended error trace.

— /opt/gradle-0.9.1/samples/osgi/build.gradle 2011-01-02 11:44:22.000000000 -0500
+++ build.gradle 2011-01-03 18:06:34.000000000 -0500
@@ -22,5 +22,6 @@
instruction 'Import-Package', '*'
instruction 'Export-Package', '*'
attributes( 'Built-By': gradle.gradleVersion )
+ writeTo "META-INF/MANIFEST.MF"
}
}

$ gradle -s -d
19:22:33.549 [INFO] [org.gradle.BuildLogger] Starting Build
19:22:33.564 [DEBUG] [org.gradle.BuildLogger] Gradle user home: /home/sit/.gradle
19:22:33.568 [DEBUG] [org.gradle.BuildLogger] Current dir: /tmp/osgi
19:22:33.569 [DEBUG] [org.gradle.BuildLogger] Settings file: null
19:22:33.570 [DEBUG] [org.gradle.BuildLogger] Build file: null
19:22:33.584 [DEBUG] [org.gradle.BuildLogger] Select default project: with project directory '/tmp/osgi'
19:22:33.630 [DEBUG] [org.gradle.initialization.BuildSourceBuilder] Starting to build the build sources.
19:22:33.633 [DEBUG] [org.gradle.initialization.BuildSourceBuilder] Gradle source dir does not exist. We leave.
19:22:33.637 [DEBUG] [org.gradle.initialization.DefaultGradlePropertiesLoader] Found env project properties: []
19:22:33.641 [DEBUG] [org.gradle.initialization.DefaultGradlePropertiesLoader] Found system project properties: []
19:22:34.405 [DEBUG] [org.gradle.initialization.ScriptEvaluatingSettingsProcessor] Timing: Processing settings took: 0.761 secs
19:22:34.406 [INFO] [org.gradle.BuildLogger] Settings evaluated using empty settings file.
19:22:34.410 [DEBUG] [org.gradle.initialization.BuildLoader] Loading Project objects
19:22:34.582 [DEBUG] [org.gradle.initialization.BuildLoader] Looking for project properties from: /tmp/osgi/gradle.properties
19:22:34.584 [DEBUG] [org.gradle.initialization.BuildLoader] project property file does not exists. We continue!
19:22:34.591 [DEBUG] [org.gradle.initialization.BuildLoader] Timing: Loading projects took: 0.18 secs
19:22:34.592 [INFO] [org.gradle.BuildLogger] Projects loaded. Root project using build file '/tmp/osgi/build.gradle'.
19:22:34.607 [INFO] [org.gradle.BuildLogger] Included projects: [root project 'osgi']
19:22:34.619 [INFO] [org.gradle.configuration.BuildScriptProcessor] Evaluating root project 'osgi' using build file '/tmp/osgi/build.gradle'.
19:22:35.856 [DEBUG] [org.gradle.messaging.remote.internal.TcpOutgoingConnector] Found loop-back addresses: [/0:0:0:0:0:0:0:1%1, /127.0.0.1].
19:22:36.467 [DEBUG] [org.gradle.configuration.BuildScriptProcessor] Timing: Running the build script took 1.847 secs
19:22:36.507 [ERROR] [org.gradle.BuildExceptionReporter]
19:22:36.512 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
19:22:36.514 [ERROR] [org.gradle.BuildExceptionReporter]
19:22:36.515 [ERROR] [org.gradle.BuildExceptionReporter] * Where:
19:22:36.516 [ERROR] [org.gradle.BuildExceptionReporter] Build file '/tmp/osgi/build.gradle' line: 25
19:22:36.517 [ERROR] [org.gradle.BuildExceptionReporter]
19:22:36.521 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
19:22:36.522 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred evaluating root project 'osgi'.
19:22:36.530 [ERROR] [org.gradle.BuildExceptionReporter] Cause: java.util.zip.ZipException: The JAR/ZIP file (/tmp/osgi/build/classes/main) seems corrupted, error: error in opening zip file
19:22:36.535 [ERROR] [org.gradle.BuildExceptionReporter]
19:22:36.536 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
19:22:36.540 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.LocationAwareGradleScriptException: Build file '/tmp/osgi/build.gradle' line: 25
19:22:36.543 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred evaluating root project 'osgi'.
19:22:36.544 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.groovy.scripts.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:51)
19:22:36.546 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:127)
19:22:36.548 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptProcessor.java:38)
19:22:36.549 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.DefaultProjectEvaluator.evaluate(DefaultProjectEvaluator.java:38)
19:22:36.550 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:506)
19:22:36.552 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:71)
19:22:36.553 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:23)
19:22:36.554 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:21)
19:22:36.556 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.DefaultBuildConfigurer$1.execute(DefaultBuildConfigurer.java:38)
19:22:36.562 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.DefaultBuildConfigurer$1.execute(DefaultBuildConfigurer.java:36)
19:22:36.566 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:482)
19:22:36.568 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:477)
19:22:36.569 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
19:22:36.572 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:136)
19:22:36.573 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:107)
19:22:36.576 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:75)
19:22:36.577 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:41)
19:22:36.578 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:27)
19:22:36.579 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:209)
19:22:36.580 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:193)
19:22:36.581 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.Main.execute(Main.java:55)
19:22:36.582 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.Main.main(Main.java:40)
19:22:36.582 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:46)
19:22:36.589 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:28)
19:22:36.589 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
19:22:36.595 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.util.UncheckedException: java.util.zip.ZipException: The JAR/ZIP file (/tmp/osgi/build/classes/main) seems corrupted, error: error in opening zip file
19:22:36.596 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.util.UncheckedException.asUncheckedException(UncheckedException.java:31)
19:22:36.596 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.osgi.DefaultOsgiManifest.getEffectiveManifest(DefaultOsgiManifest.java:74)
19:22:36.613 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.java.archives.internal.DefaultManifest.writeTo(DefaultManifest.java:152)
19:22:36.614 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.java.archives.internal.DefaultManifest.writeTo(DefaultManifest.java:168)
19:22:36.615 [ERROR] [org.gradle.BuildExceptionReporter] at build_4cti90gs8u8f92a6u1fikseqnh$_run_closure3_closure4.doCall(/tmp/osgi/build.gradle:25)
19:22:36.616 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:61)
19:22:36.616 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:31)
19:22:36.617 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.util.ConfigureUtil$configure.call(Unknown Source)
19:22:36.619 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.tasks.bundling.Jar.manifest(Jar.groovy:88)
19:22:36.620 [ERROR] [org.gradle.BuildExceptionReporter] at build_4cti90gs8u8f92a6u1fikseqnh$_run_closure3.doCall(/tmp/osgi/build.gradle:18)
19:22:36.621 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:61)
19:22:36.626 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:31)
19:22:36.659 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.DefaultNamedDomainObjectContainer$ContainerElementsDynamicObject.invokeMethod(DefaultNamedDomainObjectContainer.java:307)
19:22:36.662 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:93)
19:22:36.663 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:93)
19:22:36.664 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:93)
19:22:36.665 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.DefaultProject_Decorated.invokeMethod(Unknown Source)
19:22:36.678 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.groovy:68)
19:22:36.679 [ERROR] [org.gradle.BuildExceptionReporter] at build_4cti90gs8u8f92a6u1fikseqnh.run(/tmp/osgi/build.gradle:17)
19:22:36.679 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.groovy.scripts.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:49)
19:22:36.683 [ERROR] [org.gradle.BuildExceptionReporter] ... 24 more
19:22:36.684 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.util.zip.ZipException: The JAR/ZIP file (/tmp/osgi/build/classes/main) seems corrupted, error: error in opening zip file
19:22:36.684 [ERROR] [org.gradle.BuildExceptionReporter] at aQute.lib.osgi.ZipResource.build(ZipResource.java:59)
19:22:36.685 [ERROR] [org.gradle.BuildExceptionReporter] at aQute.lib.osgi.ZipResource.build(ZipResource.java:33)
19:22:36.691 [ERROR] [org.gradle.BuildExceptionReporter] at aQute.lib.osgi.Jar.<init>(Jar.java:36)
19:22:36.692 [ERROR] [org.gradle.BuildExceptionReporter] at aQute.lib.osgi.Jar.<init>(Jar.java:55)
19:22:36.693 [ERROR] [org.gradle.BuildExceptionReporter] at aQute.lib.osgi.Analyzer.setJar(Analyzer.java:699)
19:22:36.699 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.osgi.DefaultOsgiManifest.setAnalyzerProperties(DefaultOsgiManifest.java:90)
19:22:36.700 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.osgi.DefaultOsgiManifest.getEffectiveManifest(DefaultOsgiManifest.java:64)
19:22:36.700 [ERROR] [org.gradle.BuildExceptionReporter] ... 42 more
19:22:36.701 [ERROR] [org.gradle.BuildExceptionReporter]
19:22:36.706 [LIFECYCLE] [org.gradle.BuildResultLogger]
19:22:36.707 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
19:22:36.708 [LIFECYCLE] [org.gradle.BuildResultLogger]
19:22:36.815 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 4.554 secs



 Comments   
Comment by Emil Sit [ 04/Jan/11 ]

A work-around is to call it in a separate task that depends on the jar. e.g.,

// Work around GRADLE-1282
task generateManifest(dependsOn: jar) << {
    jar.manifest.writeTo("META-INF/MANIFEST.MF")
}
// Optionally...
build.dependsOn(generateManifest)

Incidentally, adding inputs and outputs to the generateManifest task doesn't help because the manifest is always updated with the generation time.

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 10/Feb/17 ]

Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved.

Generated at Wed Jun 30 11:51:34 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.