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

Add support for building multi-release jars (automatic!) #5359

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions biz.aQute.bndlib.tests/test/aQute/bnd/osgi/AnalyzerTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package aQute.bnd.osgi;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.Optional;
import java.util.jar.Manifest;

import org.junit.jupiter.api.Test;

import aQute.lib.io.IO;

public class AnalyzerTest {

@Test
Expand All @@ -13,4 +20,36 @@ public void testdoNameSection() throws Exception {
}
}

@Test
public void multiRelease() throws Exception {
try (Analyzer a = new Analyzer(new Jar("test"))) {
a.setProperty("Multi-Release", "true");
assertThat(a.check()).isTrue();
Jar jar = a.getJar();
String fooPath = "test/Foo.class";
String barPath = "test/Bar.class";
jar.putResource(fooPath,
new FileResource(IO.getFile("testresources/mr/java8/Foo.class")));
jar.putResource(barPath,
new FileResource(IO.getFile("testresources/mr/java8/Bar.class")));
jar.putVersionedResource(fooPath, 9, new FileResource(IO.getFile("testresources/mr/java9/Foo.class")));
jar.putVersionedResource(barPath, 17, new FileResource(IO.getFile("testresources/mr/java17/Bar.class")));
jar.setManifest(a.calcManifest());
Manifest mainMf = jar.getManifest();
Optional<Manifest> java9Mf = jar.getManifest(9);
Optional<Manifest> java17Mf = jar.getManifest(17);
assertThat(mainMf.getMainAttributes()
.getValue(Constants.REQUIRE_CAPABILITY)).isNotNull()
.contains("(&(osgi.ee=JavaSE)(version=1.8))");
assertThat(java9Mf.get()
.getMainAttributes()
.getValue(Constants.REQUIRE_CAPABILITY)).isNotNull()
.contains("(&(osgi.ee=JavaSE)(version=9))");
assertThat(java17Mf.get()
.getMainAttributes()
.getValue(Constants.REQUIRE_CAPABILITY)).isNotNull()
.contains("(&(osgi.ee=JavaSE)(version=17))");
}
}

}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.