Closed adityarathore closed 6 years ago
First of all, I'd like to encourage you to check out Gradle basics, e.g on page: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html Knowledge of basic Gradle's structural elements like project, tasks, extension is crucial to understand migration from Maven to Gradle.
Gradle buidscripts are being extended by plugins via line e.g apply plugin: 'org.dm.bundle'
.
Then that plugin https://github.com/TomDmitriev/gradle-bundle-plugin#instructions provides new sections in our buildscript, like bundle {}
, so that we can configure new tasks (https://docs.gradle.org/current/userguide/more_about_tasks.html) or extensions (https://docs.gradle.org/current/userguide/custom_plugins.html#sec:getting_input_from_the_build).
About bundle
plugin, please take a look at example project which uses Gradle AEM Plugin:
https://github.com/Cognifide/gradle-aem-example/blob/master/app/core/build.gradle . In that file you have configured a project which is a OSGi bundle in which you can specify import package, sling models's specific instructions etc.
To achieve artifact embedding (Embed-Dependency
), just declare compile depenendency using special configuration name aemEmbed
instead of compile
in dependencies
section. See example already included in example project: https://github.com/Cognifide/gradle-aem-example/blob/master/app/common/build.gradle#L26
About SCR plugin... in features section (https://github.com/Cognifide/gradle-aem-plugin#features) I noticed that plugin assumes usage of new standarized OSGi annotations / Declarative Services instead of Service Component Runtime annotations. This standard is available also on AEM since 6.2 version. http://blogs.adobe.com/experiencedelivers/experience-management/osgi/using-osgi-annotations-aem6-2/ . Refactoring code from old annotations to new ones is most often trivial. SCR support in Gradle AEM plugin was implemented in 1.x version, but after wider consultancy I decided to abandon support for that old form of declaring OSGi services. It was very problematic due to SCR generator classloading issues (#18). New OSGi annotations processing does not have such problems and are being covered by BND plugin itself (which is used under the hood by org.dm.bundle
plugin).
Java example for declaring filter using new annotations: https://github.com/Cognifide/gradle-aem-example/blob/master/app/core/src/main/java/com/company/aem/example/core/LoggingFilter.java
Kotlin example (with OSGi configuration admin): https://github.com/Cognifide/gradle-aem-example/blob/master/app/core/src/main/kotlin/com/company/aem/example/core/services/posts/PostsService.kt#L18
If there is sth more to clarify, just let me know. I will try to help as much as I can. Greetings, Krystian.
I am planning to extend docs by adding howtos section with clarifications for such questions.
Thank you very much for getting back and answering the question in detail.
Np 😉
Hello,
How do we define plugins in gradle? e.g how we would write plugin like below