Bug 377249 - [manifest] manifest line not terminated by a linebreak silently ignored
Summary: [manifest] manifest line not terminated by a linebreak silently ignored
Status: REOPENED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-20 03:14 EDT by Arturs Licis CLA
Modified: 2021-04-28 16:54 EDT (History)
5 users (show)

See Also:


Attachments
Example, as provided in 'steps to reporoduce' (2.65 KB, application/x-zip-compressed)
2012-04-20 03:16 EDT, Arturs Licis CLA
no flags Details
MANIFEST editor error (29.83 KB, image/png)
2012-04-20 08:47 EDT, Jan Sievers CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arturs Licis CLA 2012-04-20 03:14:42 EDT
Build Identifier: Indigo - 201106220900

When building manifest-first Eclipse plug-ins, Tycho considers MANIFEST.MF provided, and produces slightly modified MANIFEST.MF in a target. When 'Export-Package: ' header is placed after 'Import-Package: ', Tycho ignores it, and doesn't include in target. This structure seems to be valid, as we used this structure of MANIFEST.MF along with working plugins.
Example of MANIFEST.MF (Export-Package at the end, and will be ignored by Tycho):

Manifest-Version: 1.0
Bundle-Version: 1.0.0.qualifier
Tool: Bnd-0.0.357
Bundle-Name: first-bundle
Bnd-LastModified: 1334819004300
Created-By: 1.6.0_25 (Sun Microsystems Inc.)
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.mydemo.first-bundle
Import-Package: org.codehaus.plexus.util
Bundle-Localization: plugin
Export-Package: org.mydemo


Reproducible: Always

Steps to Reproduce:
1. Create very simple project to be built with Tycho; packagin = 'eclipse-plugin'. Example of such POM file is:

<project xmlns="http://maven.apache.org/POM/4.0.0"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
		http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	
	<groupId>org.mydemo</groupId>
	<artifactId>org.mydemo.first-bundle</artifactId>
	
	<packaging>eclipse-plugin</packaging>
	<version>1.0.0-SNAPSHOT</version>

	<properties>
		<tycho.ver>0.14.1</tycho.ver>
	</properties>
	
	<repositories>
		<repository>
			<id>helios</id>
			<layout>p2</layout>
			<url>http://download.eclipse.org/releases/indigo</url>
		</repository>
	</repositories>

	<build>	
		<plugins>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-maven-plugin</artifactId>
				<version>${tycho.ver}</version>
				<extensions>true</extensions>
			</plugin>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>target-platform-configuration</artifactId>
				<version>${tycho.ver}</version>
				<configuration>
					<pomDependencies>consider</pomDependencies>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

2. Provide the following MANIFEST.MF in META-INF:

Manifest-Version: 1.0
Bundle-Version: 1.0.0.qualifier
Tool: Bnd-0.0.357
Bundle-Name: first-bundle
Bnd-LastModified: 1334819004300
Created-By: 1.6.0_25 (Sun Microsystems Inc.)
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.mydemo.first-bundle
Import-Package: org.codehaus.plexus.util
Bundle-Localization: plugin
Export-Package: org.mydemo

3. create some very simple package in src/main/java -- in this case org/mydemo

4. Try building, and the target MANIFEST.MF looks as following (notice there's no Export-Package): 

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: 1.6.0_25 (Sun Microsystems Inc.)
Built-By: arturs.licis
Build-Jdk: 1.6.0_25
Bundle-Version: 1.0.0.201204200712
Tool: Bnd-0.0.357
Bundle-Localization: plugin
Bnd-LastModified: 1334819004300
Bundle-Name: first-bundle
Bundle-ManifestVersion: 2
Import-Package: org.codehaus.plexus.util
Bundle-SymbolicName: org.mydemo.first-bundle
Comment 1 Arturs Licis CLA 2012-04-20 03:16:43 EDT
Created attachment 214289 [details]
Example, as provided in 'steps to reporoduce'
Comment 2 Jan Sievers CLA 2012-04-20 05:30:43 EDT

*** This bug has been marked as a duplicate of bug 376543 ***
Comment 3 Arturs Licis CLA 2012-04-20 08:10:43 EDT
build.properties was missing because I tried to create a minimalistic example, and was not aware of issue you've marked as duplicated. Adding build.properties does not solve the issue I've describe, and Export-Package is still removed.
Comment 4 Jan Sievers CLA 2012-04-20 08:47:15 EDT
last line in MANIFEST.MF not terminated by a line break, see screenshot
Comment 5 Jan Sievers CLA 2012-04-20 08:47:45 EDT
Created attachment 214302 [details]
MANIFEST editor error
Comment 6 Arturs Licis CLA 2012-04-20 09:06:36 EDT
Yes, that was the case -- missing line break. I wonder if Eclipse is able to read such plug-ins, because I faced this problem when tried to migrate builds of existing plug-ins. 

Since Tycho parses MANIFEST.MF, and creates a modified version, warning about some line being ignored is a nice to have.
Comment 7 Tobias Oberlies CLA 2012-05-23 11:54:53 EDT
Probably the build should fail in this case, right?
Comment 8 Jan Sievers CLA 2012-05-23 12:08:28 EDT
(In reply to comment #7)
> Probably the build should fail in this case, right?

Ideally yes, but the MANIFEST parser we are using (org.eclipse.osgi.framework.util.Headers ) seems to be lenient in this regard.
Need to investigate which parser the PDE MANIFEST editor is using and whether it's possible or worth it using a stricter parser.
Comment 9 Jan Sievers CLA 2012-05-29 09:37:54 EDT
PDE UI has a more strict manifest parser [1] which causes the problem to be detected as in editor screenshot, but it's too entangled with PDE for reuse in tycho.

BND has a bundle verifier but it's on semantic level only and reuses java.util.jar.Manifest for low-level parsing which does not detect missing linebreaks neither [2].

For now I don't think we can catch the missing line break problem with acceptable effort.

[1] http://git.eclipse.org/c/pde/eclipse.pde.ui.git/tree/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/JarManifestErrorReporter.java#n109

[2] https://github.com/bndtools/bnd/blob/master/biz.aQute.bndlib/src/aQute/lib/osgi/Verifier.java#L190
Comment 10 Tobias Oberlies CLA 2012-05-31 11:42:14 EDT
Could we not combine our currently used parser with an additional end of file check? AFAIK, the last characters in a MANIFEST.MF must always be a line break.
Comment 11 Kai Zimmermann CLA 2013-02-28 09:03:09 EST
"AFAIK, the last characters in a MANIFEST.MF must always be a line break."

:( Could you throw an error or add the missing line break?
Comment 12 Jan Sievers CLA 2013-02-28 09:46:02 EST
(In reply to comment #11)
> "AFAIK, the last characters in a MANIFEST.MF must always be a line break."
> 
> :( Could you throw an error or add the missing line break?

see PDE discussion on bug 256787

basically the only manifest parser implementation I know of which handles the missing line break correctly/fixes it automatically for you is in PDE.

As of now PDE parser can't be easily reused as 

1. it's not available as a maven artifact
2. it will drag in lots of unwanted dependencies

MANIFEST format is known to be obscure (e.g. 72 *byte* line length limit etc.) and not editable by humans without proper editor support.

For now I have to say if you use anything else than the PDE manifest editor to edit MANIFEST files, you are doomed.
Comment 13 Frank Gasdorf CLA 2019-01-30 16:28:52 EST
Just created a gerrit changeset to add validation of Manifest-Files regarding missing empty line at the end of it: https://git.eclipse.org/r/136046
Comment 14 Mickael Istria CLA 2021-04-08 18:09:14 EDT
Eclipse Tycho is moving away from this bugs.eclipse.org issue tracker to https://github.com/eclipse/tycho/issues/ instead. If this issue is relevant to you, your action is required.
0. Verify this issue is still happening with latest Tycho 2.4.0-SNAPSHOT
  if issue has disappeared, please change status of this issue to "CLOSED WORKFORME" with some details about your testing environment and how you did verify the issue; and you're done
  if issue is still present when latest release:
* Create a new issue at https://github.com/eclipse/tycho/issues/
  ** Use as title in GitHub the title of this Bugzilla ticket (may include the bug number or not, at your own convenience)
  ** In the GitHub description, start with a link to this bugzilla ticket
  ** Optionally add new content to the description if it can helps towards resolution
  ** Submit GitHub issue
* Update bugzilla ticket
  ** Add to "See also" property (up right column) the link to the newly created GitHub issue
  ** Add a comment "Migrated to <link-to-newly-created-GitHub-issue>"
  ** Set status as CLOSED MOVED
  ** Submit

All issues that remain open will be automatically closed next week or so. Then the Bugzilla component for Tycho will be archived and made read-only.