Skip to content
Browse files

400901 add support for customizing manifests of nested jars

add support for build.properties entries#

manifest.*=...

allowing to specify a custom manifest for a nested jar. See
docs [1]

[1] http://help.eclipse.org/juno/index.jsp?topic=/org.eclipse.pde.doc.user/reference/pde_feature_generating_build.htm

Bug: 400901
Change-Id: I99c3a6d7e07f5ff4594fb7af35d3a23e90401a6f
  • Loading branch information...
1 parent 3db2338 commit eaa3a9a622e3262c8e62df5692ef4d00f4ab8c23 @jsievers jsievers committed Feb 15, 2013
View
5 ...clipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/facade/BuildProperties.java
@@ -50,6 +50,11 @@
public Map<String, String> getJarToOutputFolderMap();
+ /**
+ * Custom manifests for nested jars
+ */
+ public Map<String, String> getJarToManifestMap();
+
public Map<String, String> getRootEntries();
public Map<String, List<String>> getJarToSourceFolderMap();
View
10 ...se.tycho.core.shared/src/main/java/org/eclipse/tycho/core/facade/BuildPropertiesImpl.java
@@ -42,6 +42,7 @@
private Map<String, List<String>> jarToExtraClasspathMap;
private Map<String, String> jarToJavacDefaultEncodingMap;
private Map<String, String> jarToOutputFolderMap;
+ private Map<String, String> jarToManifestMap;
private Map<String, String> rootEntries;
public BuildPropertiesImpl(File propsFile) {
@@ -68,6 +69,7 @@ public BuildPropertiesImpl(Properties properties) {
HashMap<String, List<String>> jarToExtraClasspathTmp = new HashMap<String, List<String>>();
HashMap<String, String> jarToJavacDefaultEncodingTmp = new HashMap<String, String>();
HashMap<String, String> jarToOutputFolderMapTmp = new HashMap<String, String>();
+ HashMap<String, String> jarToManifestMapTmp = new HashMap<String, String>();
HashMap<String, String> rootEntriesTmp = new HashMap<String, String>();
for (Entry<Object, Object> entry : properties.entrySet()) {
@@ -85,6 +87,9 @@ public BuildPropertiesImpl(Properties properties) {
} else if (key.startsWith("output.")) {
String jarName = key.substring("output.".length());
jarToOutputFolderMapTmp.put(jarName, value);
+ } else if (key.startsWith("manifest.")) {
+ String jarName = key.substring("manifest.".length());
+ jarToManifestMapTmp.put(jarName, value);
} else if (key.startsWith("root.") || key.equals("root")) {
rootEntriesTmp.put(key, value);
}
@@ -93,6 +98,7 @@ public BuildPropertiesImpl(Properties properties) {
jarToExtraClasspathMap = unmodifiableMap(jarToExtraClasspathTmp);
jarToJavacDefaultEncodingMap = unmodifiableMap(jarToJavacDefaultEncodingTmp);
jarToOutputFolderMap = unmodifiableMap(jarToOutputFolderMapTmp);
+ jarToManifestMap = unmodifiableMap(jarToManifestMapTmp);
rootEntries = unmodifiableMap(rootEntriesTmp);
}
@@ -194,6 +200,10 @@ public String getJavacTarget() {
return jarToOutputFolderMap;
}
+ public Map<String, String> getJarToManifestMap() {
+ return jarToManifestMap;
+ }
+
public String getJreCompilationProfile() {
return jreCompilationProfile;
}
View
11 tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/PackagePluginMojo.java
@@ -128,11 +128,22 @@ private void createSubJars() throws MojoExecutionException {
private File makeJar(BuildOutputJar jar) throws MojoExecutionException {
String jarName = jar.getName();
+ BuildProperties buildProperties = pdeProject.getBuildProperties();
+ String customManifest = buildProperties.getJarToManifestMap().get(jarName);
try {
File jarFile = new File(project.getBasedir(), jarName);
JarArchiver archiver = new JarArchiver();
archiver.setDestFile(jarFile);
archiver.addDirectory(jar.getOutputDirectory());
+ if (customManifest != null) {
+ for (File sourceFolder : jar.getSourceFolders()) {
+ File manifestFile = new File(sourceFolder, customManifest);
+ if (manifestFile.isFile()) {
+ archiver.setManifest(manifestFile);
+ break;
+ }
+ }
+ }
archiver.createArchive();
return jarFile;
} catch (Exception e) {
View
15 ...kaging-plugin/src/test/java/org/eclipse/tycho/buildnumber/test/PackagePluginMojoTest.java
@@ -81,6 +81,21 @@ public void testBinIncludesSpaces() throws Exception {
}
}
+ public void testCustomManifestNestedJar() throws Exception {
+ File basedir = getBasedir("projects/customManifestNestedJar");
+ File classes = new File(basedir, "target/classes");
+ classes.mkdirs();
+ PackagePluginMojo mojo = execMaven(basedir);
+ mojo.execute();
+
+ JarFile nestedJar = new JarFile(new File(basedir, "nested.jar"));
+ try {
+ assertEquals("nested", nestedJar.getManifest().getMainAttributes().getValue("Bundle-SymbolicName"));
+ } finally {
+ nestedJar.close();
+ }
+ }
+
public void testNoManifestVersion() throws Exception {
File basedir = getBasedir("projects/noManifestVersion");
PackagePluginMojo mojo = execMaven(basedir);
View
5 ...packaging-plugin/src/test/resources/projects/customManifestNestedJar/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: bundle;singleton:=true
+Bundle-Version: 0.0.1.qualifier
+Bundle-Name: bundle
+Bundle-ClassPath: nested.jar
View
3 tycho-packaging-plugin/src/test/resources/projects/customManifestNestedJar/build.properties
@@ -0,0 +1,3 @@
+source.nested.jar = src/
+manifest.nested.jar = META-INF/MANIFEST.MF
+bin.includes = META-INF/,nested.jar
View
25 tycho-packaging-plugin/src/test/resources/projects/customManifestNestedJar/pom.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>noManifestVersion</groupId>
+ <artifactId>bundle</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-packaging-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <buildDirectory>target/projects/customManifestNestedJar/target</buildDirectory>
+ <finalName>test</finalName>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
View
4 ...aging-plugin/src/test/resources/projects/customManifestNestedJar/src/META-INF/MANIFEST.MF
@@ -0,0 +1,4 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: nested
+Bundle-Version: 1.0.0
+Bundle-Name: nested

0 comments on commit eaa3a9a

Please sign in to comment.
Something went wrong with that request. Please try again.