Skip to content

Commit c5d5d1a

Browse files
authored
Merge pull request #6908 from chrisrueger/improve-magicbnd-pmvn-parsing
fix .pmvn parsing
2 parents c2b8047 + 709b6a5 commit c5d5d1a

File tree

5 files changed

+108
-2
lines changed

5 files changed

+108
-2
lines changed

biz.aQute.bndlib.tests/test/test/WorkspaceTest.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020
import aQute.bnd.build.Project;
2121
import aQute.bnd.build.Workspace;
2222
import aQute.bnd.header.Attrs;
23+
import aQute.bnd.header.Parameters;
2324
import aQute.bnd.osgi.About;
2425
import aQute.bnd.osgi.Constants;
2526
import aQute.bnd.osgi.Processor;
27+
import aQute.bnd.repository.maven.provider.MavenBndRepository;
28+
import aQute.bnd.repository.osgi.OSGiRepository;
2629
import aQute.bnd.test.jupiter.InjectTemporaryDirectory;
2730
import aQute.lib.io.IO;
2831
import aQute.lib.strings.Strings;
@@ -382,4 +385,36 @@ void workspace_lock_deadlock_write_read_write() throws Exception {
382385
}, 10_000L);
383386
}
384387
}
388+
389+
/**
390+
* Tests the parsing of .pmv, pobr files in MagicBnd.java See
391+
* https://bnd.bndtools.org/chapters/150-build.html#the-cnfext-directory
392+
*/
393+
@Test
394+
public void testMagicBnd() throws Exception {
395+
IO.copy(IO.getFile("testresources/ws-magicbnd"), testDir);
396+
try (Workspace ws = new Workspace(testDir)) {
397+
398+
List<MavenBndRepository> plugins = ws.getPlugins(MavenBndRepository.class);
399+
assertThat(plugins).hasSize(1);
400+
401+
Parameters mvn = ws.getMergedParameters("-plugin.ext.org.bndtools.demo.webapp.pmvn");
402+
Attrs attrs = mvn.get("aQute.bnd.repository.maven.provider.MavenBndRepository");
403+
assertThat(attrs.get("index")).contains("testMagicBnd/cnf/ext/org.bndtools.demo.webapp.pmvn");
404+
assertThat(attrs.get("name")).isEqualTo("org.bndtools.templates.osgi-servlet");
405+
assertThat(attrs.get("releaseUrl")).isEqualTo("https://repo.maven.apache.org/maven2/somethingforthetest");
406+
assertThat(attrs.get("snapshotUrl"))
407+
.isEqualTo("https://oss.sonatype.org/content/repositories/snapshots/somethingforthetest");
408+
409+
List<OSGiRepository> plugins2 = ws.getPlugins(OSGiRepository.class);
410+
assertThat(plugins2).hasSize(1);
411+
412+
Parameters obr = ws.getMergedParameters("-plugin.ext.eclipse.p2-helper.xml.pobr");
413+
Attrs attrs2 = obr.get("aQute.bnd.repository.osgi.OSGiRepository");
414+
assertThat(attrs2.get("locations")).contains("testMagicBnd/cnf/ext/eclipse.p2-helper.xml.pobr");
415+
assertThat(attrs2.get("name")).isEqualTo("Eclipse_2022-12-Legacy");
416+
417+
}
418+
419+
}
385420
}

biz.aQute.bndlib.tests/testresources/ws-magicbnd/cnf/build.bnd

Whitespace-only changes.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<!--
3+
This repository contains a few manually added dependencies
4+
from previous / older Eclipse version which are still needed, but dropped in more recent
5+
Eclipse versions. Those are mostly non-OSGi libs for which no OSGi-bundle exists on Maven Central
6+
but were OSGified by Eclipse team.
7+
-->
8+
<repository xmlns="http://www.osgi.org/xmlns/repository/v1.0.0" name="Eclipse_2022-12-Legacy" increment="1759431158054">
9+
<resource>
10+
<capability namespace="osgi.identity">
11+
<attribute name="osgi.identity" value="org.hamcrest.core"/>
12+
<attribute name="type" value="osgi.bundle"/>
13+
<attribute name="version" value="1.3.0.v20180420-1519" type="Version"/>
14+
</capability>
15+
<capability namespace="osgi.wiring.package">
16+
<directive name="uses" value="org.hamcrest.core,org.hamcrest.internal"/>
17+
<directive name="mandatory" value="core"/>
18+
<attribute name="core" value="split"/>
19+
<attribute name="bundle-symbolic-name" value="org.hamcrest.core"/>
20+
<attribute name="bundle-version" value="1.3.0.v20180420-1519" type="Version"/>
21+
<attribute name="osgi.wiring.package" value="org.hamcrest"/>
22+
<attribute name="version" value="1.3.0" type="Version"/>
23+
<attribute name="bnd.hashes" value="-366206901,515220737,-1789452028,1600917233,2587372,1142656251,-269945248,-1637731231,-1106348678,1980707797,-56677412,-606507625,572770538,2071941500,-1789452014,-748688648,819664212,-1774319861,977265264,447226155" type="List&lt;Long&gt;"/>
24+
</capability>
25+
<capability namespace="osgi.wiring.package">
26+
<directive name="uses" value="org.hamcrest"/>
27+
<attribute name="bundle-symbolic-name" value="org.hamcrest.core"/>
28+
<attribute name="bundle-version" value="1.3.0.v20180420-1519" type="Version"/>
29+
<attribute name="osgi.wiring.package" value="org.hamcrest.core"/>
30+
<attribute name="version" value="1.3.0" type="Version"/>
31+
<attribute name="bnd.hashes" value="63352632,63424707,16449521,103005741,-756275534,-70059797,67339003,2378,869720556,-2135792586,-572150774,-1057350090,70921513,-2096394767,-2096265008,-1050048887,1313826160,-670536913,-1834239032,-500995647" type="List&lt;Long&gt;"/>
32+
</capability>
33+
<capability namespace="osgi.wiring.package">
34+
<directive name="x-internal" value="true"/>
35+
<directive name="uses" value="org.hamcrest"/>
36+
<attribute name="bundle-symbolic-name" value="org.hamcrest.core"/>
37+
<attribute name="bundle-version" value="1.3.0.v20180420-1519" type="Version"/>
38+
<attribute name="osgi.wiring.package" value="org.hamcrest.internal"/>
39+
<attribute name="version" value="1.3.0" type="Version"/>
40+
<attribute name="bnd.hashes" value="951756231,-271425669,-1979006851,-485793781" type="List&lt;Long&gt;"/>
41+
</capability>
42+
<capability namespace="osgi.wiring.bundle">
43+
<attribute name="bundle-version" value="1.3.0.v20180420-1519" type="Version"/>
44+
<attribute name="osgi.wiring.bundle" value="org.hamcrest.core"/>
45+
</capability>
46+
<capability namespace="osgi.wiring.host">
47+
<attribute name="bundle-version" value="1.3.0.v20180420-1519" type="Version"/>
48+
<attribute name="osgi.wiring.host" value="org.hamcrest.core"/>
49+
</capability>
50+
<capability namespace="osgi.content">
51+
<attribute name="size" value="66997" type="Long"/>
52+
<attribute name="mime" value="application/vnd.osgi.bundle"/>
53+
<attribute name="url" value="https://download.eclipse.org/releases/2022-12/202212071000/plugins/org.hamcrest.core_1.3.0.v20180420-1519.jar"/>
54+
<attribute name="osgi.content" value="9DBEEC98D90D589B3BDFDEA604EAA484007A42572F7437C90C06B823063CD00A"/>
55+
</capability>
56+
<requirement namespace="osgi.ee">
57+
<directive name="filter" value="(&amp;(osgi.ee=JavaSE)(version=1.5))"/>
58+
</requirement>
59+
</resource>
60+
</repository>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# name = org.bndtools.templates.osgi-servlet
2+
# releaseUrl = https://repo.maven.apache.org/maven2/somethingforthetest
3+
# snapshotUrl = https://oss.sonatype.org/content/repositories/snapshots/somethingforthetest
4+
#
5+
# Repository for the template org.bndtools.templates.osgi-servlet
6+
# Source: https://github.com/bndtools/workspace-templates/servlet
7+
8+
#not relevant for the test org.slf4j:slf4j-api:1.7.36

biz.aQute.bndlib/src/aQute/bnd/build/MagicBnd.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
* This is used in included files in a bnd file. It allows another file to be
3535
* mapped to the properties. This can be used to setup a plugin that is
3636
* parameterized by that file.
37+
* <p>
38+
* See test.WorkspaceTest.testMagicBnd() for a test.
39+
* </p>
3740
*/
3841
public class MagicBnd {
3942
final static RE KEY_P = re("[\\w\\d_\\.]+");
@@ -155,11 +158,11 @@ private static Result<Properties> convertMaven(Workspace ws, File file) {
155158

156159
if (release.isEmpty())
157160
release.add("https://repo.maven.apache.org/maven2/");
158-
sb.append(";releaseUrl=")
161+
sb.append(";releaseUrl='")
159162
.append(release.stream()
160163
.collect(Collectors.joining()))
161164
.append("'");
162-
sb.append(";snapshotUrl=")
165+
sb.append(";snapshotUrl='")
163166
.append(snapshot.stream()
164167
.collect(Collectors.joining()))
165168
.append("'");

0 commit comments

Comments
 (0)