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

[tycho-4.0.x] add bundle using bnd's sub-bundles via -sub: *.bnd #4669

Merged
merged 1 commit into from
Feb 1, 2025
Merged
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
2 changes: 1 addition & 1 deletion demo/bnd-workspace/.mvn/maven.config
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-Dtycho-version=4.0.0-SNAPSHOT
-Dtycho-version=4.0.11
6 changes: 5 additions & 1 deletion demo/bnd-workspace/cnf/ext/central.mvn
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Contains all bundles to consume from maven central

org.osgi:osgi.core:8.0.0
org.osgi:osgi.annotation:8.1.0
org.osgi:org.osgi.service.component.annotations:1.5.1
org.osgi:org.osgi.service.component.annotations:1.5.1
org.osgi:org.osgi.service.component:1.5.1
org.commonmark:commonmark:0.22.0
org.commonmark:commonmark-ext-gfm-tables:0.22.0
1 change: 1 addition & 0 deletions demo/bnd-workspace/tycho.demo.impl/bnd.bnd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-buildpath: osgi.annotation, \
tycho.demo.api, \
tycho.demo.markdown.api,\
org.osgi.service.component.annotations
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@

import org.eclipse.tycho.demo.api.HelloWorld;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import tycho.demo.utils.markdown.api.MarkdownRenderer;

@Component
public class HelloWorldService implements HelloWorld {

@Reference
private MarkdownRenderer markdown;

public void sayHello() {
System.out.println("Hello BND Workspace!");

System.out.println("Render some markdown to HTML: " + markdown.render("## H2 Headline"));
}
}
1 change: 1 addition & 0 deletions demo/bnd-workspace/tycho.demo.markdown/api.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Export-Package: tycho.demo.utils.markdown.api
8 changes: 8 additions & 0 deletions demo/bnd-workspace/tycho.demo.markdown/bnd.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-sub: *.bnd

-buildpath: \
osgi.core;version=latest,\
osgi.annotation;version=latest,\
org.osgi.service.component.annotations;version=latest,\
org.commonmark:commonmark;version=latest,\
org.commonmark:commonmark-ext-gfm-tables;version=latest
8 changes: 8 additions & 0 deletions demo/bnd-workspace/tycho.demo.markdown/impl.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-privatepackage: tycho.demo.utils.markdown.impl



-includeresource: \
${repo;org.commonmark:commonmark;latest}; lib:=true,\
${repo;org.commonmark:commonmark-ext-gfm-tables;latest}; lib:=true,\

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*******************************************************************************
* Copyright (c) 2025 Christoph Rüger 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 Rüger - extend example to use bnd -sub instruction
*******************************************************************************/
package tycho.demo.utils.markdown.api;

public interface MarkdownRenderer {

/**
* Renders markdown string to html.
*
* @param markdown
* @return
*/
String render(String markdown);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*******************************************************************************
* Copyright (c) 2025 Christoph Rüger 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 Rüger - extend example to use bnd -sub instruction
*******************************************************************************/
package tycho.demo.utils.markdown.impl;

import java.util.Arrays;
import java.util.List;

import org.commonmark.Extension;
import org.commonmark.ext.gfm.tables.TablesExtension;
import org.commonmark.node.Node;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;
import org.osgi.service.component.annotations.Component;

import tycho.demo.utils.markdown.api.MarkdownRenderer;

@Component
public class MarkdownRendererImpl implements MarkdownRenderer {

private Parser parser;
private HtmlRenderer renderer;

public MarkdownRendererImpl() {
List<Extension> extensions = Arrays.asList(TablesExtension.create());

this.parser = Parser.builder().extensions(extensions).build();
this.renderer = HtmlRenderer.builder().extensions(extensions).build();
}

@Override
public String render(String markdown) {

Node document = parser.parse(markdown);
return renderer.render(document);
}

}
Loading