Giter Site home page Giter Site logo

Comments (16)

sharwell avatar sharwell commented on July 28, 2024

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.

sakno avatar sakno commented on July 28, 2024

I want to use StringTemplate and ANTLR libraries in my application based on OSGI. I have two ways to to do that:

  1. Embed dependency in my OSGI bundle (not reusable and can cause ClassLoader problems)
  2. 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.

cniles avatar cniles commented on July 28, 2024

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.

parrt avatar parrt commented on July 28, 2024

How about including the main antlr tool, which includes st 4?

from stringtemplate4.

cniles avatar cniles commented on July 28, 2024

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.

parrt avatar parrt commented on July 28, 2024

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.

cniles avatar cniles commented on July 28, 2024

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.

cbdiesse avatar cbdiesse commented on July 28, 2024

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.

sakno avatar sakno commented on July 28, 2024

You can solve this problem in this way:

  1. Create antlr-bundlized maven module in your poject
  2. Define packaging bundle to your module
  3. Specify artifact ID of ANTLR inside of <Embed-Dependency> tag in the configuration section of maven-bundle-plugin module. And don't forget to specify scope:=compile inside of this tag.
  4. Declare dependency on ANTLR with compile scope (any other OSGi-friendly dependencies should be declared with provided scope)
  5. Declare <Embed-Transitive> tag with value true in the configuration section
  6. Specify <Export-Package> tag in the configuration section of maven-bundle-plugin and set org.antlr.* as its value

Now you can use your antlr-bundlized module as OSGi-friendly version of ANTLR.

from stringtemplate4.

sharwell avatar sharwell commented on July 28, 2024

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:

  1. 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.
  2. 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.

felixdo avatar felixdo commented on July 28, 2024

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.

parrt avatar parrt commented on July 28, 2024

@felixdo Does the resulting jar not operate as you would expect?

from stringtemplate4.

felixdo avatar felixdo commented on July 28, 2024

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.

parrt avatar parrt commented on July 28, 2024

oh, well i guess we need to use the mvn shade thing to build a combined lib.

from stringtemplate4.

felixdo avatar felixdo commented on July 28, 2024

yes that's what I meant. I thought the pom here already included that part.

from stringtemplate4.

felixdo avatar felixdo commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.