Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323108

Summary: Xtext generator should not touch MANIFEST.MF if no changes are necessary
Product: [Modeling] TMF Reporter: Daniel Weber <daniel.weber.dev>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: jan, karsten.thoms, sebastian.zarnekow, sven.efftinge
Version: 1.0.0Flags: jan: juno+
Target Milestone: M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Hack (as stated in the comment) was there for other sections, added the same for import-package sven.efftinge: iplog+

Description Daniel Weber CLA 2010-08-19 04:31:30 EDT
Build Identifier: I20100608-0911

When running the .mwe2 workflow for an Xtext grammar, it tries to write to the UI project's manifest although nothing has to be changed (the merged manifest is the same as the one on disk). As our SCM (Perforce) makes files read-only by default, we run into an exception in this case (see below).

Change detection seems to work fine if I change e.g. Bundle-Vendor or if I add more required bundles. But if I add an imported package, the merge algorithm seems to detect changes although it should not.

Reproducible: Always

Steps to Reproduce:
1. Create a new Xtext project, using default values in the wizard, no generator project
2. In the UI project's MANIFEST.MF, add an additional imported package (e.g. antlr)
3. Make /org.xtext.example.mydsl.ui/META-INF/MANIFEST.MF read-only
4. run /org.xtext.example.mydsl/src/org/xtext/example/mydsl/GenerateMyDsl.mwe2

==> 
org.eclipse.emf.common.util.WrappedException: java.io.FileNotFoundException: ..\org.xtext.example.mydsl.ui\META-INF\MANIFEST.MF (Zugriff verweigert)
	at org.eclipse.xtext.generator.Generator.mergeManifest(Generator.java:353)
	at org.eclipse.xtext.generator.Generator.generateManifestUi(Generator.java:390)
	at org.eclipse.xtext.generator.Generator.invokeInternal(Generator.java:118)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
	at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
	at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:31)
	at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:80)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
Caused by: java.io.FileNotFoundException: ..\org.xtext.example.mydsl.ui\META-INF\MANIFEST.MF (Zugriff verweigert)
	at java.io.FileOutputStream.open(Native Method)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
	at org.eclipse.xtext.generator.Generator.mergeManifest(Generator.java:348)
Comment 1 Daniel Weber CLA 2010-08-19 04:34:46 EDT
P.S.: As a workaround, I disabled manifest merging for the time being.
Comment 2 Karsten Thoms CLA 2010-08-19 04:48:30 EDT
What a coincidence :-) Although we use SVN here a new project policy enforces that no source file must be touched during a build. The sources are write protected, and we stumbled yesterday over the same issue.

Setting the mergeManifest property to false is no option, since we also don't want to have the generated manifest.

So +1 for this bug from my side.
Comment 3 Daniel Weber CLA 2010-08-19 06:46:48 EDT
Created attachment 176978 [details]
Hack (as stated in the comment) was there for other sections, added the same for import-package

According to the sources, there is a "hack" in org.eclipse.xtext.generator/src/org/eclipse/xtext/generator/MergeableManifest.java 

   // hack: reconstruct linebreaks
   addRequiredBundles(Collections.<String>emptySet());
   addExportedPackages(Collections.<String>emptySet());

The patch I just attached adds another line calling addImportedPackages. This seems to fix the problem I encountered, but I did not dig any deeper to check how a clean solution could replace the hack ;)
Comment 4 Jan Koehnlein CLA 2012-02-24 09:33:25 EST
MergeableManifest has been moved in the meantime. Applied the patch to org.eclipse.xtext.util.MergeableManifest. Works fine. Pushed to MASTER.
Comment 5 Eclipse Webmaster CLA 2017-10-31 11:30:59 EDT
Requested via bug 522520.

-M.