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

Problem extending bundle with custom library #3

Open
piotrkot opened this issue Mar 22, 2017 · 2 comments
Open

Problem extending bundle with custom library #3

piotrkot opened this issue Mar 22, 2017 · 2 comments

Comments

@piotrkot
Copy link

There is a problem with extending the bootstrap connector bundle with custom library.

Steps to reproduce:

  1. Create a small custom library having just one class in it.
public final class Dummy {
    public String print() {
        return "I'm dummy";
    }
}

or take any library that is not publicly available.

  1. Add the library to the connector under the new lib location, i.e. aem-translation-framework-bootstrap-connector/bundle/lib/dummy-1.0-SNAPSHOT.jar
  2. Add dependency to the bootstrap-connector.bundle pom file
        <dependency>
            <groupId>com.example.dummy</groupId>
            <artifactId>dummy</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
  1. Instruct maven to add the library into the bundle by adding configuration to the maven-bundle-plugin in bootstrap-connector.bundle pom file
<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
        <instructions>
            <!--
            <Embed-Dependency>
              artifactId1,
              artifactId2;inline=true
            </Embed-Dependency>
            -->
            <Export-Package>
                com.adobe.granite.translation.connector.bootstrap.core
            </Export-Package>
            <Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
            <Embed-Directory>lib</Embed-Directory>
            <Embed-Transitive>true</Embed-Transitive>
        </instructions>
    </configuration>
</plugin>

It does not matter if the library is embedded or inlined since if doesn't work in both cases. (I prefer inlined)

  1. Call the library from the code, for example in BootstrapTranslationServiceImpl.java add private Dummy dummy = new Dummy(); on line 63.

  2. Deploy the bundle to the AEM instance.

Problem: When creating translation project boostrap name in no longer available on the Translation Provider list. And there is no errors in logs.

@sridharjayakumar
Copy link
Contributor

sridharjayakumar commented Mar 27, 2017

@piotrkot Please take a look at https://github.com/Adobe-Marketing-Cloud/aem-translation-framework-bootstrap-connector/tree/master/content/src/main/content/jcr_root/apps/bootstrap-connector/install. There is already a custom bundle that is provided to show how to extend the Bootstrap connector. The connector is simply a framework provided to show how the translation APIs work.

@piotrkot
Copy link
Author

piotrkot commented Mar 27, 2017

@sridharjayakumar Yes, I saw how the bootstrap-content includes the custom bundle for the bootstrap-bundle but I personally just don't find it right. Firstly, it requires to build a separated bundle from the custom library. Secondly, dependency required by the bootstrap-bundle is added in the bootstrap-content. Not relevant modules become relevant which contradicts my idea of single-responsibility principle. Thirdly, a bundle with custom library would have to be visible with its services exposed. This violates the restrictions set on the custom library.
Is your solution the only one available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants