AEM 6.5 add Third party dependency And AEM OSGI shows 'com.twilio -- Cannot be resolved' - aem

I want to add the dependency of twilio in AEM 6.5,there is an error such as the image
This is the dependency I added
so,How can AEM correctly introduce third-party dependencies?

You have to install the dependency as an OSGi bundle. Some libraries provide OSGi bundles as part of their releases, others you’ll have to bundle yourself. One of the ways to do this is with bnd from bndtools. They have a guide that should help you get started: https://bnd.bndtools.org/chapters/390-wrapping.html
Once you have that, you need to ensure it declares the packages you depend on as exported and then you need to install it into your AEM. From that point on, the dependencies will be marked as resolved.

Related

OSGi jar restricted inside a CQ5/ AEM component

Is it possible to install a OSGi jar to Felix by keeping the jar as a part of the cq5 component and install it on build?
You cannot restrict an OSGi bundle so that only one CQ component can use it. If an OSGi bundle exports a java package, that will be visible from all java and scripting code.
You can include it in a content package at build time, if you're targeting this with your question. The multimodule-content-package-archetype provided by Adobe does that as well.

GWT Custom Library Dependency issues

I have created a library of widgets that export to a jar and reuse in several other projects. In my library, I depend on a few other jars in my war/WEB-INF/lib. The problem is that when I use my library in another project the dependencies of the library do not get carried over so I have to add those jars to the classpath and inherit them in the project as well. There has got to be a better way to handle the dependencies, do I need to use maven or is there another practice that works?
Yes, if you don't want to manually manage your dependencies you will have to use a dependency management system. The 3 big ones are Maven, Ivy, and Gradle. I have included links below so you can read about them. A quick search will reveal the pros/cons of each from the community and also information about alternative dependency management systems. There are quite a few out there.
Apache Maven
Apache Ivy
Gradle

Developing eclipse plugin using maven dependencies

I've been beating my head against a wall for about 6 months now and have not found a concise way of understanding the mechanism for developing an eclipse plugin with third-party resources.
We are attempting to develop an Eclipse ODA to ride on top of in-house Spring-based code that accesses a REST based info set.
In broad strokes - this is what I feel that we need to be able to do:
Augment our maven artifacts with Eclipse bundle information using tycho or a the felix bundle plugin.
Set up a plugin project through Eclipse for the ODA Implementation & UI.
Have Tycho generate the poms etc for the plugin.
Now here's where I get muddy. I understand that there are two approaches
Manifest-First - which is the standard mechanism for defining a plugin's dependencies
POM-First - which provides dependencies via Maven's resolution mechanisms.
I'm not entirely sure where to begin trying to start doing this as I've never worked on developing an eclipse plugin.
One of the other questions I have is, how does a developer of an eclipse plugin (maven aside) leverage already existing third-party code (i.e. Apache HttpClient 4.x)? Do they have to download the jars, dump them into a directory within the project, add to classpath, then go from there or is there a "repository" mechanism similar to what is used with ivy, maven, gradle?
Thanks in advance and I apologize if I was rambling a bit with that.
Disclaimer: Your question is very broad, so it is impossible to answer it completely. Still, I can give you some hints so that you know what to search for.
In the Eclipse universe, the primary source for libraries (in the sense of binary dependencies) are p2 repositories. However, since p2 repositories are rarely used outside of the Eclipse context, you won't e.g. find a p2 repository on the Apache HTTP Client project's download page.
To account for this problem, there is the Eclipse Orbit Project which provides libraries used by Eclipse projects in p2 repositories.
If you can't find the library or library version in the Eclipse Orbit, you may also be able to use the libraries from Maven repositories. This is for example supported by Tycho via the pomDependencies=consider mechanism.
Note however that Eclipse plug-ins can only depend on libraries which are OSGi bundles. So if the library in the Maven repository is not yet an OSGi bundle, you need to convert it to an OSGi bundle first, e.g. with the maven-bundle-plugin and the Embed-Dependency mechanism.
The best way for an Eclipse plugin to consume libraries is as OSGi bundles. You just install those bundles into your target platform and reference them in the same way as eclipse.org plugins. Some of the library providers already offer their libraries as OSGi bundles. Absent that, you can typically turn a plain library jar into an OSGi bundle simply by adding a few manifest entries.
Depending on the build system you use and whether the libraries you need are available as OSGi bundles packaged into an online p2 repository, you can reference the URL and rely on your build to download and install the bundle.
If question of choosing a build system for Eclipse plugins with dependencies is still relevant:
Today I released new gradle plugin: Wuff version 0.0.1, which (I think) completely solves the problem. It allows to build Eclipse bundles and applications as they would be "normal" Gradle projects. All OSGi woodoo is auto-generated (although customizable). All dependencies are usual maven dependencies - regardless of whether dependency is OSGi or "normal" library.
Sources and doc: https://github.com/akhikhl/wuff

Netty eclipse "no mandatory external dependencies"? import errors

I just downloaded Netty for a personal client-server-project from here:
http://netty.io/downloads/netty-3.3.0.Final-dist.tar.bz2
On the download page http://netty.io/downloads/ it says there are "no mandatory external dependencies". You only need a JDK 1.5 or higher. So I just set up a java project in eclipse IDE using my 1.6 JDK and got multiple errors saying "import cannot be resolved".
Examples:
org.jboss.logging, com.google, org.osgi, javax.servlet
That tells me that there are actually some external libraries needed. Or am I doing anything wrong?
Can anyone tell me where to find all these libraries since I could not find any clues on the Netty pages where to get them (I know that javax.servlet is part of Tomcat and JBoss AS distribution, but why do they then say that no external libraries are needed).
Are you trying to build netty from source? There's a pom.xml file in the root, implying that netty can be built by maven. You'll find all those dependencies in the pom file. "No mandatory external dependencies" means that you need no jar other than the netty jar to run your application. External dependecies is probably needed for some of the examples, definitively for testing and perhaps for some special, but optional, run time features.
The dependencies are only used for building and are marked as optional. The dependencies are only needed if you want for example use slf4j for logging in netty. Beside this netty can be used within your project without pulling in any third-party dependencies.

How can a maven build process be retrofitted to an eclipse developed plugin?

The eclipse plugin development environment is a pretty handy tool when creating from scratch a set of OSGi bundles that need to work together. Particularly this is true when trying to get all the package imports and exports and other manifest fluff right during development, or if there are third party jars that need to be embedded. But trying to retrofit a maven build process around this afterwards seems to be pretty tricky, mainly because most of the maven plugins for bundling/OSGi build the manifest themselves, whereas using the PDE, you are handcrafting the manifest.
What is the best way to retrofit a maven build process to a bunde/set of bundles, that dont respect the standard maven project layout, and already have handcrafted manifests?
Use Tycho. It lacks some documentation, but it does just that: builds the plugins using the PDE semantics (actually, it uses PDE compiler internally). So, all you need is to create almost empty pom.xml's for your modules.