Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format the generated manifest #1029

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*******************************************************************************
* Copyright (c) 2023 Christoph Läubrich and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christoph Läubrich - initial API and implementation
*******************************************************************************/
package org.eclipse.pde.internal.core.bnd;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.jar.Manifest;

import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.pde.internal.core.util.ManifestUtils;
import org.osgi.framework.BundleException;

import aQute.bnd.osgi.ManifestResource;

public class FormatedManifestResource extends ManifestResource {

public FormatedManifestResource(Manifest manifest) {
super(manifest);
}

@Override
public void write(OutputStream out) throws IOException {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
super.write(bout);
try {
Map<String, String> map = ManifestElement.parseBundleManifest(new ByteArrayInputStream(bout.toByteArray()),
null);
try (OutputStreamWriter writer = new OutputStreamWriter(out, StandardCharsets.UTF_8)) {
ManifestUtils.writeManifest(map, writer);
}
} catch (BundleException e) {
throw new IOException("invalid manifest", e); //$NON-NLS-1$
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public ProjectJar(IProject project, Predicate<IResource> filter) throws CoreExce
@Override
public void setManifest(Manifest manifest) {
super.setManifest(manifest);
ManifestResource resource = new ManifestResource(manifest);
ManifestResource resource = new FormatedManifestResource(manifest);
// We must handle this with a little care here, first we put it as a
// resource, what will make other parts of BND find it and copy it to
// the output location(so it can be found when using the output as a
Expand Down
Loading