Comments (16)
We aren't familiar with, and do not use this type of library. If you could explain what's involved in detail, or provide a pull request, it would be much easier to evaluate this.
from stringtemplate4.
I want to use StringTemplate and ANTLR libraries in my application based on OSGI. I have two ways to to do that:
- Embed dependency in my OSGI bundle (not reusable and can cause ClassLoader problems)
- Install StringTemplate and ANTLR libraries as OSGI bundles
OSGI bundle is just a JAR file with special Manifest Headers. Without these headers OSGI environment (such as Apache Felix) couldn't install and load these libraries. The easiest way to do that is to add maven-bundle-plugin
to your POM.xml.
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>org.antlr.stringTemplate</Bundle-SymbolicName>
<Export-Package>org.stringtemplate.*</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
As you can see, it is quite simple. maven-bundle-plugin
will add all necessary headers to JAR Manifest. And you library can be used in OSGI and non-OSGI environments both.
from stringtemplate4.
Has there been any recent consideration of this? The change should have no impact unless an OSGi application kernel is being utilized. If you want I'll make the changes and send in a pull request.
from stringtemplate4.
How about including the main antlr tool, which includes st 4?
from stringtemplate4.
Are you suggesting adding OSGi metadata for the monolithic antlr artifact vice adding it to the ST4 artifact, or saying that this has been done already and I should be installing the main antlr tool?
If the former then yes; that would be a good idea and I would be happy to contribute.
from stringtemplate4.
latest antlr jars are osgi compatible
T
On Mar 19, 2015, at 11:43 AM, Craig Niles [email protected] wrote:
Are you suggesting adding OSGi metadata for the monolithic antlr artifact vice adding it to the ST4 artifact, or saying that this has been done already and I should be installing the main antlr tool?
If the former then yes; that would be a good idea and I would be happy to contribute.
�
Reply to this email directly or view it on GitHub.
from stringtemplate4.
Looking through the public antlr 4.5 artifacts:
The one maven artifact that has OSGi headers is org.antlr/antlr4-runtime/4.5 (antlr4-runtime-4.5jar), but it doesn't contain the ST4 classes. The ST4 classes are in the artifact org.antlr/antlr4/4.5 but the osgi headers are not present in the jar's manifest.
Are these changes that are still not released (4.5.1)?
from stringtemplate4.
Looking for antlr 4.5.x complete jar with StringTemplate-4 api exported and usable in eclipse plug-in development environment.
The antlr.org site claim that the provided jar files are osgi ready, but it's not the case for antlr-4.5.3-complete.jar. the provided manifest.mf don't provide any package export.
On the other hand, the runtime version : antlr-runtime-4.5.3 is osgi ready, but don't provide StringTemplate-4 packages. Meanwhile, no osgi version of StringTemplate-4 is provided.
In result, we have very hard time using ST4 and ANTLR4 in eclipse plug-in development env.
Can anyone help provide something more effective to a low profil developper like me ? This will really help me cross the river. Thanks.
from stringtemplate4.
You can solve this problem in this way:
- Create
antlr-bundlized
maven module in your poject - Define packaging
bundle
to your module - Specify artifact ID of ANTLR inside of
<Embed-Dependency>
tag in the configuration section ofmaven-bundle-plugin
module. And don't forget to specifyscope:=compile
inside of this tag. - Declare dependency on ANTLR with
compile
scope (any other OSGi-friendly dependencies should be declared withprovided
scope) - Declare
<Embed-Transitive>
tag with valuetrue
in the configuration section - Specify
<Export-Package>
tag in the configuration section ofmaven-bundle-plugin
and setorg.antlr.*
as its value
Now you can use your antlr-bundlized
module as OSGi-friendly version of ANTLR.
from stringtemplate4.
We've now moved all the way in this direction for the ANTLR 4 runtime. However, that library proved easier than ST4, especially now that we've eliminated its last external dependency. I'll look at implementing this for ST4 as well, but there's an interesting dependency chain here:
ST4 → ANTLR 3 → ST3 → ANTLR 2
The real reason this is so interesting is twofold:
- ST4 doesn't use any features of ANTLR 3 which depend on ST3. However, ANTLR 3 as an independent bundle would need to declare the ST3 dependency.
- The shaded ST4 bundle wouldn't have any external dependencies, but maven-bundle-plugin runs before maven-shade-plugin so the manifest for the complete jar still lists imports for the ANTLR 3 runtime, even though they aren't actually required. I found this answer on Stack Overflow which suggests solutions to this exist, but I haven't followed this investigation to the end yet.
from stringtemplate4.
I would like to play with this, but when I run mvn clean verify, the resulting jar does not contain the 'st4hidden' package that is in the jar I can download from the st website. What am I missing?
from stringtemplate4.
@felixdo Does the resulting jar not operate as you would expect?
from stringtemplate4.
No. I would like to produce a standalone OSGI bundle with no external dependencies for st4, which afaiu is the goal of this issue, and which does not exist atm. I would therefore need to include the antlr runtime just as it is included in ST-4.0.8.jar that I get from the st4 website. mvn clean verify does however not create that mysterious st4hidden package which contains the required antlr runtime.
from stringtemplate4.
oh, well i guess we need to use the mvn shade thing to build a combined lib.
from stringtemplate4.
yes that's what I meant. I thought the pom here already included that part.
from stringtemplate4.
Maybe not even needed to include antlr, since that is already available in eclipse orbit https://dev.eclipse.org/ipzilla/show_bug.cgi?id=4865, so if we produce a bundle with a dependency on that, it should work. or not, if i still don't understand the dependency chain here... :)
from stringtemplate4.
Related Issues (20)
- Hidden argument <i> reported as an error when rendering templates HOT 2
- CDATA section HOT 2
- Loading template group from STGroupDir in app running on Tomcat 8 fails HOT 12
- How to pass arguments for indirect template call? HOT 3
- Incorrect indentation HOT 4
- Integrating stringtemplate4 into OSS-Fuzz HOT 1
- ST4-testjar not found HOT 9
- Use Class.getDeclaredField instead of Class.getField HOT 2
- Separator not emitted for nulls until a value is hit HOT 4
- Multiple special characters in a single <...> does not work as documented HOT 1
- You cannot use i as variable name HOT 3
- Should support coercing the (non)emptiness of a Map or Collection to a Boolean for conditionals of the form `<if(a.p)>` where `p` is a Collection or Map HOT 2
- Comparison with python based template engines like jinja2/mustache
- Looking for code samples cited in this article: Language Translation Using ANTLR and StringTemplate HOT 4
- Support for Java records HOT 2
- Test failures like org.junit.ComparisonFailure: expected:<...etime: 7/5/05, 12:00[ ]AM> but was:<...etime: 7/5/05, 12:00[ ]AM>
- Successful test prints error
- Does it support Custom Function?
- Help newbies with ANTLR dependencies
- correct StackOverflowEerror from rendering `java.nio.Path` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stringtemplate4.